summaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2016-11-16 13:18:49 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2016-11-17 07:58:51 +0100
commit8303208e95112943cccfe6252e806cc159e5106a (patch)
tree928dbd09b1620b2b98301b8bca73da995f7ae909 /drivers/i2c
parent8eb1fb3519b6c1ae6ddab114a7cdc86bb24da296 (diff)
downloadbarebox-8303208e95112943cccfe6252e806cc159e5106a.tar.gz
barebox-8303208e95112943cccfe6252e806cc159e5106a.tar.xz
i2c: gpio: fix handling of return code of of_get_gpio
Instead of using gpio_is_valid just check the return code of of_get_gpio for being < 0. This fixes -EPROBE_DEFER handling as now this error code is handed to the caller instead of -ENODEV. If the gpio returned by of_get_gpio is an invalid number this isn't noticed by of_i2c_gpio_probe, but then gpio_request later fails which is good enough. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-gpio.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index 9362ed181f..850db7b2f6 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -89,6 +89,7 @@ static int of_i2c_gpio_probe(struct device_node *np,
struct i2c_gpio_platform_data *pdata)
{
u32 reg;
+ int ret;
if (!IS_ENABLED(CONFIG_OFDEVICE))
return -ENODEV;
@@ -96,14 +97,15 @@ static int of_i2c_gpio_probe(struct device_node *np,
if (of_gpio_count(np) < 2)
return -ENODEV;
- pdata->sda_pin = of_get_gpio(np, 0);
- pdata->scl_pin = of_get_gpio(np, 1);
+ ret = of_get_gpio(np, 0);
+ if (ret < 0)
+ return ret;
+ pdata->sda_pin = ret;
- if (!gpio_is_valid(pdata->sda_pin) || !gpio_is_valid(pdata->scl_pin)) {
- pr_err("%s: invalid GPIO pins, sda=%d/scl=%d\n",
- np->full_name, pdata->sda_pin, pdata->scl_pin);
- return -ENODEV;
- }
+ ret = of_get_gpio(np, 1);
+ if (ret < 0)
+ return ret;
+ pdata->scl_pin = ret;
of_property_read_u32(np, "i2c-gpio,delay-us", &pdata->udelay);