mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] leds: leds-pca9532 cleanups
@ 2010-12-20  1:49 Axel Lin
  2010-12-20 17:22 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2010-12-20  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Riku Voipio, Richard Purdie, Andrew Morton, Dmitry Torokhov

This patch includes below fixes:
1. Remove unneeded input_free_device() after input_unregister_device().
2. Add pca9532_destroy_devices() function for destroy devices.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
Changes for v2:
Base on Dmitry's comments to add pca9532_destroy_devices() for destroy devices.

 drivers/leds/leds-pca9532.c |   66 ++++++++++++++++++------------------------
 1 files changed, 28 insertions(+), 38 deletions(-)

diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c
index 43d0875..afac338 100644
--- a/drivers/leds/leds-pca9532.c
+++ b/drivers/leds/leds-pca9532.c
@@ -200,6 +200,32 @@ static void pca9532_led_work(struct work_struct *work)
 	pca9532_setled(led);
 }
 
+static void pca9532_destroy_devices(struct pca9532_data *data, int n_devs)
+{
+	int i = n_devs;
+
+	if (!data)
+		return;
+
+	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;
+		}
+	}
+}
+
 static int pca9532_configure(struct i2c_client *client,
 	struct pca9532_data *data, struct pca9532_platform_data *pdata)
 {
@@ -274,25 +300,7 @@ 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;
-			}
-
+	pca9532_destroy_devices(data, i);
 	return err;
 }
 
@@ -329,25 +337,7 @@ static int pca9532_probe(struct i2c_client *client,
 static int pca9532_remove(struct i2c_client *client)
 {
 	struct pca9532_data *data = i2c_get_clientdata(client);
-	int i;
-	for (i = 0; i < 16; 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;
-		}
-
+	pca9532_destroy_devices(data, 16);
 	kfree(data);
 	return 0;
 }
-- 
1.7.2




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

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

On Mon, Dec 20, 2010 at 09:49:37AM +0800, Axel Lin wrote:
> This patch includes below fixes:
> 1. Remove unneeded input_free_device() after input_unregister_device().
> 2. Add pca9532_destroy_devices() function for destroy devices.
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
> Changes for v2:
> Base on Dmitry's comments to add pca9532_destroy_devices() for destroy devices.
> 

Looks good, thank you for making changes.

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

-- 
Dmitry

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-20  1:49 [PATCH v2] leds: leds-pca9532 cleanups Axel Lin
2010-12-20 17:22 ` Dmitry Torokhov

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

all inboxes | Powered by JetHome®