]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
platform-drivers-x86: eeepc-laptop: fix wrong test for successful registered led_classdev
authorAxel Lin <axel.lin@gmail.com>
Mon, 8 Aug 2011 09:14:19 +0000 (17:14 +0800)
committerMatthew Garrett <mjg@redhat.com>
Mon, 24 Oct 2011 14:52:38 +0000 (16:52 +0200)
device_create returns &struct device pointer on success, or ERR_PTR() on error.
Thus if led_classdev_register fails, led_cdev->dev is always not NULL.

If IS_ERR(eeepc->tpd_led.dev) is ture, it means led_classdev_register fails.
If (asus->tpd_led.dev) is NULL, it means we call eeepc_led_exit before
calling led_classdev_register for &eeepc->tpd_led.

We only want to call led_classdev_unregister for sucessfully registered
led_classdev, then we should check (!IS_ERR_OR_NULL(eeepc->tpd_led.dev)).

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
drivers/platform/x86/eeepc-laptop.c

index 1c45d92e21638230728a1f2919b1cc776360c937..ea44abd8df48d7db82c3b8e8a7d7c671cd00b028 100644 (file)
@@ -568,7 +568,7 @@ static int eeepc_led_init(struct eeepc_laptop *eeepc)
 
 static void eeepc_led_exit(struct eeepc_laptop *eeepc)
 {
-       if (eeepc->tpd_led.dev)
+       if (!IS_ERR_OR_NULL(eeepc->tpd_led.dev))
                led_classdev_unregister(&eeepc->tpd_led);
        if (eeepc->led_workqueue)
                destroy_workqueue(eeepc->led_workqueue);