Re: [PATCH] i2c: designware: retry transfer on transient failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2015-12-23 at 18:43 +0200, Baruch Siach wrote:
> Set the i2c_adapter retries field to a sensible value. This allows
> the i2c core
> to retry master_xfer() when it returns -EAGAIN. Currently the i2c-
> designware
> driver returns -EAGAIN only on Tx arbitration failure
> (DW_IC_TX_ARB_LOST).

Wolfram, regarding to this patch I have the following idea (I would
like to discuss a road map before step in implementing that).

First of all I would like to refactor the existing API,
i.e. i2c_parse_fw_timings(). So, do exactly two things:
a) embed struct i2c_timings into struct i2c_adapter;
b) change prototype to be i2c_parse_fw_timings(struct i2c_adapter
*adapter, bool use_defaults).

After that, introduce a new property 'linux,i2c-retry-count' to be used
as retries field in struct i2c_adapter.

Then introduce where we do similar stuff

void i2c_parse_linux_retries(struct i2c_adapter *adapter, bool
use_defaults)
{
  struct device *dev = adapter->dev.parent;
  int ret;

  ret = device_property_read_u{8,16,32?}(dev, "linux,i2c-retry-count",
&adapter->retries);
  if (ret && use_defaults)
    adapter->retries = 3;
}

And replace adapter.retries = 3 in the drivers by
i2c_parse_linux_retries(&adapter, true);

So, what do you think?

> 
> Reported-by: Rolland Chau <zourongrong@xxxxxxxxx>
> Signed-off-by: Baruch Siach <baruch@xxxxxxxxxx>
> ---
>  drivers/i2c/busses/i2c-designware-core.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/i2c/busses/i2c-designware-core.c
> b/drivers/i2c/busses/i2c-designware-core.c
> index de7fbbb374cd..f7b34b360dc9 100644
> --- a/drivers/i2c/busses/i2c-designware-core.c
> +++ b/drivers/i2c/busses/i2c-designware-core.c
> @@ -860,6 +860,7 @@ int i2c_dw_probe(struct dw_i2c_dev *dev)
>  
>  	snprintf(adap->name, sizeof(adap->name),
>  		 "Synopsys DesignWare I2C adapter");
> +	adap->retries = 3;
>  	adap->algo = &i2c_dw_algo;
>  	adap->dev.parent = dev->dev;
>  	i2c_set_adapdata(adap, dev);

-- 
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Intel Finland Oy

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux