linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
To: Mike Looijmans <mike.looijmans-Oq418RWZeHk@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] i2c-davinci: Handle signals gracefully
Date: Mon, 24 Mar 2014 17:14:32 +0100	[thread overview]
Message-ID: <20140324161432.GA7524@katana> (raw)
In-Reply-To: <1394779348-4084-1-git-send-email-mike.looijmans-Oq418RWZeHk@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 2147 bytes --]


> diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
> index af0b583..254d897 100644
> --- a/drivers/i2c/busses/i2c-davinci.c
> +++ b/drivers/i2c/busses/i2c-davinci.c
> @@ -372,9 +372,9 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
>  		flag |= DAVINCI_I2C_MDR_STP;
>  	davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag);
>  
> -	r = wait_for_completion_interruptible_timeout(&dev->cmd_complete,
> +	r = wait_for_completion_timeout(&dev->cmd_complete,
>  						      dev->adapter.timeout);
> -	if (r == 0) {
> +	if (unlikely(r == 0)) {

Not really needed, but well yeah...

>  		dev_err(dev->dev, "controller timed out\n");
>  		davinci_i2c_recover_bus(dev);
>  		i2c_davinci_init(dev);
> @@ -384,7 +384,6 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
>  	if (dev->buf_len) {
>  		/* This should be 0 if all bytes were transferred
>  		 * or dev->cmd_err denotes an error.
> -		 * A signal may have aborted the transfer.
>  		 */
>  		if (r >= 0) {
>  			dev_err(dev->dev, "abnormal termination buf_len=%i\n",
> @@ -436,22 +435,24 @@ i2c_davinci_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
>  	ret = i2c_davinci_wait_bus_not_busy(dev, 1);
>  	if (ret < 0) {
>  		dev_warn(dev->dev, "timeout waiting for bus ready\n");
> -		return ret;
> +		goto error;

You are fixing the error path here to include the completion? This is a
seperate patch IMO.

>  	}
>  
>  	for (i = 0; i < num; i++) {
>  		ret = i2c_davinci_xfer_msg(adap, &msgs[i], (i == (num - 1)));
> -		dev_dbg(dev->dev, "%s [%d/%d] ret: %d\n", __func__, i + 1, num,
> -			ret);
> +		dev_dbg(dev->dev, "%s [%d/%d] %#x ret: %d\n", __func__, i + 1,
> +				num, msgs[i].addr, ret);

No need for this change. We have other debug output/tracing already. But
no need to clean up either.

>  		if (ret < 0)
> -			return ret;
> +			goto error;
>  	}
> +	ret = num;
>  
> +error:
>  #ifdef CONFIG_CPU_FREQ
>  	complete(&dev->xfr_complete);
>  #endif
>  
> -	return num;
> +	return ret;

Thanks,

   Wolfram


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2014-03-24 16:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-09 11:11 [PATCH] i2c-davinci: Handle signals gracefully Mike Looijmans
     [not found] ` <1389265885-26777-1-git-send-email-mike.looijmans-Oq418RWZeHk@public.gmane.org>
2014-03-09 20:21   ` Wolfram Sang
2014-03-10 10:24     ` Mike Looijmans
     [not found]       ` <531D92F7.7080509-Oq418RWZeHk@public.gmane.org>
2014-03-10 10:59         ` Wolfram Sang
2014-03-10 15:24           ` Wolfram Sang
2014-03-14  6:43             ` Mike Looijmans
2014-03-14  6:42   ` Mike Looijmans
     [not found]     ` <1394779348-4084-1-git-send-email-mike.looijmans-Oq418RWZeHk@public.gmane.org>
2014-03-24 16:14       ` Wolfram Sang [this message]
2014-05-21  8:17         ` Wolfram Sang
2014-05-24 11:53           ` Mike Looijmans
     [not found]             ` <53808851.7060308-Oq418RWZeHk@public.gmane.org>
2014-06-01 20:11               ` Wolfram Sang
2014-11-08 21:51                 ` Wolfram Sang
2014-11-10 14:49                   ` Mike Looijmans

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=20140324161432.GA7524@katana \
    --to=wsa-z923lk4zbo2bacvfa/9k2g@public.gmane.org \
    --cc=davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mike.looijmans-Oq418RWZeHk@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).