Linux-LEDs Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] leds: use devm_platform_ioremap_resource_byname()
@ 2020-02-14 15:48 qiwuchen55
  0 siblings, 0 replies; only message in thread
From: qiwuchen55 @ 2020-02-14 15:48 UTC (permalink / raw)
  To: jacek.anaszewski, pavel, dmurphy; +Cc: linux-leds, chenqiwu

From: chenqiwu <chenqiwu@xiaomi.com>

Use devm_platform_ioremap_resource_byname() instead of calling
platform_get_resource_byname() and devm_ioremap_resource() separately.

Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
---
 drivers/leds/leds-cobalt-qube.c | 12 +++---------
 drivers/leds/leds-cobalt-raq.c  | 12 ++++--------
 2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/leds/leds-cobalt-qube.c b/drivers/leds/leds-cobalt-qube.c
index ef22e1e..76af9d8 100644
--- a/drivers/leds/leds-cobalt-qube.c
+++ b/drivers/leds/leds-cobalt-qube.c
@@ -36,15 +36,9 @@ static void qube_front_led_set(struct led_classdev *led_cdev,
 
 static int cobalt_qube_led_probe(struct platform_device *pdev)
 {
-	struct resource *res;
-
-	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);
diff --git a/drivers/leds/leds-cobalt-raq.c b/drivers/leds/leds-cobalt-raq.c
index 045c239..8b1317d 100644
--- a/drivers/leds/leds-cobalt-raq.c
+++ b/drivers/leds/leds-cobalt-raq.c
@@ -65,16 +65,11 @@ static void raq_power_off_led_set(struct led_classdev *led_cdev,
 
 static int cobalt_raq_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);
 
 	retval = led_classdev_register(&pdev->dev, &raq_power_off_led);
 	if (retval)
@@ -90,6 +85,7 @@ static int cobalt_raq_led_probe(struct platform_device *pdev)
 	led_classdev_unregister(&raq_power_off_led);
 
 err_null:
+	devm_ioremap_release(&pdev->dev, led_port);
 	led_port = NULL;
 
 	return retval;
-- 
1.9.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-14 15:48 [PATCH] leds: use devm_platform_ioremap_resource_byname() qiwuchen55

Linux-LEDs Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-leds/0 linux-leds/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-leds linux-leds/ https://lore.kernel.org/linux-leds \
		linux-leds@vger.kernel.org
	public-inbox-index linux-leds

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-leds


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git