diff mbox

i2c: pca954x: Defer probing due to reset GPIO

Message ID 1425480268-7322-1-git-send-email-laurent.pinchart@ideasonboard.com
State Rejected
Headers show

Commit Message

Laurent Pinchart March 4, 2015, 2:44 p.m. UTC
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 <laurent.pinchart@ideasonboard.com>
---
 drivers/i2c/muxes/i2c-mux-pca954x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Uwe Kleine-König March 5, 2015, 8:53 a.m. UTC | #1
Hello,

On Wed, Mar 04, 2015 at 04:44:28PM +0200, Laurent Pinchart wrote:
> 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 <laurent.pinchart@ideasonboard.com>
I sent the same patch with a slightly different motivation two weeks
ago: http://article.gmane.org/gmane.linux.drivers.i2c/21972

Best regards
Uwe
Laurent Pinchart March 5, 2015, 10:23 a.m. UTC | #2
Hi Uwe,

On Thursday 05 March 2015 09:53:53 Uwe Kleine-König wrote:
> On Wed, Mar 04, 2015 at 04:44:28PM +0200, Laurent Pinchart wrote:
> > 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 <laurent.pinchart@ideasonboard.com>
> 
> I sent the same patch with a slightly different motivation two weeks
> ago: http://article.gmane.org/gmane.linux.drivers.i2c/21972

And I've even acked it... Well, I guess it means I really like the patch ;-) 
Let's get your version merged.
diff mbox

Patch

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