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
576576 if (slave->flags & I2C_CLIENT_TEN)
577577 return -EAFNOSUPPORT;
578578
579− pm_runtime_forbid(rcar_i2c_priv_to_dev(priv));
579+ pm_runtime_get_sync(rcar_i2c_priv_to_dev(priv));
580580
581581 priv->slave = slave;
582582 rcar_i2c_write(priv, ICSAR, slave->addr);
@@ -598,7 +598,7 @@ static int rcar_unreg_slave(struct i2c_client *slave) · 15 unmodified lines
598598
599599 priv->slave = NULL;
600600
601− pm_runtime_allow(rcar_i2c_priv_to_dev(priv));
601+ pm_runtime_put(rcar_i2c_priv_to_dev(priv));
602602
603603 return 0;
604604 }