All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Gao Pandy <gaopan@freescale.com>
Cc: Li Frank <Frank.Li@freescale.com>,
	"wsa@the-dreams.de" <wsa@the-dreams.de>,
	"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	Duan Andy <fugang.duan@freescale.com>,
	"shawnguo@kernel.org" <shawnguo@kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [Patch V5] i2c: imx: implement bus recovery
Date: Mon, 21 Sep 2015 08:33:23 +0200	[thread overview]
Message-ID: <20150921063323.GA754@pengutronix.de> (raw)
In-Reply-To: <CY1PR0301MB0858E1C589215DBAFBE9E35ECF460@CY1PR0301MB0858.namprd03.prod.outlook.com>

Hello,

On Mon, Sep 21, 2015 at 04:29:20AM +0000, Gao Pandy wrote:
> > On Fri, Sep 11, 2015 at 06:42:34PM +0800, Gao Pan wrote:
> > > V5:
> > >  -introduce a dedicated gpio state for bus recovery.
> > >  -assign adapter.bus_recovery_info after the two gpios were aquired
> > >   successfully.
> > 
> > You also do this if the gpios were not acquired successfully.
>  
> Thanks. If the gpios are not acquired successfully, the context goes
> to label clk_disable. So the assignment is skipped.
> Please see the following code.
> 
>       ......
>   
> 	if (IS_ERR(i2c_imx->pins.sda)) {
> 		ret = PTR_ERR(i2c_imx->pins.sda);
> 		goto clk_disable;
> 	}
> 	if (IS_ERR(i2c_imx->pins.scl)) {
> 		ret = PTR_ERR(i2c_imx->pins.scl);
> 		goto clk_disable;
> 	}
> 	
> 	i2c_imx->adapter.bus_recovery_info = &i2c_imx_bus_recovery_info;
> 
> 	......

Right, if devm_gpiod_get_optional returns an error probing fails and
everything is right. If however devm_gpiod_get_optional returns NULL
(i.e. the dt doesn't contain an scl-gpios property) you happily use them
even though gpio_set_value are stubs in this case.
 
> > IMHO pinctrl_lookup_state returning an error is enough to not try a
> > recovery.
>  
> Thanks, you are right. How about the following logic.
> 
> 	if (!(IS_ERR(i2c_imx->pinctrl_pins_default)) && !(IS_ERR(i2c_imx->pinctrl_pins_gpio))) {

After the ! you don't need a (, but apart from this the logic is fine.

>                 i2c_imx->pins.sda =
>                         devm_gpiod_get_optional(&pdev->dev, "sda-gpios", GPIOD_IN);
>                 i2c_imx->pins.scl =
>                         devm_gpiod_get_optional(&pdev->dev, "scl-gpios", GPIOD_IN);
> 
>                 if (IS_ERR(i2c_imx->pins.sda)) {
>                         ret = PTR_ERR(i2c_imx->pins.sda);
>                         goto clk_disable;
>                 }
> 
>                 if (IS_ERR(i2c_imx->pins.scl)) {
>                         ret = PTR_ERR(i2c_imx->pins.scl);
>                         goto clk_disable;
>                 }

As said above, here you need an

		if (i2c_imx->pins.scl && i2c_imx->pins.sda)
>                 i2c_imx->adapter.bus_recovery_info = &i2c_imx_bus_recovery_info;
> 	} 

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

WARNING: multiple messages have this Message-ID (diff)
From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: [Patch V5] i2c: imx: implement bus recovery
Date: Mon, 21 Sep 2015 08:33:23 +0200	[thread overview]
Message-ID: <20150921063323.GA754@pengutronix.de> (raw)
In-Reply-To: <CY1PR0301MB0858E1C589215DBAFBE9E35ECF460@CY1PR0301MB0858.namprd03.prod.outlook.com>

Hello,

On Mon, Sep 21, 2015 at 04:29:20AM +0000, Gao Pandy wrote:
> > On Fri, Sep 11, 2015 at 06:42:34PM +0800, Gao Pan wrote:
> > > V5:
> > >  -introduce a dedicated gpio state for bus recovery.
> > >  -assign adapter.bus_recovery_info after the two gpios were aquired
> > >   successfully.
> > 
> > You also do this if the gpios were not acquired successfully.
>  
> Thanks. If the gpios are not acquired successfully, the context goes
> to label clk_disable. So the assignment is skipped.
> Please see the following code.
> 
>       ......
>   
> 	if (IS_ERR(i2c_imx->pins.sda)) {
> 		ret = PTR_ERR(i2c_imx->pins.sda);
> 		goto clk_disable;
> 	}
> 	if (IS_ERR(i2c_imx->pins.scl)) {
> 		ret = PTR_ERR(i2c_imx->pins.scl);
> 		goto clk_disable;
> 	}
> 	
> 	i2c_imx->adapter.bus_recovery_info = &i2c_imx_bus_recovery_info;
> 
> 	......

Right, if devm_gpiod_get_optional returns an error probing fails and
everything is right. If however devm_gpiod_get_optional returns NULL
(i.e. the dt doesn't contain an scl-gpios property) you happily use them
even though gpio_set_value are stubs in this case.
 
> > IMHO pinctrl_lookup_state returning an error is enough to not try a
> > recovery.
>  
> Thanks, you are right. How about the following logic.
> 
> 	if (!(IS_ERR(i2c_imx->pinctrl_pins_default)) && !(IS_ERR(i2c_imx->pinctrl_pins_gpio))) {

After the ! you don't need a (, but apart from this the logic is fine.

>                 i2c_imx->pins.sda =
>                         devm_gpiod_get_optional(&pdev->dev, "sda-gpios", GPIOD_IN);
>                 i2c_imx->pins.scl =
>                         devm_gpiod_get_optional(&pdev->dev, "scl-gpios", GPIOD_IN);
> 
>                 if (IS_ERR(i2c_imx->pins.sda)) {
>                         ret = PTR_ERR(i2c_imx->pins.sda);
>                         goto clk_disable;
>                 }
> 
>                 if (IS_ERR(i2c_imx->pins.scl)) {
>                         ret = PTR_ERR(i2c_imx->pins.scl);
>                         goto clk_disable;
>                 }

As said above, here you need an

		if (i2c_imx->pins.scl && i2c_imx->pins.sda)
>                 i2c_imx->adapter.bus_recovery_info = &i2c_imx_bus_recovery_info;
> 	} 

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

  reply	other threads:[~2015-09-21  6:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-11 10:42 [Patch V5] i2c: imx: implement bus recovery Gao Pan
2015-09-11 10:42 ` Gao Pan
     [not found] ` <1441968155-10918-1-git-send-email-b54642-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-09-11 10:42   ` [Patch V5] ARM: dts: imx6qdl-sabresd: add i2c pinctrl gpio state for " Gao Pan
2015-09-11 10:42     ` Gao Pan
     [not found]     ` <1441968155-10918-2-git-send-email-b54642-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-09-18  7:39       ` Gao Pandy
2015-09-18  7:39         ` Gao Pandy
2015-09-18  7:40   ` [Patch V5] i2c: imx: implement " Gao Pandy
2015-09-18  7:40     ` Gao Pandy
2015-09-18  7:54   ` Uwe Kleine-König
2015-09-18  7:54     ` Uwe Kleine-König
2015-09-21  4:29     ` Gao Pandy
2015-09-21  4:29       ` Gao Pandy
2015-09-21  6:33       ` Uwe Kleine-König [this message]
2015-09-21  6:33         ` Uwe Kleine-König
2015-09-21  8:13         ` Gao Pandy
2015-09-21  8:13           ` Gao Pandy
2015-09-18  7:58   ` Sascha Hauer
2015-09-18  7:58     ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150921063323.GA754@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=Frank.Li@freescale.com \
    --cc=fugang.duan@freescale.com \
    --cc=gaopan@freescale.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=shawnguo@kernel.org \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.