diff options
author | Axel Lin <axel.lin@gmail.com> | 2011-08-08 05:17:18 -0400 |
---|---|---|
committer | Matthew Garrett <mjg@redhat.com> | 2011-10-24 10:52:38 -0400 |
commit | 8fcf71aa0032acbd30b3222f9cb238919ab3b984 (patch) | |
tree | 04f2299615adfef58c098960fbc3524da5981498 /drivers/platform/x86/asus-laptop.c | |
parent | e9298028ee69bda44607156e7348cd32f7ab9360 (diff) |
platform-drivers-x86: asus-laptop: fix wrong test for successful registered led_classdev
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.
Thus to unregister a successful registered led_classdev, we should check
IS_ERR_OR_NULL macro for led_cdev->dev instead of checking if led_cdev->dev
is NULL or not.
we use IS_ERR_OR_NULL instead of IS_ERR because if we havn't call
led_classdev_register, the led_cdev->dev is NULL.
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>
Diffstat (limited to 'drivers/platform/x86/asus-laptop.c')
-rw-r--r-- | drivers/platform/x86/asus-laptop.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index afed9ff33b86..10b0a8663bb7 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c | |||
@@ -459,17 +459,17 @@ static enum led_brightness asus_kled_cdev_get(struct led_classdev *led_cdev) | |||
459 | 459 | ||
460 | static void asus_led_exit(struct asus_laptop *asus) | 460 | static void asus_led_exit(struct asus_laptop *asus) |
461 | { | 461 | { |
462 | if (asus->mled.led.dev) | 462 | if (!IS_ERR_OR_NULL(asus->mled.led.dev)) |
463 | led_classdev_unregister(&asus->mled.led); | 463 | led_classdev_unregister(&asus->mled.led); |
464 | if (asus->tled.led.dev) | 464 | if (!IS_ERR_OR_NULL(asus->tled.led.dev)) |
465 | led_classdev_unregister(&asus->tled.led); | 465 | led_classdev_unregister(&asus->tled.led); |
466 | if (asus->pled.led.dev) | 466 | if (!IS_ERR_OR_NULL(asus->pled.led.dev)) |
467 | led_classdev_unregister(&asus->pled.led); | 467 | led_classdev_unregister(&asus->pled.led); |
468 | if (asus->rled.led.dev) | 468 | if (!IS_ERR_OR_NULL(asus->rled.led.dev)) |
469 | led_classdev_unregister(&asus->rled.led); | 469 | led_classdev_unregister(&asus->rled.led); |
470 | if (asus->gled.led.dev) | 470 | if (!IS_ERR_OR_NULL(asus->gled.led.dev)) |
471 | led_classdev_unregister(&asus->gled.led); | 471 | led_classdev_unregister(&asus->gled.led); |
472 | if (asus->kled.led.dev) | 472 | if (!IS_ERR_OR_NULL(asus->kled.led.dev)) |
473 | led_classdev_unregister(&asus->kled.led); | 473 | led_classdev_unregister(&asus->kled.led); |
474 | if (asus->led_workqueue) { | 474 | if (asus->led_workqueue) { |
475 | destroy_workqueue(asus->led_workqueue); | 475 | destroy_workqueue(asus->led_workqueue); |