diff mbox

[linux,dev-4.10,v6,2/2] drivers/leds: pca955x count LED lines as GPIO

Message ID 20170729183638.17503-3-cbostic@linux.vnet.ibm.com
State Changes Requested, archived
Headers show

Commit Message

Christopher Bostic July 29, 2017, 6:36 p.m. UTC
In order for gpio-keys-polled driver to properly register pins
connected to the pca955x chip it is necessary to count 'LED' lines
as part of the total gpio count.  The assocated gpio_chip struct
for the pca955x is then set to all available I/O (LEDS and 'GPIO').
Failure to do so will cause any pin # > GPIO pin count to fail
gpio-keys-polled probe/registration as it falls outside the bounds
of what the gpio_chip struct indicates is available.

Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com>
---
 drivers/leds/leds-pca955x.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Brad Bishop July 30, 2017, 12:50 a.m. UTC | #1
> On Jul 29, 2017, at 2:36 PM, Christopher Bostic <cbostic@linux.vnet.ibm.com> wrote:
> 
> In order for gpio-keys-polled driver to properly register pins
> connected to the pca955x chip it is necessary to count 'LED' lines
> as part of the total gpio count.  The assocated gpio_chip struct
> for the pca955x is then set to all available I/O (LEDS and 'GPIO').
> Failure to do so will cause any pin # > GPIO pin count to fail
> gpio-keys-polled probe/registration as it falls outside the bounds
> of what the gpio_chip struct indicates is available.
> 
> Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com>
Tested-by: Brad Bishop <bradleyb@fuzziesquirrel.com>

> ---
> drivers/leds/leds-pca955x.c | 2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
> index 9216742..4fa58b9 100644
> --- a/drivers/leds/leds-pca955x.c
> +++ b/drivers/leds/leds-pca955x.c
> @@ -472,6 +472,8 @@ static int pca955x_probe(struct i2c_client *client,
> 			ngpios++;
> 			break;
> 		case PCA955X_TYPE_LED:
> +			ngpios++;
> +
> 			/*
> 			 * Platform data can specify LED names and
> 			 * default triggers
> -- 
> 1.8.2.2
Joel Stanley July 31, 2017, 2:16 a.m. UTC | #2
On Sun, Jul 30, 2017 at 10:20 AM, Brad Bishop
<bradleyb@fuzziesquirrel.com> wrote:
>
>> On Jul 29, 2017, at 2:36 PM, Christopher Bostic <cbostic@linux.vnet.ibm.com> wrote:
>>
>> In order for gpio-keys-polled driver to properly register pins
>> connected to the pca955x chip it is necessary to count 'LED' lines
>> as part of the total gpio count.  The assocated gpio_chip struct
>> for the pca955x is then set to all available I/O (LEDS and 'GPIO').
>> Failure to do so will cause any pin # > GPIO pin count to fail
>> gpio-keys-polled probe/registration as it falls outside the bounds
>> of what the gpio_chip struct indicates is available.
>>
>> Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com>
> Tested-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
>
>> ---
>> drivers/leds/leds-pca955x.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
>> index 9216742..4fa58b9 100644
>> --- a/drivers/leds/leds-pca955x.c
>> +++ b/drivers/leds/leds-pca955x.c
>> @@ -472,6 +472,8 @@ static int pca955x_probe(struct i2c_client *client,
>>                       ngpios++;
>>                       break;
>>               case PCA955X_TYPE_LED:
>> +                     ngpios++;
>> +

Hey Cedric, does this look like the correct fix?
Cédric Le Goater July 31, 2017, 7:26 a.m. UTC | #3
On 07/31/2017 04:16 AM, Joel Stanley wrote:
> On Sun, Jul 30, 2017 at 10:20 AM, Brad Bishop
> <bradleyb@fuzziesquirrel.com> wrote:
>>
>>> On Jul 29, 2017, at 2:36 PM, Christopher Bostic <cbostic@linux.vnet.ibm.com> wrote:
>>>
>>> In order for gpio-keys-polled driver to properly register pins
>>> connected to the pca955x chip it is necessary to count 'LED' lines
>>> as part of the total gpio count.  The assocated gpio_chip struct
>>> for the pca955x is then set to all available I/O (LEDS and 'GPIO').
>>> Failure to do so will cause any pin # > GPIO pin count to fail
>>> gpio-keys-polled probe/registration as it falls outside the bounds
>>> of what the gpio_chip struct indicates is available.
>>>
>>> Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com>
>> Tested-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
>>
>>> ---
>>> drivers/leds/leds-pca955x.c | 2 ++
>>> 1 file changed, 2 insertions(+)
>>>
>>> diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
>>> index 9216742..4fa58b9 100644
>>> --- a/drivers/leds/leds-pca955x.c
>>> +++ b/drivers/leds/leds-pca955x.c
>>> @@ -472,6 +472,8 @@ static int pca955x_probe(struct i2c_client *client,
>>>                       ngpios++;
>>>                       break;
>>>               case PCA955X_TYPE_LED:
>>> +                     ngpios++;
>>> +
> 
> Hey Cedric, does this look like the correct fix?
> 

At first glance, I would say no. I will take a look.

C.
diff mbox

Patch

diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
index 9216742..4fa58b9 100644
--- a/drivers/leds/leds-pca955x.c
+++ b/drivers/leds/leds-pca955x.c
@@ -472,6 +472,8 @@  static int pca955x_probe(struct i2c_client *client,
 			ngpios++;
 			break;
 		case PCA955X_TYPE_LED:
+			ngpios++;
+
 			/*
 			 * Platform data can specify LED names and
 			 * default triggers