public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: santosh.shilimkar@ti•com (Santosh Shilimkar)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v2 2/7] i2c: omap: reorder exit path of omap_i2c_xfer_msg()
Date: Thu, 25 Oct 2012 18:12:00 +0530	[thread overview]
Message-ID: <50893398.6070004@ti.com> (raw)
In-Reply-To: <1351167915-15079-3-git-send-email-balbi@ti.com>

On Thursday 25 October 2012 05:55 PM, Felipe Balbi wrote:
> just a cleanup patch trying to make exit path
> more straightforward. No changes otherwise.
>
> Signed-off-by: Felipe Balbi <balbi@ti•com>
> ---
>   drivers/i2c/busses/i2c-omap.c | 26 +++++++++++++++++---------
>   1 file changed, 17 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index c07d9c4..bea0277 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -505,6 +505,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
>   {
>   	struct omap_i2c_dev *dev = i2c_get_adapdata(adap);
>   	unsigned long timeout;
> +	int ret;
You might want to initialize the error value to avoid return 0. Compiler
might be already cribbing for it

>   	u16 w;
>
>   	dev_dbg(dev->dev, "addr: 0x%04x, len: %d, flags: 0x%x, stop: %d\n",
> @@ -582,31 +583,38 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
>   	dev->buf_len = 0;
>   	if (timeout == 0) {
>   		dev_err(dev->dev, "controller timed out\n");
> -		omap_i2c_init(dev);
> -		return -ETIMEDOUT;
> +		ret = -ETIMEDOUT;
> +		goto err_i2c_init;
>   	}
>
> -	if (likely(!dev->cmd_err))
> -		return 0;
> -
Have you have drooped this check completely ?

>   	/* We have an error */
>   	if (dev->cmd_err & (OMAP_I2C_STAT_AL | OMAP_I2C_STAT_ROVR |
>   			    OMAP_I2C_STAT_XUDF)) {
> -		omap_i2c_init(dev);
> -		return -EIO;
> +		ret = -EIO;
> +		goto err_i2c_init;
>   	}
>
>   	if (dev->cmd_err & OMAP_I2C_STAT_NACK) {
>   		if (msg->flags & I2C_M_IGNORE_NAK)
>   			return 0;
> +
>   		if (stop) {
>   			w = omap_i2c_read_reg(dev, OMAP_I2C_CON_REG);
>   			w |= OMAP_I2C_CON_STP;
>   			omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w);
>   		}
> -		return -EREMOTEIO;
> +
> +		ret = -EREMOTEIO;
> +		goto err;
>   	}
> -	return -EIO;
> +
> +	return 0;
With initialized value you can use
return ret;

Regards
Santosh

  reply	other threads:[~2012-10-25 12:42 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-22  9:46 [PATCH 0/8] I2C patches for v3.8 merge window Felipe Balbi
2012-10-22  9:46 ` [PATCH 1/8] i2c: omap: no need to access platform_device Felipe Balbi
2012-10-22  9:46 ` [PATCH 2/8] i2c: omap: reorder exit path of omap_i2c_xfer_msg() Felipe Balbi
2012-10-25 11:40   ` Shubhrajyoti Datta
2012-10-25 12:01     ` Felipe Balbi
2012-10-22  9:46 ` [PATCH 3/8] i2c: omap: fix error checking Felipe Balbi
2012-10-24 14:41   ` Michael Trimarchi
2012-10-25 10:10     ` Felipe Balbi
2012-10-25 10:33       ` Michael Trimarchi
2012-10-25 10:48         ` Felipe Balbi
2012-10-22  9:46 ` [PATCH 4/8] i2c: omap: also complete() when stat becomes zero Felipe Balbi
2012-10-22  9:46 ` [PATCH 5/8] i2c: omap: introduce and use OMAP_I2C_IP_VERSION_3 Felipe Balbi
2012-10-22 12:27   ` Benoit Cousson
2012-10-22 12:28     ` Felipe Balbi
2012-10-22 13:05       ` Benoit Cousson
2012-10-22 13:09         ` Felipe Balbi
2012-10-22 13:18   ` [PATCH v2 5/8] i2c: omap: in case of VERSION_2 read IRQSTATUS_RAW but write to IRQSTATUS Felipe Balbi
2012-10-22  9:46 ` [PATCH 6/8] i2c: omap: wait for transfer completion before sending STP bit Felipe Balbi
2012-10-22  9:46 ` [PATCH 7/8] i2c: add 'transferred' field to struct i2c_msg Felipe Balbi
2012-10-25 12:57   ` Jean Delvare
2012-10-25 13:14     ` Russell King - ARM Linux
2012-10-25 13:42       ` Jean Delvare
2012-10-25 13:46         ` Russell King - ARM Linux
2012-10-25 13:56           ` Jean Delvare
2012-10-25 14:18             ` Russell King - ARM Linux
2012-10-27 14:32               ` Jean Delvare
2012-10-27 16:40                 ` Al Viro
2012-10-27 17:02                   ` Al Viro
2012-10-27 17:10                     ` Al Viro
2012-10-27 19:03                       ` Jean Delvare
2012-10-27 17:25                 ` Russell King - ARM Linux
2012-10-22  9:46 ` [PATCH 8/8] i2c: omap: implement handling for 'transferred' bytes Felipe Balbi
2012-10-22 13:30 ` [PATCH 0/8] I2C patches for v3.8 merge window Felipe Balbi
2012-10-22 14:06   ` Shubhrajyoti Datta
2012-10-22 14:06     ` Felipe Balbi
2012-10-22 15:02       ` Shubhrajyoti
2012-11-14 16:58     ` Wolfram Sang
2012-10-25 12:25 ` [PATCH v2 0/7] " Felipe Balbi
2012-10-25 12:25   ` [PATCH v2 1/7] i2c: omap: no need to access platform_device Felipe Balbi
2012-10-25 12:41     ` Santosh Shilimkar
2012-10-25 12:25   ` [PATCH v2 2/7] i2c: omap: reorder exit path of omap_i2c_xfer_msg() Felipe Balbi
2012-10-25 12:42     ` Santosh Shilimkar [this message]
2012-10-25 12:40       ` Felipe Balbi
2012-10-25 12:53       ` Lothar Waßmann
2012-10-25 12:25   ` [PATCH v2 3/7] i2c: omap: also complete() when stat becomes zero Felipe Balbi
2012-10-25 12:43     ` Santosh Shilimkar
2012-10-25 12:39       ` Felipe Balbi
2012-10-25 12:25   ` [PATCH v2 4/7] i2c: omap: in case of VERSION_2 read IRQSTATUS_RAW but write to IRQSTATUS Felipe Balbi
2012-10-25 12:53     ` Santosh Shilimkar
2012-10-25 12:52       ` Felipe Balbi
2012-10-25 13:06         ` Santosh Shilimkar
2012-10-25 12:25   ` [PATCH v2 5/7] i2c: omap: wait for transfer completion before sending STP bit Felipe Balbi
2012-10-25 12:32     ` Felipe Balbi
2012-10-25 12:34     ` [PATCH v3 " Felipe Balbi
2012-10-25 13:01     ` [PATCH v2 " Santosh Shilimkar
2012-10-25 14:15       ` Felipe Balbi
2012-10-25 12:25   ` [PATCH v2 6/7] i2c: add 'transferred' field to struct i2c_msg Felipe Balbi
2012-10-25 12:25   ` [PATCH v2 7/7] i2c: omap: implement handling for 'transferred' bytes Felipe Balbi
2012-10-27 18:55     ` Paul Walmsley
2012-11-05  8:10   ` [PATCH v2 0/7] I2C patches for v3.8 merge window Felipe Balbi

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=50893398.6070004@ti.com \
    --to=santosh.shilimkar@ti$(echo .)com \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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