From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Riku Voipio <riku.voipio@iki.fi>,
Richard Purdie <rpurdie@rpsys.net>,
Andrew Morton <akpm@linux-foundation.org>,
Dmitry Torokhov <dtor@mail.ru>
Subject: [PATCH] leds: leds-pca9532 cleanups
Date: Thu, 16 Dec 2010 17:05:53 +0800 [thread overview]
Message-ID: <1292490353.9368.2.camel@mola> (raw)
>From 6244111ba78a6768ded3fedf8967b6bc891fa757 Mon Sep 17 00:00:00 2001
From: Axel Lin <axel.lin@gmail.com>
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@gmail.com>
---
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
next reply other threads:[~2010-12-16 9:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-16 9:05 Axel Lin [this message]
2010-12-16 17:37 ` [PATCH] leds: leds-pca9532 cleanups Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1292490353.9368.2.camel@mola \
--to=axel.lin@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dtor@mail.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=riku.voipio@iki.fi \
--cc=rpurdie@rpsys.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox