Commit 125c7135 authored by Axel Lin's avatar Axel Lin Committed by Linus Torvalds

leds: leds-pca9532 cleanups

- Remove unneeded input_free_device() after input_unregister_device().

- Add pca9532_destroy_devices() function for destroy devices.
Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Acked-by: default avatarDmitry Torokhov <dtor@mail.ru>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2260209c
...@@ -200,6 +200,32 @@ static void pca9532_led_work(struct work_struct *work) ...@@ -200,6 +200,32 @@ static void pca9532_led_work(struct work_struct *work)
pca9532_setled(led); 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, static int pca9532_configure(struct i2c_client *client,
struct pca9532_data *data, struct pca9532_platform_data *pdata) struct pca9532_data *data, struct pca9532_platform_data *pdata)
{ {
...@@ -274,25 +300,7 @@ static int pca9532_configure(struct i2c_client *client, ...@@ -274,25 +300,7 @@ static int pca9532_configure(struct i2c_client *client,
return 0; return 0;
exit: exit:
if (i > 0) pca9532_destroy_devices(data, i);
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;
}
return err; return err;
} }
...@@ -329,25 +337,7 @@ static int pca9532_probe(struct i2c_client *client, ...@@ -329,25 +337,7 @@ static int pca9532_probe(struct i2c_client *client,
static int pca9532_remove(struct i2c_client *client) static int pca9532_remove(struct i2c_client *client)
{ {
struct pca9532_data *data = i2c_get_clientdata(client); struct pca9532_data *data = i2c_get_clientdata(client);
int i; pca9532_destroy_devices(data, 16);
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;
}
kfree(data); kfree(data);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment