Commit 74779f6e authored by Wolfram Sang's avatar Wolfram Sang Committed by Wolfram Sang

i2c: rcar: refactor and shorten timeout when resetting

LOOP_TIMEOUT was only used back then because we didn't want to introduce
another constant. The timeout value can easily be a magnitude shorter
because the typical range is 3us - 8us. Refactor the code to use the
poll_timeout helper, use a specific timeout value and get rid of the
ugly LOOP_TIMEOUT constant.
Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent 9374ed1d
...@@ -146,9 +146,6 @@ struct rcar_i2c_priv { ...@@ -146,9 +146,6 @@ struct rcar_i2c_priv {
#define rcar_i2c_priv_to_dev(p) ((p)->adap.dev.parent) #define rcar_i2c_priv_to_dev(p) ((p)->adap.dev.parent)
#define rcar_i2c_is_recv(p) ((p)->msg->flags & I2C_M_RD) #define rcar_i2c_is_recv(p) ((p)->msg->flags & I2C_M_RD)
#define LOOP_TIMEOUT 1024
static void rcar_i2c_write(struct rcar_i2c_priv *priv, int reg, u32 val) static void rcar_i2c_write(struct rcar_i2c_priv *priv, int reg, u32 val)
{ {
writel(val, priv->io + reg); writel(val, priv->io + reg);
...@@ -760,20 +757,14 @@ static void rcar_i2c_release_dma(struct rcar_i2c_priv *priv) ...@@ -760,20 +757,14 @@ static void rcar_i2c_release_dma(struct rcar_i2c_priv *priv)
/* I2C is a special case, we need to poll the status of a reset */ /* I2C is a special case, we need to poll the status of a reset */
static int rcar_i2c_do_reset(struct rcar_i2c_priv *priv) static int rcar_i2c_do_reset(struct rcar_i2c_priv *priv)
{ {
int i, ret; int ret;
ret = reset_control_reset(priv->rstc); ret = reset_control_reset(priv->rstc);
if (ret) if (ret)
return ret; return ret;
for (i = 0; i < LOOP_TIMEOUT; i++) { return read_poll_timeout_atomic(reset_control_status, ret, ret == 0, 1,
ret = reset_control_status(priv->rstc); 100, false, priv->rstc);
if (ret == 0)
return 0;
udelay(1);
}
return -ETIMEDOUT;
} }
static int rcar_i2c_master_xfer(struct i2c_adapter *adap, static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment