Re: [PATCH 3/3] platform-drivers-x86: asus-laptop: fix wrong test forsuccessful registered led_classdev

From: Corentin Chary
Date: Mon Aug 08 2011 - 08:18:32 EST


On Mon, Aug 8, 2011 at 11:17 AM, Axel Lin <axel.lin@xxxxxxxxx> wrote:
> 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@xxxxxxxxx>

Acked-by: Corentin Chary <corentin.chary@xxxxxxxxx>


> ---
> Â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 fa6d7ec..0e071fa 100644
> --- a/drivers/platform/x86/asus-laptop.c
> +++ b/drivers/platform/x86/asus-laptop.c
> @@ -430,17 +430,17 @@ static enum led_brightness asus_kled_cdev_get(struct led_classdev *led_cdev)
>
> Â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);
> - Â Â Â if (asus->tled.led.dev)
> + Â Â Â if (!IS_ERR_OR_NULL(asus->tled.led.dev))
> Â Â Â Â Â Â Â Â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);
> - Â Â Â if (asus->rled.led.dev)
> + Â Â Â if (!IS_ERR_OR_NULL(asus->rled.led.dev))
> Â Â Â Â Â Â Â Â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);
> - Â Â Â if (asus->kled.led.dev)
> + Â Â Â if (!IS_ERR_OR_NULL(asus->kled.led.dev))
> Â Â Â Â Â Â Â Âled_classdev_unregister(&asus->kled.led);
> Â Â Â Âif (asus->led_workqueue) {
> Â Â Â Â Â Â Â Âdestroy_workqueue(asus->led_workqueue);
> --
> 1.7.4.1
>
>
>
>



--
Corentin Chary
http://xf.iksaif.net
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/