Re: [PATCH v6 25/35] i2c: tegra: Factor out error recovery from tegra_i2c_xfer_msg()

2020-09-08 Thread Dmitry Osipenko
08.09.2020 11:49, Andy Shevchenko пишет:
> On Tue, Sep 8, 2020 at 5:11 AM Dmitry Osipenko  wrote:
>>
>> Factor out error recovery code from tegra_i2c_xfer_msg() in order to
>> make this function easier to read and follow.
> 
> Ordering issue.
> You have a patch that replaces int -> unsigned int or so, which
> obviously has less impact (severity) than this one.

I guess you meant s/less/more/.

> Can you revisit the entire series and rethink ordering one more time?
> 

I'll try to improve the ordering a bit more, thanks.


Re: [PATCH v6 25/35] i2c: tegra: Factor out error recovery from tegra_i2c_xfer_msg()

2020-09-08 Thread Andy Shevchenko
On Tue, Sep 8, 2020 at 5:11 AM Dmitry Osipenko  wrote:
>
> Factor out error recovery code from tegra_i2c_xfer_msg() in order to
> make this function easier to read and follow.

Ordering issue.
You have a patch that replaces int -> unsigned int or so, which
obviously has less impact (severity) than this one.
Can you revisit the entire series and rethink ordering one more time?

-- 
With Best Regards,
Andy Shevchenko


[PATCH v6 25/35] i2c: tegra: Factor out error recovery from tegra_i2c_xfer_msg()

2020-09-07 Thread Dmitry Osipenko
Factor out error recovery code from tegra_i2c_xfer_msg() in order to
make this function easier to read and follow.

Reviewed-by: Michał Mirosław 
Signed-off-by: Dmitry Osipenko 
---
 drivers/i2c/busses/i2c-tegra.c | 46 ++
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 0d823aae9eaf..e53334bc3de3 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -1098,6 +1098,32 @@ static int tegra_i2c_issue_bus_clear(struct i2c_adapter 
*adap)
return -EAGAIN;
 }
 
+static int tegra_i2c_error_recover(struct tegra_i2c_dev *i2c_dev,
+  struct i2c_msg *msg)
+{
+   if (i2c_dev->msg_err == I2C_ERR_NONE)
+   return 0;
+
+   tegra_i2c_init(i2c_dev);
+
+   /* start recovery upon arbitration loss in single master mode */
+   if (i2c_dev->msg_err == I2C_ERR_ARBITRATION_LOST) {
+   if (!i2c_dev->is_multimaster_mode)
+   return i2c_recover_bus(&i2c_dev->adapter);
+
+   return -EAGAIN;
+   }
+
+   if (i2c_dev->msg_err == I2C_ERR_NO_ACK) {
+   if (msg->flags & I2C_M_IGNORE_NAK)
+   return 0;
+
+   return -EREMOTEIO;
+   }
+
+   return -EIO;
+}
+
 static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
  struct i2c_msg *msg,
  enum msg_end_type end_state)
@@ -1282,24 +1308,12 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev 
*i2c_dev,
i2c_dev->msg_err);
 
i2c_dev->is_curr_dma_xfer = false;
-   if (i2c_dev->msg_err == I2C_ERR_NONE)
-   return 0;
 
-   tegra_i2c_init(i2c_dev);
-   /* start recovery upon arbitration loss in single master mode */
-   if (i2c_dev->msg_err == I2C_ERR_ARBITRATION_LOST) {
-   if (!i2c_dev->is_multimaster_mode)
-   return i2c_recover_bus(&i2c_dev->adapter);
-   return -EAGAIN;
-   }
-
-   if (i2c_dev->msg_err == I2C_ERR_NO_ACK) {
-   if (msg->flags & I2C_M_IGNORE_NAK)
-   return 0;
-   return -EREMOTEIO;
-   }
+   err = tegra_i2c_error_recover(i2c_dev, msg);
+   if (err)
+   return err;
 
-   return -EIO;
+   return 0;
 }
 
 static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
-- 
2.27.0