History

i2c: rcar: disable runtime PM correctly in slave mode

When we also are I2C slave, we need to disable runtime PM because the address detection mechanism needs to be active all the time. However, we can reenable runtime PM once the slave instance was unregistered. So, use pm_runtime_get_sync/put to achieve this, since it has proper refcounting. pm_runtime_allow/forbid is like a global knob controllable from userspace which is unsuitable here.

Wolfram Sang committed 10 years ago

Commit b4cd08a1 parent e79e72c1 file · +2 −2Browse files

Unified · Split

drivers/i2c/busses/i2c-rcar.c+2−2
@@ -576,7 +576,7 @@ static int rcar_reg_slave(struct i2c_client *slave) · 575 unmodified lines
576 if (slave->flags & I2C_CLIENT_TEN)576 if (slave->flags & I2C_CLIENT_TEN)
577 return -EAFNOSUPPORT;577 return -EAFNOSUPPORT;
578 578
579 pm_runtime_forbid(rcar_i2c_priv_to_dev(priv));579 pm_runtime_get_sync(rcar_i2c_priv_to_dev(priv));
580 580
581 priv->slave = slave;581 priv->slave = slave;
582 rcar_i2c_write(priv, ICSAR, slave->addr);582 rcar_i2c_write(priv, ICSAR, slave->addr);
@@ -598,7 +598,7 @@ static int rcar_unreg_slave(struct i2c_client *slave) · 15 unmodified lines
598 598
599 priv->slave = NULL;599 priv->slave = NULL;
600 600
601 pm_runtime_allow(rcar_i2c_priv_to_dev(priv));601 pm_runtime_put(rcar_i2c_priv_to_dev(priv));
602 602
603 return 0;603 return 0;
604}604}