diff options
author | Axel Lin <axel.lin@gmail.com> | 2011-01-12 19:59:15 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-13 11:03:05 -0500 |
commit | 125c7135251de3aea1429968aea9bdfcb6535fc7 (patch) | |
tree | e7f610a5aad18ed24887c0d1a0e71b94eaf603c7 | |
parent | 2260209c4973e3eeb1e48abaa9e639373a0d4fb7 (diff) |
leds: leds-pca9532 cleanups
- Remove unneeded input_free_device() after input_unregister_device().
- Add pca9532_destroy_devices() function for destroy devices.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Dmitry Torokhov <dtor@mail.ru>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | 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 43d08756d823..afac338d5025 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) | |||
200 | pca9532_setled(led); | 200 | pca9532_setled(led); |
201 | } | 201 | } |
202 | 202 | ||
203 | static void pca9532_destroy_devices(struct pca9532_data *data, int n_devs) | ||
204 | { | ||
205 | int i = n_devs; | ||
206 | |||
207 | if (!data) | ||
208 | return; | ||
209 | |||
210 | while (--i >= 0) { | ||
211 | switch (data->leds[i].type) { | ||
212 | case PCA9532_TYPE_NONE: | ||
213 | break; | ||
214 | case PCA9532_TYPE_LED: | ||
215 | led_classdev_unregister(&data->leds[i].ldev); | ||
216 | cancel_work_sync(&data->leds[i].work); | ||
217 | break; | ||
218 | case PCA9532_TYPE_N2100_BEEP: | ||
219 | if (data->idev != NULL) { | ||
220 | input_unregister_device(data->idev); | ||
221 | cancel_work_sync(&data->work); | ||
222 | data->idev = NULL; | ||
223 | } | ||
224 | break; | ||
225 | } | ||
226 | } | ||
227 | } | ||
228 | |||
203 | static int pca9532_configure(struct i2c_client *client, | 229 | static int pca9532_configure(struct i2c_client *client, |
204 | struct pca9532_data *data, struct pca9532_platform_data *pdata) | 230 | struct pca9532_data *data, struct pca9532_platform_data *pdata) |
205 | { | 231 | { |
@@ -274,25 +300,7 @@ static int pca9532_configure(struct i2c_client *client, | |||
274 | return 0; | 300 | return 0; |
275 | 301 | ||
276 | exit: | 302 | exit: |
277 | if (i > 0) | 303 | pca9532_destroy_devices(data, i); |
278 | for (i = i - 1; i >= 0; i--) | ||
279 | switch (data->leds[i].type) { | ||
280 | case PCA9532_TYPE_NONE: | ||
281 | break; | ||
282 | case PCA9532_TYPE_LED: | ||
283 | led_classdev_unregister(&data->leds[i].ldev); | ||
284 | cancel_work_sync(&data->leds[i].work); | ||
285 | break; | ||
286 | case PCA9532_TYPE_N2100_BEEP: | ||
287 | if (data->idev != NULL) { | ||
288 | input_unregister_device(data->idev); | ||
289 | input_free_device(data->idev); | ||
290 | cancel_work_sync(&data->work); | ||
291 | data->idev = NULL; | ||
292 | } | ||
293 | break; | ||
294 | } | ||
295 | |||
296 | return err; | 304 | return err; |
297 | } | 305 | } |
298 | 306 | ||
@@ -329,25 +337,7 @@ static int pca9532_probe(struct i2c_client *client, | |||
329 | static int pca9532_remove(struct i2c_client *client) | 337 | static int pca9532_remove(struct i2c_client *client) |
330 | { | 338 | { |
331 | struct pca9532_data *data = i2c_get_clientdata(client); | 339 | struct pca9532_data *data = i2c_get_clientdata(client); |
332 | int i; | 340 | pca9532_destroy_devices(data, 16); |
333 | for (i = 0; i < 16; i++) | ||
334 | switch (data->leds[i].type) { | ||
335 | case PCA9532_TYPE_NONE: | ||
336 | break; | ||
337 | case PCA9532_TYPE_LED: | ||
338 | led_classdev_unregister(&data->leds[i].ldev); | ||
339 | cancel_work_sync(&data->leds[i].work); | ||
340 | break; | ||
341 | case PCA9532_TYPE_N2100_BEEP: | ||
342 | if (data->idev != NULL) { | ||
343 | input_unregister_device(data->idev); | ||
344 | input_free_device(data->idev); | ||
345 | cancel_work_sync(&data->work); | ||
346 | data->idev = NULL; | ||
347 | } | ||
348 | break; | ||
349 | } | ||
350 | |||
351 | kfree(data); | 341 | kfree(data); |
352 | return 0; | 342 | return 0; |
353 | } | 343 | } |