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>
This commit is contained in:
Axel Lin 2011-08-08 17:17:18 +08:00 committed by Matthew Garrett
parent e9298028ee
commit 8fcf71aa00
1 changed files with 6 additions and 6 deletions

View File

@ -459,17 +459,17 @@ static enum led_brightness asus_kled_cdev_get(struct led_classdev *led_cdev)
static void asus_led_exit(struct asus_laptop *asus) static void asus_led_exit(struct asus_laptop *asus)
{ {
if (asus->mled.led.dev) if (!IS_ERR_OR_NULL(asus->mled.led.dev))
led_classdev_unregister(&asus->mled.led); led_classdev_unregister(&asus->mled.led);
if (asus->tled.led.dev) if (!IS_ERR_OR_NULL(asus->tled.led.dev))
led_classdev_unregister(&asus->tled.led); led_classdev_unregister(&asus->tled.led);
if (asus->pled.led.dev) if (!IS_ERR_OR_NULL(asus->pled.led.dev))
led_classdev_unregister(&asus->pled.led); led_classdev_unregister(&asus->pled.led);
if (asus->rled.led.dev) if (!IS_ERR_OR_NULL(asus->rled.led.dev))
led_classdev_unregister(&asus->rled.led); led_classdev_unregister(&asus->rled.led);
if (asus->gled.led.dev) if (!IS_ERR_OR_NULL(asus->gled.led.dev))
led_classdev_unregister(&asus->gled.led); led_classdev_unregister(&asus->gled.led);
if (asus->kled.led.dev) if (!IS_ERR_OR_NULL(asus->kled.led.dev))
led_classdev_unregister(&asus->kled.led); led_classdev_unregister(&asus->kled.led);
if (asus->led_workqueue) { if (asus->led_workqueue) {
destroy_workqueue(asus->led_workqueue); destroy_workqueue(asus->led_workqueue);