* [PATCH] i2c: pca954x: improve usage of gpiod API @ 2015-02-17 9:12 Uwe Kleine-König [not found] ` <1424164328-28534-1-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: Uwe Kleine-König @ 2015-02-17 9:12 UTC (permalink / raw) To: Wolfram Sang, Laurent Pinchart Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, kernel-bIcnvbaLZ9MEGnE8C9+IrQ Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions) which appeared in v3.17-rc1, the gpiod_get* functions take an additional parameter that allows to specify direction and initial value for outputs. Also there is an *_optional variant that serves well here. The sematics is slightly changed here by using it. Now if a reset gpio is specified and getting hold on it fails, pca954x_probe fails, too. Signed-off-by: Uwe Kleine-König <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> --- 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 ec11b404b433..0042cf3d77db 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -201,9 +201,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 -- 2.1.4 ^ permalink raw reply related [flat|nested] 3+ messages in thread
[parent not found: <1424164328-28534-1-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>]
* Re: [PATCH] i2c: pca954x: improve usage of gpiod API [not found] ` <1424164328-28534-1-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> @ 2015-02-17 20:06 ` Laurent Pinchart 2015-03-07 0:18 ` Wolfram Sang 1 sibling, 0 replies; 3+ messages in thread From: Laurent Pinchart @ 2015-02-17 20:06 UTC (permalink / raw) To: Uwe Kleine-König Cc: Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA, kernel-bIcnvbaLZ9MEGnE8C9+IrQ Hi Uwe, Thank you for the patch. On Tuesday 17 February 2015 10:12:08 Uwe Kleine-König wrote: > Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions) > which appeared in v3.17-rc1, the gpiod_get* functions take an additional > parameter that allows to specify direction and initial value for > outputs. > > Also there is an *_optional variant that serves well here. The sematics > is slightly changed here by using it. Now if a reset gpio is specified > and getting hold on it fails, pca954x_probe fails, too. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> Acked-by: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org> > --- > 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 ec11b404b433..0042cf3d77db > 100644 > --- a/drivers/i2c/muxes/i2c-mux-pca954x.c > +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c > @@ -201,9 +201,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 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] i2c: pca954x: improve usage of gpiod API [not found] ` <1424164328-28534-1-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> 2015-02-17 20:06 ` Laurent Pinchart @ 2015-03-07 0:18 ` Wolfram Sang 1 sibling, 0 replies; 3+ messages in thread From: Wolfram Sang @ 2015-03-07 0:18 UTC (permalink / raw) To: Uwe Kleine-König Cc: Laurent Pinchart, linux-i2c-u79uwXL29TY76Z2rM5mHXA, kernel-bIcnvbaLZ9MEGnE8C9+IrQ [-- Attachment #1: Type: text/plain, Size: 644 bytes --] On Tue, Feb 17, 2015 at 10:12:08AM +0100, Uwe Kleine-König wrote: > Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions) > which appeared in v3.17-rc1, the gpiod_get* functions take an additional > parameter that allows to specify direction and initial value for > outputs. > > Also there is an *_optional variant that serves well here. The sematics > is slightly changed here by using it. Now if a reset gpio is specified > and getting hold on it fails, pca954x_probe fails, too. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> Applied to for-next, thanks! [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-07 0:18 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-02-17 9:12 [PATCH] i2c: pca954x: improve usage of gpiod API Uwe Kleine-König [not found] ` <1424164328-28534-1-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> 2015-02-17 20:06 ` Laurent Pinchart 2015-03-07 0:18 ` Wolfram Sang
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).