Patchwork [1/2] gpio: mcp23s08: Allow -1 as a legal value for global gpio base

login
register
mail settings
Submitter Lars Poeschel
Date Feb. 6, 2013, 5:01 p.m.
Message ID <1360170118-11937-2-git-send-email-larsi@wh2.tu-dresden.de>
Download mbox | patch
Permalink /patch/218694/
State Not Applicable
Headers show

Comments

Lars Poeschel - Feb. 6, 2013, 5:01 p.m.
From: Lars Poeschel <poeschel@lemonage.de>

Explicitly allow -1 as a legal value for the
mcp23s08_platform_data->base. This is the special value lets the
kernel choose a valid global gpio base number.

Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
---
 drivers/gpio/gpio-mcp23s08.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Grant Likely - Feb. 9, 2013, 2:27 p.m.
On Wed,  6 Feb 2013 18:01:57 +0100, Lars Poeschel <larsi@wh2.tu-dresden.de> wrote:
> From: Lars Poeschel <poeschel@lemonage.de>
> 
> Explicitly allow -1 as a legal value for the
> mcp23s08_platform_data->base. This is the special value lets the
> kernel choose a valid global gpio base number.
> 
> Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
> ---
>  drivers/gpio/gpio-mcp23s08.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
> index 3cea0ea..2afb828 100644
> --- a/drivers/gpio/gpio-mcp23s08.c
> +++ b/drivers/gpio/gpio-mcp23s08.c
> @@ -483,7 +483,7 @@ static int mcp230xx_probe(struct i2c_client *client,
>  	int status;
>  
>  	pdata = client->dev.platform_data;
> -	if (!pdata || !gpio_is_valid(pdata->base)) {
> +	if ((!pdata || !gpio_is_valid(pdata->base)) && pdata->base != -1) {
>  		dev_dbg(&client->dev, "invalid or missing platform data\n");
>  		return -EINVAL;

When used with the device tree you shouldn't have a platform data
pointer at all. Instead you should modify the driver to not require it.

g.

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
index 3cea0ea..2afb828 100644
--- a/drivers/gpio/gpio-mcp23s08.c
+++ b/drivers/gpio/gpio-mcp23s08.c
@@ -483,7 +483,7 @@  static int mcp230xx_probe(struct i2c_client *client,
 	int status;
 
 	pdata = client->dev.platform_data;
-	if (!pdata || !gpio_is_valid(pdata->base)) {
+	if ((!pdata || !gpio_is_valid(pdata->base)) && pdata->base != -1) {
 		dev_dbg(&client->dev, "invalid or missing platform data\n");
 		return -EINVAL;
 	}
@@ -570,7 +570,7 @@  static int mcp23s08_probe(struct spi_device *spi)
 	type = spi_get_device_id(spi)->driver_data;
 
 	pdata = spi->dev.platform_data;
-	if (!pdata || !gpio_is_valid(pdata->base)) {
+	if ((!pdata || !gpio_is_valid(pdata->base)) && pdata->base != -1) {
 		dev_dbg(&spi->dev, "invalid or missing platform data\n");
 		return -EINVAL;
 	}