If a reset GPIO is specified but not available we must defer probing, as
the device could be held in reset. Use devm_gpiod_request_optional() to
handle this automatically.

Signed-off-by: Laurent Pinchart <[email protected]>
---
 drivers/i2c/muxes/i2c-mux-pca954x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c 
b/drivers/i2c/muxes/i2c-mux-pca954x.c
index 3d8f4fe..bea0d2d 100644
--- a/drivers/i2c/muxes/i2c-mux-pca954x.c
+++ b/drivers/i2c/muxes/i2c-mux-pca954x.c
@@ -204,9 +204,9 @@ static int pca954x_probe(struct i2c_client *client,
        i2c_set_clientdata(client, data);
 
        /* Get the mux out of reset if a reset GPIO is specified. */
-       gpio = devm_gpiod_get(&client->dev, "reset");
-       if (!IS_ERR(gpio))
-               gpiod_direction_output(gpio, 0);
+       gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_LOW);
+       if (IS_ERR(gpio))
+               return PTR_ERR(gpio);
 
        /* Write the mux register at addr to verify
         * that the mux is in fact present. This also
-- 
Regards,

Laurent Pinchart

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

Reply via email to