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]
Message-ID: <20080128101551.7cbc7af5@dhcp-252-066.norway.atmel.com>
Date:	Mon, 28 Jan 2008 10:15:51 +0100
From:	Haavard Skinnemoen <hskinnemoen@...el.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	David Brownell <david-b@...bell.net>,
	Andrew Victor <linux@...im.org.za>,
	Nicolas Ferre <nicolas.ferre@...el.com>,
	Patrice Vilchez <patrice.vilchez@....atmel.com>,
	Richard Purdie <rpurdie@...ys.net>,
	linux-kernel@...r.kernel.org, kernel@...32linux.org,
	David Brownell <dbrownell@...rs.sourceforge.net>
Subject: Re: [PATCH -mm 2/2] PWM LED driver

On Sun, 27 Jan 2008 21:32:32 -0800
Andrew Morton <akpm@...ux-foundation.org> wrote:

> On Thu, 24 Jan 2008 15:33:45 +0100 Haavard Skinnemoen <hskinnemoen@...el.com> wrote:
> 
> > +	if (i > 0) {
> > +		for (i = i - 1; i >= 0; i--) {
> > +			led_classdev_unregister(&leds[i].cdev);
> > +			pwm_channel_free(&leds[i].pwmc);
> > +		}
> > +	}
> 
> Could be:
> 
> 	while (--i > 0) {
> 		led_classdev_unregister(&leds[i].cdev);
> 		pwm_channel_free(&leds[i].pwmc);
> 	}
> 
> or thereabouts.

Almost...we need to clean up for leds[0] too. Using a postfix decrement
should take care of that. How about the patch below?

Haavard

>From de5002ad71a1000f81817410f02a7d9fbd5d4ecd Mon Sep 17 00:00:00 2001
From: Haavard Skinnemoen <hskinnemoen@...el.com>
Date: Mon, 28 Jan 2008 10:14:14 +0100
Subject: [PATCH] PWM led driver: Simplify cleanup loop

Why use a for loop inside an if() when we can get away with a simple
while() loop?

Signed-off-by: Haavard Skinnemoen <hskinnemoen@...el.com>
---
 drivers/leds/leds-atmel-pwm.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/leds/leds-atmel-pwm.c b/drivers/leds/leds-atmel-pwm.c
index af61f55..187031c 100644
--- a/drivers/leds/leds-atmel-pwm.c
+++ b/drivers/leds/leds-atmel-pwm.c
@@ -100,11 +100,9 @@ static int __init pwmled_probe(struct platform_device *pdev)
 	return 0;
 
 err:
-	if (i > 0) {
-		for (i = i - 1; i >= 0; i--) {
-			led_classdev_unregister(&leds[i].cdev);
-			pwm_channel_free(&leds[i].pwmc);
-		}
+	while (i-- > 0) {
+		led_classdev_unregister(&leds[i].cdev);
+		pwm_channel_free(&leds[i].pwmc);
 	}
 	kfree(leds);
 
-- 
1.5.3.8

--
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