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:	Sat, 23 Aug 2008 22:36:06 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Constantin Baranov <const@...st.mimas.ru>
Cc:	linux-kernel@...r.kernel.org, rpurdie@...ys.net
Subject: Re: [PATCH 2.6.27-rc3] led: driver for LEDs on PCEngines ALIX.2 and
 ALIX.3 boards

On Sat, 23 Aug 2008 22:11:56 +0500 Constantin Baranov <const@...st.mimas.ru> wrote:

> > For example, this?
> > 
> > static int __init alix_led_probe(struct platform_device *pdev)
> > {
> > 	int i;
> > 	int ret;
> > 
> > 	for (i = 0; i < ARRAY_SIZE(alix_leds); i++) {
> > 		ret = led_classdev_register(&pdev->dev, &alix_leds[i].cdev);
> > 		if (ret < 0)
> > 			goto fail;
> > 	}
> > 	return 0;
> > 
> > fail:
> > 	while (--i >= 0)
> > 		led_classdev_unregister(&alix_leds[i].cdev);
> > 	return ret;
> > }
> > 
> > (note there's no longer a need for a fake initalisation of `ret')
> > 
> >> Note that probe routine originates from leds-ams-delta.c.
> > 
> > That's what you get for copying stuff :(
> 
> Well, this variant looks better and correct and still works.
> Should I post again patch or fix-patch?

I already queued that as an incremental:

--- a/drivers/leds/leds-alix.c~led-driver-for-leds-on-pcengines-alix2-and-alix3-boards-fix
+++ a/drivers/leds/leds-alix.c
@@ -4,7 +4,7 @@
  * Copyright (C) 2008 Constantin Baranov <const@...su.ru>
  */
 
-#include <asm/io.h>
+#include <linux/io.h>
 #include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/leds.h>
@@ -22,6 +22,7 @@ static void alix_led_set(struct led_clas
 {
 	struct alix_led *led_dev =
 		container_of(led_cdev, struct alix_led, cdev);
+
 	if (brightness)
 		outl(led_dev->on_value, led_dev->port);
 	else
@@ -63,6 +64,7 @@ static struct alix_led alix_leds[] = {
 static int alix_led_suspend(struct platform_device *dev, pm_message_t state)
 {
 	int i;
+
 	for (i = 0; i < ARRAY_SIZE(alix_leds); i++)
 		led_classdev_suspend(&alix_leds[i].cdev);
 	return 0;
@@ -71,6 +73,7 @@ static int alix_led_suspend(struct platf
 static int alix_led_resume(struct platform_device *dev)
 {
 	int i;
+
 	for (i = 0; i < ARRAY_SIZE(alix_leds); i++)
 		led_classdev_resume(&alix_leds[i].cdev);
 	return 0;
@@ -86,22 +89,25 @@ static int alix_led_resume(struct platfo
 static int __init alix_led_probe(struct platform_device *pdev)
 {
 	int i;
-	int ret = 0;
+	int ret;
 
-	for (i = 0; i < ARRAY_SIZE(alix_leds) && ret >= 0; i++)
+	for (i = 0; i < ARRAY_SIZE(alix_leds); i++) {
 		ret = led_classdev_register(&pdev->dev, &alix_leds[i].cdev);
-
-	if (ret < 0) {
-		for (i = i - 2; i >= 0; i--)
-			led_classdev_unregister(&alix_leds[i].cdev);
+		if (ret < 0)
+			goto fail;
 	}
+	return 0;
 
+fail:
+	while (--i >= 0)
+		led_classdev_unregister(&alix_leds[i].cdev);
 	return ret;
 }
 
 static int alix_led_remove(struct platform_device *pdev)
 {
 	int i;
+
 	for (i = 0; i < ARRAY_SIZE(alix_leds); i++)
 		led_classdev_unregister(&alix_leds[i].cdev);
 	return 0;
@@ -122,6 +128,7 @@ static struct platform_device *pdev;
 static int __init alix_led_init(void)
 {
 	int ret;
+
 	pdev = platform_device_register_simple(KBUILD_MODNAME, -1, NULL, 0);
 	if (!IS_ERR(pdev)) {
 		ret = platform_driver_probe(&alix_led_driver, alix_led_probe);
_

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ