]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00251209-9 msl: usb: make global variable as drvdata
authorPeter Chen <peter.chen@freescale.com>
Tue, 5 Mar 2013 03:21:04 +0000 (11:21 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:35:56 +0000 (08:35 +0200)
There is a bug when we try to remove wakeup module twice as
g_ctrl is a globle variable, in fact, it is per controller
wakeup driver, so the private data should be per device.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
arch/arm/plat-mxc/usb_wakeup.c

index 5d31d3621205273d43411de67ae72fb5a6d0017d..00af25f71a6abae686631680c658e3bf18d9e807 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2012 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2011-2013 Freescale Semiconductor, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -37,7 +37,6 @@ struct wakeup_ctrl {
        struct task_struct *thread;
        struct completion  event;
 };
-static struct wakeup_ctrl *g_ctrl;
 
 extern int usb_event_is_otg_wakeup(struct fsl_usb2_platform_data *pdata);
 extern void usb_debounce_id_vbus(void);
@@ -218,7 +217,7 @@ static int wakeup_dev_probe(struct platform_device *pdev)
        status = IS_ERR(ctrl->thread) ? -1 : 0;
        if (status)
                goto error2;
-       g_ctrl = ctrl;
+       platform_set_drvdata(pdev, ctrl);
 
        printk(KERN_DEBUG "the wakeup pdata is 0x%p\n", pdata);
        return 0;
@@ -231,13 +230,14 @@ error1:
 
 static int  wakeup_dev_exit(struct platform_device *pdev)
 {
-       if (g_ctrl->thread) {
-               g_ctrl->thread_close = true;
-               complete(&g_ctrl->event);
-               kthread_stop(g_ctrl->thread);
-       }
-       free_irq(g_ctrl->wakeup_irq, (void *)g_ctrl);
-       kfree(g_ctrl);
+       struct wakeup_ctrl *wctrl = platform_get_drvdata(pdev);
+
+       wctrl->thread_close = true;
+       complete(&wctrl->event);
+       kthread_stop(wctrl->thread);
+       free_irq(wctrl->wakeup_irq, (void *)wctrl);
+       kfree(wctrl);
+
        return 0;
 }
 static struct platform_driver wakeup_d = {