Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753348Ab3FRASC (ORCPT ); Mon, 17 Jun 2013 20:18:02 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:37866 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751337Ab3FRASA (ORCPT ); Mon, 17 Jun 2013 20:18:00 -0400 X-Sasl-enc: yFyEBq2lBeZ7dFgiKXD09yJz3ppo33sOgXe2HRN/B7w9 1371514673 Date: Mon, 17 Jun 2013 21:17:50 -0300 From: Henrique de Moraes Holschuh To: Adam Lee Cc: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, ibm-acpi-devel@lists.sourceforge.net, Matthew Garrett , Henrique de Moraes Holschuh , Alex Hung , Bjorn Mork , Amos Kong Subject: Re: [PATCH 1/3 v3] thinkpad_acpi: return -NODEV while operating uninitialized LEDs Message-ID: <20130618001750.GB27654@khazad-dum.debian.net> References: <1370593209-21358-1-git-send-email-adam.lee@canonical.com> <1370681475-6601-1-git-send-email-adam.lee@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1370681475-6601-1-git-send-email-adam.lee@canonical.com> X-GPG-Fingerprint: 1024D/1CDB0FE3 5422 5C61 F6B7 06FB 7E04 3738 EE25 DE3F 1CDB 0FE3 User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2089 Lines: 60 On Sat, 08 Jun 2013, Adam Lee wrote: > 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 Acked-by: Henrique de Moraes Holschuh > --- > 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")) { -- "One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/