lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 18 Sep 2020 00:33:24 +0200
From:   Marek Behún <marek.behun@....cz>
To:     linux-leds@...r.kernel.org
Cc:     Pavel Machek <pavel@....cz>, Dan Murphy <dmurphy@...com>,
        Ondřej Jirman <megous@...ous.com>,
        linux-kernel@...r.kernel.org, Rob Herring <robh+dt@...nel.org>,
        devicetree@...r.kernel.org,
        Marek Behún <marek.behun@....cz>,
        Simon Guinot <simon.guinot@...uanux.org>,
        Simon Guinot <sguinot@...ie.com>,
        Vincent Donnefort <vdonnefort@...il.com>,
        Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>,
        Linus Walleij <linus.walleij@...aro.org>
Subject: [PATCH leds v2 36/50] leds: ns2: use devres LED registering function

By using devres version of LED registering function we can remove the
.remove method from this driver. The probe method also gets simpler.

Signed-off-by: Marek Behún <marek.behun@....cz>
Cc: Simon Guinot <simon.guinot@...uanux.org>
Cc: Simon Guinot <sguinot@...ie.com>
Cc: Vincent Donnefort <vdonnefort@...il.com>
Cc: Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>
Cc: Linus Walleij <linus.walleij@...aro.org>
---
 drivers/leds/leds-ns2.c | 30 ++----------------------------
 1 file changed, 2 insertions(+), 28 deletions(-)

diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c
index 22d38c83b6dca..1a7ef66464b5d 100644
--- a/drivers/leds/leds-ns2.c
+++ b/drivers/leds/leds-ns2.c
@@ -227,16 +227,7 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat,
 	led_dat->cdev.brightness =
 		(mode == NS_V2_LED_OFF) ? LED_OFF : LED_FULL;
 
-	ret = led_classdev_register(&pdev->dev, &led_dat->cdev);
-	if (ret < 0)
-		return ret;
-
-	return 0;
-}
-
-static void delete_ns2_led(struct ns2_led_data *led_dat)
-{
-	led_classdev_unregister(&led_dat->cdev);
+	return devm_led_classdev_register(&pdev->dev, &led_dat->cdev);
 }
 
 #ifdef CONFIG_OF_GPIO
@@ -380,11 +371,8 @@ static int ns2_led_probe(struct platform_device *pdev)
 	for (i = 0; i < priv->num_leds; i++) {
 		ret = create_ns2_led(pdev, &priv->leds_data[i],
 				     &pdata->leds[i]);
-		if (ret < 0) {
-			for (i = i - 1; i >= 0; i--)
-				delete_ns2_led(&priv->leds_data[i]);
+		if (ret < 0)
 			return ret;
-		}
 	}
 
 	platform_set_drvdata(pdev, priv);
@@ -392,22 +380,8 @@ static int ns2_led_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int ns2_led_remove(struct platform_device *pdev)
-{
-	int i;
-	struct ns2_led_priv *priv;
-
-	priv = platform_get_drvdata(pdev);
-
-	for (i = 0; i < priv->num_leds; i++)
-		delete_ns2_led(&priv->leds_data[i]);
-
-	return 0;
-}
-
 static struct platform_driver ns2_led_driver = {
 	.probe		= ns2_led_probe,
-	.remove		= ns2_led_remove,
 	.driver		= {
 		.name		= "leds-ns2",
 		.of_match_table	= of_match_ptr(of_ns2_leds_match),
-- 
2.26.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ