Linux LED subsystem development
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: qiwuchen55@gmail.com
Cc: florian@openwrt.org, yuasa@linux-mips.org,
	jacek.anaszewski@gmail.com, dmurphy@ti.com,
	linux-leds@vger.kernel.org, chenqiwu <chenqiwu@xiaomi.com>
Subject: Re: [PATCH v2] leds: use devm_platform_ioremap_resource() API to simplify code
Date: Mon, 27 Apr 2020 14:17:20 +0200	[thread overview]
Message-ID: <20200427121720.GC544@duo.ucw.cz> (raw)
In-Reply-To: <66479474345d3df541eca961d953c6b4420c87ce.1582732388.git.chenqiwu@xiaomi.com>

[-- Attachment #1: Type: text/plain, Size: 1527 bytes --]

Hi!

> From: chenqiwu <chenqiwu@xiaomi.com>
> 
> 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@xiaomi.com>

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

      reply	other threads:[~2020-04-27 12:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26 16:10 [PATCH v2] leds: use devm_platform_ioremap_resource() API to simplify code qiwuchen55
2020-02-26 16:10 ` qiwuchen55
2020-04-27 12:17   ` Pavel Machek [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200427121720.GC544@duo.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=chenqiwu@xiaomi.com \
    --cc=dmurphy@ti.com \
    --cc=florian@openwrt.org \
    --cc=jacek.anaszewski@gmail.com \
    --cc=linux-leds@vger.kernel.org \
    --cc=qiwuchen55@gmail.com \
    --cc=yuasa@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox