* [PATCH] gpio: mcp23s08: create default gpio base if neither device node nor platform data is defined
@ 2015-01-20 9:00 Sonic Zhang
2015-01-20 10:11 ` Alexandre Courbot
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Sonic Zhang @ 2015-01-20 9:00 UTC (permalink / raw)
To: linux-gpio, antonio, gnurou, linus.walleij, grant.likely, robh+dt
Cc: adi-buildroot-devel, Sonic Zhang
From: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
drivers/gpio/gpio-mcp23s08.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
index da9c316..eea5d7e 100644
--- a/drivers/gpio/gpio-mcp23s08.c
+++ b/drivers/gpio/gpio-mcp23s08.c
@@ -801,9 +801,11 @@ static int mcp230xx_probe(struct i2c_client *client,
client->irq = irq_of_parse_and_map(client->dev.of_node, 0);
} else {
pdata = dev_get_platdata(&client->dev);
- if (!pdata || !gpio_is_valid(pdata->base)) {
- dev_dbg(&client->dev, "invalid platform data\n");
- return -EINVAL;
+ if (!pdata) {
+ pdata = devm_kzalloc(&client->dev,
+ sizeof(struct mcp23s08_platform_data),
+ GFP_KERNEL);
+ pdata->base = -1;
}
}
@@ -924,10 +926,11 @@ static int mcp23s08_probe(struct spi_device *spi)
} else {
type = spi_get_device_id(spi)->driver_data;
pdata = dev_get_platdata(&spi->dev);
- if (!pdata || !gpio_is_valid(pdata->base)) {
- dev_dbg(&spi->dev,
- "invalid or missing platform data\n");
- return -EINVAL;
+ if (!pdata) {
+ pdata = devm_kzalloc(&spi->dev,
+ sizeof(struct mcp23s08_platform_data),
+ GFP_KERNEL);
+ pdata->base = -1;
}
for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] gpio: mcp23s08: create default gpio base if neither device node nor platform data is defined
2015-01-20 9:00 [PATCH] gpio: mcp23s08: create default gpio base if neither device node nor platform data is defined Sonic Zhang
@ 2015-01-20 10:11 ` Alexandre Courbot
2015-01-20 16:03 ` Antonio Fiol Bonnín
2015-01-21 16:53 ` Linus Walleij
2 siblings, 0 replies; 5+ messages in thread
From: Alexandre Courbot @ 2015-01-20 10:11 UTC (permalink / raw)
To: Sonic Zhang
Cc: linux-gpio@vger.kernel.org, Antonio Fiol Bonnín,
Linus Walleij, Grant Likely, Rob Herring, adi-buildroot-devel,
Sonic Zhang
On Tue, Jan 20, 2015 at 6:00 PM, Sonic Zhang <sonic.adi@gmail.com> wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Thanks!
Note: please always include a commit body even if the title is enough
to understand the patch.
Antonio, could you try this and give us your Tested-by if it succeeds?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpio: mcp23s08: create default gpio base if neither device node nor platform data is defined
2015-01-20 9:00 [PATCH] gpio: mcp23s08: create default gpio base if neither device node nor platform data is defined Sonic Zhang
2015-01-20 10:11 ` Alexandre Courbot
@ 2015-01-20 16:03 ` Antonio Fiol Bonnín
2015-01-21 16:53 ` Linus Walleij
2 siblings, 0 replies; 5+ messages in thread
From: Antonio Fiol Bonnín @ 2015-01-20 16:03 UTC (permalink / raw)
To: Sonic Zhang
Cc: linux-gpio@vger.kernel.org, Alexandre Courbot, Linus Walleij,
Grant Likely, Rob Herring, adi-buildroot-devel, Sonic Zhang
On Tue, Jan 20, 2015 at 10:00 AM, Sonic Zhang <sonic.adi@gmail.com> wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Tested-by: Antonio Fiol <antonio@fiol.es>
> ---
> drivers/gpio/gpio-mcp23s08.c | 17 ++++++++++-------
> 1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
> index da9c316..eea5d7e 100644
> --- a/drivers/gpio/gpio-mcp23s08.c
> +++ b/drivers/gpio/gpio-mcp23s08.c
> @@ -801,9 +801,11 @@ static int mcp230xx_probe(struct i2c_client *client,
> client->irq = irq_of_parse_and_map(client->dev.of_node, 0);
> } else {
> pdata = dev_get_platdata(&client->dev);
> - if (!pdata || !gpio_is_valid(pdata->base)) {
> - dev_dbg(&client->dev, "invalid platform data\n");
> - return -EINVAL;
> + if (!pdata) {
> + pdata = devm_kzalloc(&client->dev,
> + sizeof(struct mcp23s08_platform_data),
> + GFP_KERNEL);
> + pdata->base = -1;
> }
> }
>
> @@ -924,10 +926,11 @@ static int mcp23s08_probe(struct spi_device *spi)
> } else {
> type = spi_get_device_id(spi)->driver_data;
> pdata = dev_get_platdata(&spi->dev);
> - if (!pdata || !gpio_is_valid(pdata->base)) {
> - dev_dbg(&spi->dev,
> - "invalid or missing platform data\n");
> - return -EINVAL;
> + if (!pdata) {
> + pdata = devm_kzalloc(&spi->dev,
> + sizeof(struct mcp23s08_platform_data),
> + GFP_KERNEL);
> + pdata->base = -1;
> }
>
> for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) {
> --
> 1.7.9.5
>
Thank you Sonic for the patch, and Alexander for your patience,
understanding and guidance.
This patch is working in my scenario. It is assigning the same base as
it was on the version before the patch that broke the behavior in the
past.
If you wish me to test in other scenarios (e.g. creating a device tree
file, or using platform data), I'd appreciate pointers to learn the
basics, or some help preparing the kernel tree to build with the
needed definitions (if that's what needs to be done).
I am saying this because seeing the commit logs it appears that effort
is being put into the driver to work in scenarios that differ from
mine, and I definitely do not want to break them.
Kind regards,
--
Antonio
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpio: mcp23s08: create default gpio base if neither device node nor platform data is defined
2015-01-20 9:00 [PATCH] gpio: mcp23s08: create default gpio base if neither device node nor platform data is defined Sonic Zhang
2015-01-20 10:11 ` Alexandre Courbot
2015-01-20 16:03 ` Antonio Fiol Bonnín
@ 2015-01-21 16:53 ` Linus Walleij
2015-01-22 3:15 ` Alexandre Courbot
2 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2015-01-21 16:53 UTC (permalink / raw)
To: Sonic Zhang
Cc: linux-gpio@vger.kernel.org, antonio, Alexandre Courbot,
Grant Likely, Rob Herring, adi-buildroot-devel, Sonic Zhang
On Tue, Jan 20, 2015 at 10:00 AM, Sonic Zhang <sonic.adi@gmail.com> wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Patch applied for fixes with the ACK and Tested-by tags.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpio: mcp23s08: create default gpio base if neither device node nor platform data is defined
2015-01-21 16:53 ` Linus Walleij
@ 2015-01-22 3:15 ` Alexandre Courbot
0 siblings, 0 replies; 5+ messages in thread
From: Alexandre Courbot @ 2015-01-22 3:15 UTC (permalink / raw)
To: Linus Walleij
Cc: Sonic Zhang, linux-gpio@vger.kernel.org, Antonio Fiol Bonnín,
Grant Likely, Rob Herring, adi-buildroot-devel, Sonic Zhang
On Thu, Jan 22, 2015 at 1:53 AM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Tue, Jan 20, 2015 at 10:00 AM, Sonic Zhang <sonic.adi@gmail.com> wrote:
>
>> From: Sonic Zhang <sonic.zhang@analog.com>
>>
>> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
>
> Patch applied for fixes with the ACK and Tested-by tags.
This was a very nice example of how bug reports should go: a clear and
detailed initial report, quick answer from involved parties, and the
fix applied, all in 5 days. Wish we could see more resolutions like
this - thanks to everyone involved.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-01-22 3:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-20 9:00 [PATCH] gpio: mcp23s08: create default gpio base if neither device node nor platform data is defined Sonic Zhang
2015-01-20 10:11 ` Alexandre Courbot
2015-01-20 16:03 ` Antonio Fiol Bonnín
2015-01-21 16:53 ` Linus Walleij
2015-01-22 3:15 ` Alexandre Courbot
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).