leds: leds-pca9532 cleanups
Subsystems (2)
PATCH 1/1 leds: leds-pca9532 cleanups
Quoted 1 line
From
6244111ba78a6768ded3fedf8967b6bc891fa757Mon Sep 17 00:00:00 2001
From: Axel Lin <[email protected]>
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.
--- drivers/leds/leds-pca9532.c | 34 ++++++++++++++++------------------ 1 files changed, 16 insertions(+), 18 deletions(-)
drivers/leds/leds-pca9532.c +16 -18
@@ -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 ; }
Signature · 1 line
1.7.2
Quoted 10 lines · Axel Lin
Quoted 1 line
From
6244111ba78a6768ded3fedf8967b6bc891fa757Mon Sep 17 00:00:00 2001From: Axel Lin <[email protected]>
Date: Thu, 16 Dec 2010 15:41:55 +0800
Subject: [PATCH] leds: leds-pca9532 cleanupsThis patch includes below fixes:
1. Remove unneededinput_free_device()afterinput_unregister_device().
2. Use "while (--i >= 0)" instead of "if (i > 0) for (i = i - 1; i >= 0; i--)" for reclaim resources inpca9532_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:
Thanks.
Signature · 1 line
Dmitry