From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751548AbbGWFkv (ORCPT ); Thu, 23 Jul 2015 01:40:51 -0400 Received: from cantor2.suse.de ([195.135.220.15]:59203 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750771AbbGWFkm (ORCPT ); Thu, 23 Jul 2015 01:40:42 -0400 Subject: Re: [PATCH] Input: LEDs - skip unnamed LEDs To: Dmitry Torokhov , Pavel Machek , Jiri Kosina References: <20150722220202.GG14875@dtor-ws> Cc: Samuel Thibault , =?UTF-8?Q?Pali_Roh=c3=a1r?= , linux-input@vger.kernel.org, rpurdie@rpsys.net, Greg Kroah-Hartman , linux-kernel@vger.kernel.org From: Vlastimil Babka X-Enigmail-Draft-Status: N1110 Message-ID: <55B07E57.9090505@suse.cz> Date: Thu, 23 Jul 2015 07:40:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: <20150722220202.GG14875@dtor-ws> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/23/2015 12:02 AM, Dmitry Torokhov wrote: > Devices may declare more LEDs than what is known to input-leds > (HID does this for some devices). Instead of showing ugly warnings > on connect and, even worse, oopsing on disconnect, let's simply > ignore LEDs that are not known to us. > > Reported-by: Vlastimil Babka > Signed-off-by: Dmitry Torokhov Thanks, I'll test it tomorrow, due to being elsewhere than the machine with the mouse today. > --- > drivers/input/input-leds.c | 16 ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) > > diff --git a/drivers/input/input-leds.c b/drivers/input/input-leds.c > index 074a65e..766bf26 100644 > --- a/drivers/input/input-leds.c > +++ b/drivers/input/input-leds.c > @@ -71,6 +71,18 @@ static void input_leds_event(struct input_handle *handle, unsigned int type, > { > } > > +static int input_leds_get_count(struct input_dev *dev) > +{ > + unsigned int led_code; > + int count = 0; > + > + for_each_set_bit(led_code, dev->ledbit, LED_CNT) > + if (input_led_info[led_code].name) > + count++; > + > + return count; > +} > + > static int input_leds_connect(struct input_handler *handler, > struct input_dev *dev, > const struct input_device_id *id) > @@ -81,7 +93,7 @@ static int input_leds_connect(struct input_handler *handler, > int led_no; > int error; > > - num_leds = bitmap_weight(dev->ledbit, LED_CNT); > + num_leds = input_leds_get_count(dev); > if (!num_leds) > return -ENXIO; > > @@ -112,7 +124,7 @@ static int input_leds_connect(struct input_handler *handler, > led->handle = &leds->handle; > led->code = led_code; > > - if (WARN_ON(!input_led_info[led_code].name)) > + if (!input_led_info[led_code].name) > continue; > > led->cdev.name = kasprintf(GFP_KERNEL, "%s::%s", >