public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] leds: leds-pca9532 cleanups
@ 2010-12-16  9:05 Axel Lin
  2010-12-16 17:37 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2010-12-16  9:05 UTC (permalink / raw)
  To: linux-kernel; +Cc: Riku Voipio, Richard Purdie, Andrew Morton, Dmitry Torokhov

>From 6244111ba78a6768ded3fedf8967b6bc891fa757 Mon Sep 17 00:00:00 2001
From: Axel Lin <axel.lin@gmail.com>
Date: Thu, 16 Dec 2010 15:41:55 +0800
Subject: [PATCH] leds: leds-pca9532 cleanups

This patch includes below fixes:
1. Remove unneeded input_free_device() after input_unregister_device().
2. Use "while (--i >= 0)" instead of "if (i > 0) for (i = i - 1; i >= 0; i--)"
   for reclaim resources in pca9532_configure() error path.
   I think this change improves readability.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/leds/leds-pca9532.c |   34 ++++++++++++++++------------------
 1 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c
index 43d0875..c298c65 100644
--- a/drivers/leds/leds-pca9532.c
+++ b/drivers/leds/leds-pca9532.c
@@ -274,24 +274,23 @@ static int pca9532_configure(struct i2c_client *client,
 	return 0;
 
 exit:
-	if (i > 0)
-		for (i = i - 1; i >= 0; i--)
-			switch (data->leds[i].type) {
-			case PCA9532_TYPE_NONE:
-				break;
-			case PCA9532_TYPE_LED:
-				led_classdev_unregister(&data->leds[i].ldev);
-				cancel_work_sync(&data->leds[i].work);
-				break;
-			case PCA9532_TYPE_N2100_BEEP:
-				if (data->idev != NULL) {
-					input_unregister_device(data->idev);
-					input_free_device(data->idev);
-					cancel_work_sync(&data->work);
-					data->idev = NULL;
-				}
-				break;
+	while (--i >= 0) {
+		switch (data->leds[i].type) {
+		case PCA9532_TYPE_NONE:
+			break;
+		case PCA9532_TYPE_LED:
+			led_classdev_unregister(&data->leds[i].ldev);
+			cancel_work_sync(&data->leds[i].work);
+			break;
+		case PCA9532_TYPE_N2100_BEEP:
+			if (data->idev != NULL) {
+				input_unregister_device(data->idev);
+				cancel_work_sync(&data->work);
+				data->idev = NULL;
 			}
+			break;
+		}
+	}
 
 	return err;
 }
@@ -341,7 +340,6 @@ static int pca9532_remove(struct i2c_client *client)
 		case PCA9532_TYPE_N2100_BEEP:
 			if (data->idev != NULL) {
 				input_unregister_device(data->idev);
-				input_free_device(data->idev);
 				cancel_work_sync(&data->work);
 				data->idev = NULL;
 			}
-- 
1.7.2




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] leds: leds-pca9532 cleanups
  2010-12-16  9:05 [PATCH] leds: leds-pca9532 cleanups Axel Lin
@ 2010-12-16 17:37 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2010-12-16 17:37 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Riku Voipio, Richard Purdie, Andrew Morton

On Thu, Dec 16, 2010 at 05:05:53PM +0800, Axel Lin wrote:
> >From 6244111ba78a6768ded3fedf8967b6bc891fa757 Mon Sep 17 00:00:00 2001
> From: Axel Lin <axel.lin@gmail.com>
> Date: Thu, 16 Dec 2010 15:41:55 +0800
> Subject: [PATCH] leds: leds-pca9532 cleanups
> 
> This patch includes below fixes:
> 1. Remove unneeded input_free_device() after input_unregister_device().
> 2. Use "while (--i >= 0)" instead of "if (i > 0) for (i = i - 1; i >= 0; i--)"
>    for reclaim resources in pca9532_configure() error path.
>    I think this change improves readability.

The whole chunk should be in a separate function, like

void pca9532_destroy_devices(struct pca9532_data *data, int n_devs);

That can be called from both pca9532_configure() and pca9532_remove().

For the input change:

	Acked-by: Dmitry Torokhov <dtor@mail.ru>

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-12-16 17:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-16  9:05 [PATCH] leds: leds-pca9532 cleanups Axel Lin
2010-12-16 17:37 ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox