mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org, Matthias Fend <matthias.fend@emfend.at>
Subject: Re: [PATCH] i2c: rockchip: fix transfer return value
Date: Wed, 11 May 2022 08:45:33 +0200	[thread overview]
Message-ID: <20220511064533.GJ4012@pengutronix.de> (raw)
In-Reply-To: <20220510153657.2033190-1-a.fatoum@pengutronix.de>

On Tue, May 10, 2022 at 05:36:57PM +0200, Ahmad Fatoum wrote:
> barebox (and kernel) API is for i2c_adapter::master_xfer to return the
> number of successfully transmitted messages and a negative value on
> error. This was not observed in the Rockchip driver, fix this.
> 
> Reported-by: Matthias Fend <matthias.fend@emfend.at>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> Only compile-tested, but change looks innocuous enough.
> ---
>  drivers/i2c/busses/i2c-rockchip.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/i2c/busses/i2c-rockchip.c b/drivers/i2c/busses/i2c-rockchip.c
> index 4990735a4b11..ca339053356c 100644
> --- a/drivers/i2c/busses/i2c-rockchip.c
> +++ b/drivers/i2c/busses/i2c-rockchip.c
> @@ -375,15 +375,17 @@ i2c_exit:
>  	return err;
>  }
>  
> -static int rockchip_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msg,
> +static int rockchip_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs,
>  			     int nmsgs)
>  {
>  	struct rk_i2c *i2c = to_rk_i2c(adapter);
>  	struct device_d *dev = &adapter->dev;
> -	int ret;
> +	int i, ret = 0;
>  
>  	dev_dbg(dev, "i2c_xfer: %d messages\n", nmsgs);
> -	for (; nmsgs > 0; nmsgs--, msg++) {
> +	for (i = 0; i < nmsgs; i++) {
> +		struct i2c_msg *msg = &msgs[i];
> +
>  		dev_dbg(dev, "i2c_xfer: chip=0x%x, len=0x%x\n", msg->addr, msg->len);
>  		if (msg->flags & I2C_M_RD) {
>  			ret = rk_i2c_read(i2c, msg->addr, 0, 0, msg->buf,
> @@ -395,14 +397,15 @@ static int rockchip_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msg,
>  		if (ret) {
>  			dev_dbg(dev, "i2c_write: error sending: %pe\n",
>  				ERR_PTR(ret));
> -			return -EREMOTEIO;
> +			ret = -EREMOTEIO;
> +			break;
>  		}
>  	}
>  
>  	rk_i2c_send_stop_bit(i2c);
>  	rk_i2c_disable(i2c);
>  
> -	return 0;
> +	return ret < 0 ? ret : nmsgs;
>  }
>  
>  static int rk_i2c_probe(struct device_d *dev)
> -- 
> 2.30.2
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


      reply	other threads:[~2022-05-11  6:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-10 15:36 Ahmad Fatoum
2022-05-11  6:45 ` Sascha Hauer [this message]

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=20220511064533.GJ4012@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=matthias.fend@emfend.at \
    /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