linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: Gao Pan <b54642-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
Cc: wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	B20596-KZfg59tc24xl57MIdRCFDg@public.gmane.org,
	b38611-KZfg59tc24xl57MIdRCFDg@public.gmane.org,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org
Subject: Re: [Patch v4] i2c: imx: implement bus recovery
Date: Mon, 7 Sep 2015 23:27:12 +0200	[thread overview]
Message-ID: <20150907212712.GJ14598@pengutronix.de> (raw)
In-Reply-To: <1439977931-5104-1-git-send-email-b54642-KZfg59tc24xl57MIdRCFDg@public.gmane.org>

Hello,

On Wed, Aug 19, 2015 at 05:52:11PM +0800, Gao Pan wrote:
> @@ -963,6 +973,59 @@ out:
>  	return (result < 0) ? result : num;
>  }
>  
> +static int i2c_imx_get_scl(struct i2c_adapter *adap)
> +{
> +	struct imx_i2c_struct *i2c_imx;
> +
> +	i2c_imx = container_of(adap, struct imx_i2c_struct, adapter);
> +
> +	return gpiod_get_value(i2c_imx->pins.scl);
> +}
> +
> +static int i2c_imx_get_sda(struct i2c_adapter *adap)
> +{
> +	struct imx_i2c_struct *i2c_imx;
> +
> +	i2c_imx = container_of(adap, struct imx_i2c_struct, adapter);
> +
> +	return gpiod_get_value(i2c_imx->pins.sda);
> +}
> +
> +static void i2c_imx_set_scl(struct i2c_adapter *adap, int val)
> +{
> +	struct imx_i2c_struct *i2c_imx;
> +
> +	i2c_imx = container_of(adap, struct imx_i2c_struct, adapter);
> +	gpiod_set_value(i2c_imx->pins.scl, val);
> +}

<nitpick>
These three functions are very similar (i.e. 1 line respectively for
variable declaration, driver data assignment and gpio operation), but
the last has an empty line less. 
</nitpick>

> +static void i2c_imx_prepare_recovery(struct i2c_adapter *adap)
> +{
> +	struct imx_i2c_struct *i2c_imx;
> +
> +	i2c_imx = container_of(adap, struct imx_i2c_struct, adapter);
> +	pinctrl_pm_select_sleep_state(&adap->dev);

I still think this is not nice, the v2 thread is still active with Linus
W. being involved.

> +	gpiod_direction_input(i2c_imx->pins.sda);
> +	gpiod_direction_output(i2c_imx->pins.scl, 1);
> +}
> [...]
> @@ -1011,12 +1074,13 @@ static int i2c_imx_probe(struct platform_device *pdev)
>  
>  	/* Setup i2c_imx driver structure */
>  	strlcpy(i2c_imx->adapter.name, pdev->name, sizeof(i2c_imx->adapter.name));
> -	i2c_imx->adapter.owner		= THIS_MODULE;
> -	i2c_imx->adapter.algo		= &i2c_imx_algo;
> -	i2c_imx->adapter.dev.parent	= &pdev->dev;
> -	i2c_imx->adapter.nr		= pdev->id;
> -	i2c_imx->adapter.dev.of_node	= pdev->dev.of_node;
> -	i2c_imx->base			= base;
> +	i2c_imx->adapter.owner = THIS_MODULE;
> +	i2c_imx->adapter.algo = &i2c_imx_algo;
> +	i2c_imx->adapter.dev.parent = &pdev->dev;
> +	i2c_imx->adapter.nr = pdev->id;
> +	i2c_imx->adapter.dev.of_node = pdev->dev.of_node;
> +	i2c_imx->adapter.bus_recovery_info = &i2c_imx_bus_recovery_info;
In a former review round I suggested to only do this assignment after
the two gpios were aquired successfully. Then the above checks could be

	if (i2c_imx->adapter.bus_recovery_info)

instead of

	if (i2c_imx->pins.sda && i2c_imx->pins.scl)

which IMHO looks nicer and more robust.

Best regards
Uwe

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

  parent reply	other threads:[~2015-09-07 21:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-19  9:52 [Patch v4] i2c: imx: implement bus recovery Gao Pan
     [not found] ` <1439977931-5104-1-git-send-email-b54642-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-08-24  1:45   ` Gao Pandy
2015-09-07 21:27   ` Uwe Kleine-König [this message]
     [not found]     ` <20150907212712.GJ14598-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2015-09-11  2:10       ` Gao Pandy

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=20150907212712.GJ14598@pengutronix.de \
    --to=u.kleine-koenig-bicnvbalz9megne8c9+irq@public.gmane.org \
    --cc=B20596-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=b38611-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=b54642-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org \
    /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 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).