Re: [PATCH v2] leds: use devm_platform_ioremap_resource() API to simplify code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

> From: chenqiwu <chenqiwu@xxxxxxxxxx>
> 
> 1. Use a wrapped API devm_platform_ioremap_resource() instead of
> calling platform_get_resource() and devm_ioremap_resource()
> separately to simplify code.
> 2. Add error checking and error processing for led driver probe.
> 
> Signed-off-by: chenqiwu <chenqiwu@xxxxxxxxxx>

Do you still want me to apply this?

Did someone test it?

> +++ b/drivers/leds/leds-cobalt-qube.c
> @@ -36,20 +36,22 @@ static void qube_front_led_set(struct led_classdev *led_cdev,
>  
>  static int cobalt_qube_led_probe(struct platform_device *pdev)
>  {
> -	struct resource *res;
> +	int retval;
>  
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res)
> -		return -EBUSY;
> -
> -	led_port = devm_ioremap(&pdev->dev, res->start, resource_size(res));
> -	if (!led_port)
> -		return -ENOMEM;
> +	led_port = devm_platform_ioremap_resource(pdev, 0);
> +	if (IS_ERR(led_port))
> +		return PTR_ERR(led_port);
>  
>  	led_value = LED_FRONT_LEFT | LED_FRONT_RIGHT;
>  	writeb(led_value, led_port);
>  
> -	return devm_led_classdev_register(&pdev->dev, &qube_front_led);
> +	retval = devm_led_classdev_register(&pdev->dev, &qube_front_led);
> +	if (retval) {
> +		devm_ioremap_release(&pdev->dev, led_port);
> +		led_port = NULL;
> +	}

Do we need to do the devm_..._release?
									Pavel
									
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux