Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c: rcar: use the new get_bus_free callback

To break out of recovery as early as possible, feed back the bus_free
logic state.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

authored by

Wolfram Sang and committed by
Wolfram Sang
4fe10de5 7ca5f6be

+11 -10
+11 -10
drivers/i2c/busses/i2c-rcar.c
··· 179 179 rcar_i2c_write(priv, ICMCR, priv->recovery_icmcr); 180 180 }; 181 181 182 - /* No get_sda, because the HW only reports its bus free logic, not SDA itself */ 183 - 184 182 static void rcar_i2c_set_sda(struct i2c_adapter *adap, int val) 185 183 { 186 184 struct rcar_i2c_priv *priv = i2c_get_adapdata(adap); ··· 191 193 rcar_i2c_write(priv, ICMCR, priv->recovery_icmcr); 192 194 }; 193 195 196 + static int rcar_i2c_get_bus_free(struct i2c_adapter *adap) 197 + { 198 + struct rcar_i2c_priv *priv = i2c_get_adapdata(adap); 199 + 200 + return !(rcar_i2c_read(priv, ICMCR) & FSDA); 201 + 202 + }; 203 + 194 204 static struct i2c_bus_recovery_info rcar_i2c_bri = { 195 205 .get_scl = rcar_i2c_get_scl, 196 206 .set_scl = rcar_i2c_set_scl, 197 207 .set_sda = rcar_i2c_set_sda, 208 + .get_bus_free = rcar_i2c_get_bus_free, 198 209 .recover_bus = i2c_generic_scl_recovery, 199 210 }; 200 211 static void rcar_i2c_init(struct rcar_i2c_priv *priv) ··· 218 211 219 212 static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv) 220 213 { 221 - int i, ret; 214 + int i; 222 215 223 216 for (i = 0; i < LOOP_TIMEOUT; i++) { 224 217 /* make sure that bus is not busy */ ··· 229 222 230 223 /* Waiting did not help, try to recover */ 231 224 priv->recovery_icmcr = MDBS | OBPC | FSDA | FSCL; 232 - ret = i2c_recover_bus(&priv->adap); 233 - 234 - /* No failure when recovering, so check bus busy bit again */ 235 - if (ret == 0) 236 - ret = (rcar_i2c_read(priv, ICMCR) & FSDA) ? -EBUSY : 0; 237 - 238 - return ret; 225 + return i2c_recover_bus(&priv->adap); 239 226 } 240 227 241 228 static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, struct i2c_timings *t)