From: Adam Lee <adam.lee@canonical.com>
To: linux-kernel@vger.kernel.org
Cc: platform-driver-x86@vger.kernel.org,
ibm-acpi-devel@lists.sourceforge.net,
Matthew Garrett <matthew.garrett@nebula.com>,
Henrique de Moraes Holschuh <ibm-acpi@hmh.eng.br>,
Alex Hung <alex.hung@canonical.com>, Bjorn Mork <bjorn@mork.no>,
Amos Kong <kongjianjun@gmail.com>
Subject: [PATCH 1/3 v3] thinkpad_acpi: return -NODEV while operating uninitialized LEDs
Date: Sat, 8 Jun 2013 16:51:15 +0800 [thread overview]
Message-ID: <1370681475-6601-1-git-send-email-adam.lee@canonical.com> (raw)
In-Reply-To: <1370593209-21358-1-git-send-email-adam.lee@canonical.com>
Not all 0-15 LEDs are available for all models, sometimes it's even not
safe. This patch return -NODEV while operating uninitialized LEDs.
Signed-off-by: Adam Lee <adam.lee@canonical.com>
---
drivers/platform/x86/thinkpad_acpi.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 54d31c0..455384b 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -369,7 +369,7 @@ struct tpacpi_led_classdev {
struct led_classdev led_classdev;
struct work_struct work;
enum led_status_t new_state;
- unsigned int led;
+ int led;
};
/* brightness level capabilities */
@@ -5344,6 +5344,8 @@ static int __init led_init(struct ibm_init_struct *iibm)
ARRAY_SIZE(led_useful_qtable));
for (i = 0; i < TPACPI_LED_NUMLEDS; i++) {
+ tpacpi_leds[i].led = -1;
+
if (!tpacpi_is_led_restricted(i) &&
test_bit(i, &useful_leds)) {
rc = tpacpi_init_led(i);
@@ -5401,9 +5403,13 @@ static int led_write(char *buf)
return -ENODEV;
while ((cmd = next_cmd(&buf))) {
- if (sscanf(cmd, "%d", &led) != 1 || led < 0 || led > 15)
+ if (sscanf(cmd, "%d", &led) != 1)
return -EINVAL;
+ if (led < 0 || led > (TPACPI_LED_NUMLEDS - 1) ||
+ tpacpi_leds[led].led < 0)
+ return -ENODEV;
+
if (strstr(cmd, "off")) {
s = TPACPI_LED_OFF;
} else if (strstr(cmd, "on")) {
--
1.7.10.4
next prev parent reply other threads:[~2013-06-08 8:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-07 8:20 [PATCH 0/3] thinkpad_acpi: avoid ACPI Warning while operating non-exist LEDs Adam Lee
2013-06-07 8:20 ` [PATCH 1/3] thinkpad_acpi: return -NODEV while operating uninitialized LEDs Adam Lee
2013-06-07 8:53 ` Bjørn Mork
2013-06-07 8:59 ` Adam Lee
2013-06-18 0:12 ` Henrique de Moraes Holschuh
2013-06-18 0:18 ` Henrique de Moraes Holschuh
2013-06-07 8:20 ` [PATCH 2/3] thinkpad_acpi: add the ability setting TPACPI_LED_NONE by quirk Adam Lee
2013-06-18 0:19 ` Henrique de Moraes Holschuh
2013-06-07 8:20 ` [PATCH 3/3] thinkpad_acpi: add LED quirks of models which don't have EC controllable LEDs Adam Lee
2013-06-07 13:22 ` Matthew Garrett
2013-06-07 15:06 ` Adam Lee
2013-06-07 20:16 ` Henrique de Moraes Holschuh
2013-06-08 9:04 ` Adam Lee
2013-06-18 0:20 ` Henrique de Moraes Holschuh
2013-06-07 9:05 ` [PATCH v2] thinkpad_acpi: return -NODEV while operating uninitialized LEDs Adam Lee
2013-06-08 2:19 ` Amos Kong
2013-06-08 8:51 ` Adam Lee [this message]
2013-06-18 0:17 ` [PATCH 1/3 v3] " Henrique de Moraes Holschuh
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=1370681475-6601-1-git-send-email-adam.lee@canonical.com \
--to=adam.lee@canonical.com \
--cc=alex.hung@canonical.com \
--cc=bjorn@mork.no \
--cc=ibm-acpi-devel@lists.sourceforge.net \
--cc=ibm-acpi@hmh.eng.br \
--cc=kongjianjun@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.garrett@nebula.com \
--cc=platform-driver-x86@vger.kernel.org \
/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
all inboxes | Powered by JetHome®