Message ID | 20190403124019.8947-5-wsa+renesas@sang-engineering.com |
---|---|
State | Deferred |
Headers | show |
Series | i2c: core: introduce atomic transfers | expand |
On 2019-04-03 14:40, Wolfram Sang wrote: > If the parent adapter has atomic_xfer callbacks, populate them for the > mux adapter as well. We can use the same translation function as for the > non-atomic xfer callback. > > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> > --- > drivers/i2c/i2c-mux.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c > index f330690b4125..603252fa1284 100644 > --- a/drivers/i2c/i2c-mux.c > +++ b/drivers/i2c/i2c-mux.c > @@ -310,12 +310,18 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc, > else > priv->algo.master_xfer = __i2c_mux_master_xfer; > } > + if (parent->algo->master_xfer_atomic) > + priv->algo.master_xfer_atomic = priv->algo.master_xfer; > + > if (parent->algo->smbus_xfer) { > if (muxc->mux_locked) > priv->algo.smbus_xfer = i2c_mux_smbus_xfer; > else > priv->algo.smbus_xfer = __i2c_mux_smbus_xfer; > } > + if (parent->algo->smbus_xfer_atomic) > + priv->algo.smbus_xfer_atomic = priv->algo.smbus_xfer; > + > priv->algo.functionality = i2c_mux_functionality; > > /* Now fill out new adapter structure */ > Hmmm, what happens if a driver implements .master_xfer and relies on emulation for SMBus, and then someone implements .smbus_xfer_atomic to handle some corner case at power-down? Then someone hides the power-down device behind a mux. That would end with xfers destined for .smbus_xfer_atomic being emulated by the non-atomic .master_xfer, no? Maybe too weird to care about? I guess the question is if it is allowed to have .master_xfer_atomic but not .master_xfer (and similarly for .smbus_xfer{,_atomic})? Maybe that decision should be made explicit? And perhaps enforced? I don't care deeply about the above though, so feel free to do something about it, or Reviewed-by: Peter Rosin <peda@axentia.se> Cheers, Peter
> I guess the question is if it is allowed to have .master_xfer_atomic > but not .master_xfer (and similarly for .smbus_xfer{,_atomic})? Maybe > that decision should be made explicit? And perhaps enforced? xfer_atomic callbacks are optional. One xfer callback is mandatory. I did a check for falling back to master_xfer_atomic if there is no suitable smbus_xfer_atomic. I will think about the vice-versa case you mentioned. Yet, this is indeed a super corner case, so I prefer to fix this incrementally. > I don't care deeply about the above though, so feel free to do > something about it, or > > Reviewed-by: Peter Rosin <peda@axentia.se> Thanks for the review!
On Wed, Apr 3, 2019 at 3:42 PM Wolfram Sang <wsa+renesas@sang-engineering.com> wrote: > > If the parent adapter has atomic_xfer callbacks, populate them for the > mux adapter as well. We can use the same translation function as for the > non-atomic xfer callback. > Reviewed-by Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> > --- > drivers/i2c/i2c-mux.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c > index f330690b4125..603252fa1284 100644 > --- a/drivers/i2c/i2c-mux.c > +++ b/drivers/i2c/i2c-mux.c > @@ -310,12 +310,18 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc, > else > priv->algo.master_xfer = __i2c_mux_master_xfer; > } > + if (parent->algo->master_xfer_atomic) > + priv->algo.master_xfer_atomic = priv->algo.master_xfer; > + > if (parent->algo->smbus_xfer) { > if (muxc->mux_locked) > priv->algo.smbus_xfer = i2c_mux_smbus_xfer; > else > priv->algo.smbus_xfer = __i2c_mux_smbus_xfer; > } > + if (parent->algo->smbus_xfer_atomic) > + priv->algo.smbus_xfer_atomic = priv->algo.smbus_xfer; > + > priv->algo.functionality = i2c_mux_functionality; > > /* Now fill out new adapter structure */ > -- > 2.11.0 >
diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c index f330690b4125..603252fa1284 100644 --- a/drivers/i2c/i2c-mux.c +++ b/drivers/i2c/i2c-mux.c @@ -310,12 +310,18 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc, else priv->algo.master_xfer = __i2c_mux_master_xfer; } + if (parent->algo->master_xfer_atomic) + priv->algo.master_xfer_atomic = priv->algo.master_xfer; + if (parent->algo->smbus_xfer) { if (muxc->mux_locked) priv->algo.smbus_xfer = i2c_mux_smbus_xfer; else priv->algo.smbus_xfer = __i2c_mux_smbus_xfer; } + if (parent->algo->smbus_xfer_atomic) + priv->algo.smbus_xfer_atomic = priv->algo.smbus_xfer; + priv->algo.functionality = i2c_mux_functionality; /* Now fill out new adapter structure */
If the parent adapter has atomic_xfer callbacks, populate them for the mux adapter as well. We can use the same translation function as for the non-atomic xfer callback. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> --- drivers/i2c/i2c-mux.c | 6 ++++++ 1 file changed, 6 insertions(+)