rk30 hdmi: fix hdmi shut down is called twice error.
authorZheng Yang <zhengyang@rock-chips.com>
Thu, 31 May 2012 06:44:00 +0000 (14:44 +0800)
committerZheng Yang <zhengyang@rock-chips.com>
Thu, 31 May 2012 06:44:00 +0000 (14:44 +0800)
drivers/video/display/display-sys.c
drivers/video/rockchip/hdmi/rk30_hdmi.c

index a0e245ec2bead8c95908990623fc963a0838c519..738b5689f81cb5d86e2df3a53d3989c9fbe0507f 100755 (executable)
@@ -373,7 +373,8 @@ struct rk_display_device *rk_display_device_register(struct rk_display_driver *d
                        if (!IS_ERR(new_dev->dev)) {
                                new_dev->parent = parent;
                                new_dev->driver = driver;
-                               new_dev->dev->driver = parent->driver;
+                               if(parent)
+                                       new_dev->dev->driver = parent->driver;
                                mutex_init(&new_dev->lock);
                                // Add new device to display device list.
                                {
index 37a05d07b71dd2e23e59cfc7193d375fd8ba4fb6..2272ca86883f8bb490e09d288e4e524cd252bb75 100755 (executable)
@@ -25,6 +25,7 @@ extern irqreturn_t hdmi_irq(int irq, void *priv);
 extern void hdmi_work(struct work_struct *work);\r
 extern struct rk_lcdc_device_driver * rk_get_lcdc_drv(char *name);\r
 extern void hdmi_register_display_sysfs(struct hdmi *hdmi, struct device *parent);\r
+extern void hdmi_unregister_display_sysfs(struct hdmi *hdmi);\r
 \r
 #ifdef CONFIG_HAS_EARLYSUSPEND\r
 static void hdmi_early_suspend(struct early_suspend *h)\r
@@ -92,7 +93,7 @@ static int __devinit rk30_hdmi_probe (struct platform_device *pdev)
        hdmi = kmalloc(sizeof(struct hdmi), GFP_KERNEL);\r
        if(!hdmi)\r
        {\r
-       dev_err(&pdev->dev, ">>rk30 lcdc inf kmalloc fail!");\r
+       dev_err(&pdev->dev, ">>rk30 hdmi kmalloc fail!");\r
        return -ENOMEM;\r
        }\r
        memset(hdmi, 0, sizeof(struct hdmi));\r
@@ -157,7 +158,7 @@ static int __devinit rk30_hdmi_probe (struct platform_device *pdev)
        register_early_suspend(&hdmi->early_suspend);\r
        #endif\r
                \r
-       hdmi_register_display_sysfs(hdmi, hdmi->dev);\r
+       hdmi_register_display_sysfs(hdmi, NULL);\r
        #ifdef CONFIG_SWITCH\r
        hdmi->switch_hdmi.name="hdmi";\r
        switch_dev_register(&(hdmi->switch_hdmi));\r
@@ -188,6 +189,7 @@ err2:
        #ifdef CONFIG_SWITCH\r
        switch_dev_unregister(&(hdmi->switch_hdmi));\r
        #endif\r
+       hdmi_unregister_display_sysfs(hdmi);\r
        #ifdef CONFIG_HAS_EARLYSUSPEND\r
        unregister_early_suspend(&hdmi->early_suspend);\r
        #endif\r
@@ -204,36 +206,43 @@ err0:
 \r
 static int __devexit rk30_hdmi_remove(struct platform_device *pdev)\r
 {\r
-       flush_scheduled_work();\r
-       destroy_workqueue(hdmi->workqueue);\r
-       #ifdef CONFIG_SWITCH\r
-       switch_dev_unregister(&(hdmi->switch_hdmi));\r
-       #endif\r
-       #ifdef CONFIG_HAS_EARLYSUSPEND\r
-       unregister_early_suspend(&hdmi->early_suspend);\r
-       #endif\r
-       iounmap((void*)hdmi->regbase);\r
-//     release_mem_region(res->start,(res->end - res->start) + 1);\r
-       clk_disable(hdmi->hclk);\r
-       kfree(hdmi);\r
-       hdmi_dbg(hdmi->dev, "rk30 hdmi unregistered.\n");\r
+       if(hdmi) {\r
+               flush_workqueue(hdmi->workqueue);\r
+               destroy_workqueue(hdmi->workqueue);\r
+               #ifdef CONFIG_SWITCH\r
+               switch_dev_unregister(&(hdmi->switch_hdmi));\r
+               #endif\r
+               hdmi_unregister_display_sysfs(hdmi);\r
+               #ifdef CONFIG_HAS_EARLYSUSPEND\r
+               unregister_early_suspend(&hdmi->early_suspend);\r
+               #endif\r
+               iounmap((void*)hdmi->regbase);\r
+       //      release_mem_region(res->start,(res->end - res->start) + 1);\r
+               clk_disable(hdmi->hclk);\r
+               kfree(hdmi);\r
+               hdmi = NULL;\r
+       }\r
+       printk(KERN_INFO "rk30 hdmi removed.\n");\r
        return 0;\r
 }\r
 \r
 static void rk30_hdmi_shutdown(struct platform_device *pdev)\r
 {\r
-       /* this func is called twice, bug? */\r
-       static bool first = true;\r
-\r
-       if (first) {\r
-               first = false;\r
-               return;\r
+       if(hdmi) {\r
+               flush_workqueue(hdmi->workqueue);\r
+               destroy_workqueue(hdmi->workqueue);\r
+               #ifdef CONFIG_SWITCH\r
+               switch_dev_unregister(&(hdmi->switch_hdmi));\r
+               #endif\r
+               hdmi_unregister_display_sysfs(hdmi);\r
+               #ifdef CONFIG_HAS_EARLYSUSPEND\r
+               unregister_early_suspend(&hdmi->early_suspend);\r
+               #endif\r
+               clk_disable(hdmi->hclk);\r
+               kfree(hdmi);\r
+               hdmi = NULL;\r
        }\r
-       if (!hdmi)\r
-               return;\r
-#ifdef CONFIG_HAS_EARLYSUSPEND\r
-       unregister_early_suspend(&hdmi->early_suspend);\r
-#endif\r
+       printk(KERN_INFO "rk30 hdmi shut down.\n");\r
 }\r
 \r
 static struct platform_driver rk30_hdmi_driver = {\r