* [PATCH] gpio: mcp23s08: Bug fix of SPI device tree registration.
@ 2014-04-17 1:00 Michael Welling
2014-04-23 12:01 ` Linus Walleij
2014-04-24 13:04 ` Linus Walleij
0 siblings, 2 replies; 5+ messages in thread
From: Michael Welling @ 2014-04-17 1:00 UTC (permalink / raw)
To: Linus Walleij, Alexandre Courbot, linux-gpio; +Cc: Michael Welling
The chips variable needs to be incremented for each chip that is found in the
spi_present_mask when register via device tree. Without this and the checking
a negative index is passed to the data->chip array in a subsequent loop.
Signed-off-by: Michael Welling <mwelling@ieee.org>
---
drivers/gpio/gpio-mcp23s08.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
index 99a6831..3d53fd6 100644
--- a/drivers/gpio/gpio-mcp23s08.c
+++ b/drivers/gpio/gpio-mcp23s08.c
@@ -894,9 +894,11 @@ static int mcp23s08_probe(struct spi_device *spi)
dev_err(&spi->dev, "invalid spi-present-mask\n");
return -ENODEV;
}
-
- for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++)
+ for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) {
+ if ((spi_present_mask & (1 << addr)))
+ chips++;
pullups[addr] = 0;
+ }
} else {
type = spi_get_device_id(spi)->driver_data;
pdata = dev_get_platdata(&spi->dev);
@@ -919,12 +921,12 @@ static int mcp23s08_probe(struct spi_device *spi)
pullups[addr] = pdata->chip[addr].pullups;
}
- if (!chips)
- return -ENODEV;
-
base = pdata->base;
}
+ if (!chips)
+ return -ENODEV;
+
data = kzalloc(sizeof(*data) + chips * sizeof(struct mcp23s08),
GFP_KERNEL);
if (!data)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] gpio: mcp23s08: Bug fix of SPI device tree registration.
2014-04-17 1:00 [PATCH] gpio: mcp23s08: Bug fix of SPI device tree registration Michael Welling
@ 2014-04-23 12:01 ` Linus Walleij
2014-04-23 13:13 ` Peter Korsgaard
2014-04-24 13:04 ` Linus Walleij
1 sibling, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2014-04-23 12:01 UTC (permalink / raw)
To: Michael Welling, Daniel M. Weeks, Lars Poeschel, Peter Korsgaard
Cc: Alexandre Courbot, linux-gpio@vger.kernel.org
Daniel, Lars, Peter: can either of you have a look at this patch
and ACK/NACK it?
Yours,
Linus Walleij
On Thu, Apr 17, 2014 at 3:00 AM, Michael Welling <mwelling@ieee.org> wrote:
> The chips variable needs to be incremented for each chip that is found in the
> spi_present_mask when register via device tree. Without this and the checking
> a negative index is passed to the data->chip array in a subsequent loop.
>
> Signed-off-by: Michael Welling <mwelling@ieee.org>
> ---
> drivers/gpio/gpio-mcp23s08.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
> index 99a6831..3d53fd6 100644
> --- a/drivers/gpio/gpio-mcp23s08.c
> +++ b/drivers/gpio/gpio-mcp23s08.c
> @@ -894,9 +894,11 @@ static int mcp23s08_probe(struct spi_device *spi)
> dev_err(&spi->dev, "invalid spi-present-mask\n");
> return -ENODEV;
> }
> -
> - for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++)
> + for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) {
> + if ((spi_present_mask & (1 << addr)))
> + chips++;
> pullups[addr] = 0;
> + }
> } else {
> type = spi_get_device_id(spi)->driver_data;
> pdata = dev_get_platdata(&spi->dev);
> @@ -919,12 +921,12 @@ static int mcp23s08_probe(struct spi_device *spi)
> pullups[addr] = pdata->chip[addr].pullups;
> }
>
> - if (!chips)
> - return -ENODEV;
> -
> base = pdata->base;
> }
>
> + if (!chips)
> + return -ENODEV;
> +
> data = kzalloc(sizeof(*data) + chips * sizeof(struct mcp23s08),
> GFP_KERNEL);
> if (!data)
> --
> 1.7.9.5
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpio: mcp23s08: Bug fix of SPI device tree registration.
2014-04-23 12:01 ` Linus Walleij
@ 2014-04-23 13:13 ` Peter Korsgaard
2014-04-23 23:12 ` Michael Welling
0 siblings, 1 reply; 5+ messages in thread
From: Peter Korsgaard @ 2014-04-23 13:13 UTC (permalink / raw)
To: Linus Walleij
Cc: Michael Welling, Daniel M. Weeks, Lars Poeschel, Peter Korsgaard,
Alexandre Courbot, linux-gpio@vger.kernel.org
>>>>> "Linus" == Linus Walleij <linus.walleij@linaro.org> writes:
> Daniel, Lars, Peter: can either of you have a look at this patch
> and ACK/NACK it?
Sorry, it seems like I wasn't CC'ed on this patch (or the one adding the
DT bindings). The patch looks good to me:
Acked-by: Peter Korsgaard <peter@korsgaard.com>
> On Thu, Apr 17, 2014 at 3:00 AM, Michael Welling <mwelling@ieee.org> wrote:
>> The chips variable needs to be incremented for each chip that is found in the
>> spi_present_mask when register via device tree. Without this and the checking
s/register/registrering/
>> a negative index is passed to the data->chip array in a subsequent loop.
>>
>> Signed-off-by: Michael Welling <mwelling@ieee.org>
>> ---
>> drivers/gpio/gpio-mcp23s08.c | 12 +++++++-----
>> 1 file changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
>> index 99a6831..3d53fd6 100644
>> --- a/drivers/gpio/gpio-mcp23s08.c
>> +++ b/drivers/gpio/gpio-mcp23s08.c
>> @@ -894,9 +894,11 @@ static int mcp23s08_probe(struct spi_device *spi)
>> dev_err(&spi->dev, "invalid spi-present-mask\n");
>> return -ENODEV;
>> }
>> -
>> - for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++)
>> + for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) {
>> + if ((spi_present_mask & (1 << addr)))
>> + chips++;
>> pullups[addr] = 0;
>> + }
>> } else {
>> type = spi_get_device_id(spi)->driver_data;
>> pdata = dev_get_platdata(&spi->dev);
>> @@ -919,12 +921,12 @@ static int mcp23s08_probe(struct spi_device *spi)
>> pullups[addr] = pdata->chip[addr].pullups;
>> }
>>
>> - if (!chips)
>> - return -ENODEV;
>> -
>> base = pdata->base;
>> }
>>
>> + if (!chips)
>> + return -ENODEV;
>> +
>> data = kzalloc(sizeof(*data) + chips * sizeof(struct mcp23s08),
>> GFP_KERNEL);
>> if (!data)
>> --
>> 1.7.9.5
>>
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpio: mcp23s08: Bug fix of SPI device tree registration.
2014-04-23 13:13 ` Peter Korsgaard
@ 2014-04-23 23:12 ` Michael Welling
0 siblings, 0 replies; 5+ messages in thread
From: Michael Welling @ 2014-04-23 23:12 UTC (permalink / raw)
To: Peter Korsgaard
Cc: Linus Walleij, Daniel M. Weeks, Lars Poeschel, Peter Korsgaard,
Alexandre Courbot, linux-gpio@vger.kernel.org
On Wed, Apr 23, 2014 at 03:13:32PM +0200, Peter Korsgaard wrote:
> >>>>> "Linus" == Linus Walleij <linus.walleij@linaro.org> writes:
>
> > Daniel, Lars, Peter: can either of you have a look at this patch
> > and ACK/NACK it?
>
> Sorry, it seems like I wasn't CC'ed on this patch (or the one adding the
> DT bindings). The patch looks good to me:
>
> Acked-by: Peter Korsgaard <peter@korsgaard.com>
>
The patched driver was tested and working on actual hardware.
>
> > On Thu, Apr 17, 2014 at 3:00 AM, Michael Welling <mwelling@ieee.org> wrote:
> >> The chips variable needs to be incremented for each chip that is found in the
> >> spi_present_mask when register via device tree. Without this and the checking
>
> s/register/registrering/
s/registrering/registering/
I should really proof read my commit logs.
>
>
> >> a negative index is passed to the data->chip array in a subsequent loop.
> >>
> >> Signed-off-by: Michael Welling <mwelling@ieee.org>
> >> ---
> >> drivers/gpio/gpio-mcp23s08.c | 12 +++++++-----
> >> 1 file changed, 7 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
> >> index 99a6831..3d53fd6 100644
> >> --- a/drivers/gpio/gpio-mcp23s08.c
> >> +++ b/drivers/gpio/gpio-mcp23s08.c
> >> @@ -894,9 +894,11 @@ static int mcp23s08_probe(struct spi_device *spi)
> >> dev_err(&spi->dev, "invalid spi-present-mask\n");
> >> return -ENODEV;
> >> }
> >> -
> >> - for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++)
> >> + for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) {
> >> + if ((spi_present_mask & (1 << addr)))
> >> + chips++;
> >> pullups[addr] = 0;
> >> + }
> >> } else {
> >> type = spi_get_device_id(spi)->driver_data;
> >> pdata = dev_get_platdata(&spi->dev);
> >> @@ -919,12 +921,12 @@ static int mcp23s08_probe(struct spi_device *spi)
> >> pullups[addr] = pdata->chip[addr].pullups;
> >> }
> >>
> >> - if (!chips)
> >> - return -ENODEV;
> >> -
> >> base = pdata->base;
> >> }
> >>
> >> + if (!chips)
> >> + return -ENODEV;
> >> +
> >> data = kzalloc(sizeof(*data) + chips * sizeof(struct mcp23s08),
> >> GFP_KERNEL);
> >> if (!data)
> >> --
> >> 1.7.9.5
> >>
>
>
> --
> Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpio: mcp23s08: Bug fix of SPI device tree registration.
2014-04-17 1:00 [PATCH] gpio: mcp23s08: Bug fix of SPI device tree registration Michael Welling
2014-04-23 12:01 ` Linus Walleij
@ 2014-04-24 13:04 ` Linus Walleij
1 sibling, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2014-04-24 13:04 UTC (permalink / raw)
To: Michael Welling; +Cc: Alexandre Courbot, linux-gpio@vger.kernel.org
On Thu, Apr 17, 2014 at 3:00 AM, Michael Welling <mwelling@ieee.org> wrote:
> The chips variable needs to be incremented for each chip that is found in the
> spi_present_mask when register via device tree. Without this and the checking
> a negative index is passed to the data->chip array in a subsequent loop.
>
> Signed-off-by: Michael Welling <mwelling@ieee.org>
Patch applied for fixes and also tagged for stable.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-04-24 13:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-17 1:00 [PATCH] gpio: mcp23s08: Bug fix of SPI device tree registration Michael Welling
2014-04-23 12:01 ` Linus Walleij
2014-04-23 13:13 ` Peter Korsgaard
2014-04-23 23:12 ` Michael Welling
2014-04-24 13:04 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).