[PATCH] leds: leds-pca9532 cleanups

From: Axel Lin
Date: Thu Dec 16 2010 - 04:06:16 EST


>From 6244111ba78a6768ded3fedf8967b6bc891fa757 Mon Sep 17 00:00:00 2001
From: Axel Lin <axel.lin@xxxxxxxxx>
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@xxxxxxxxx>
---
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



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