Message ID | 1455810794-3188-9-git-send-email-daniel.baluta@intel.com |
---|---|
State | Rejected |
Headers | show |
On Thu, Feb 18, 2016 at 05:53:13PM +0200, Daniel Baluta wrote: > From: Adriana Reus <adriana.reus@intel.com> > > Add a check in i2c_mux_master_xfer before calling the select callback. > This is necessary so that NULL callbacks can be safely registered. > > Signed-off-by: Adriana Reus <adriana.reus@intel.com> > Signed-off-by: Daniel Baluta <daniel.baluta@intel.com> Hmm, rather than supporting that in the core, I'd prefer to have the driver pass an empty function instead. Then, in the driver, we can have a comment explaining the special situation.
On Tue, Mar 1, 2016 at 10:30 PM, Wolfram Sang <wsa@the-dreams.de> wrote: > On Thu, Feb 18, 2016 at 05:53:13PM +0200, Daniel Baluta wrote: >> From: Adriana Reus <adriana.reus@intel.com> >> >> Add a check in i2c_mux_master_xfer before calling the select callback. >> This is necessary so that NULL callbacks can be safely registered. >> >> Signed-off-by: Adriana Reus <adriana.reus@intel.com> >> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com> > > Hmm, rather than supporting that in the core, I'd prefer to have the > driver pass an empty function instead. Then, in the driver, we can have > a comment explaining the special situation. Agree. This seems a better idea forcing the user to explain the situation :). -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c index 00fc5b1..74d1700 100644 --- a/drivers/i2c/i2c-mux.c +++ b/drivers/i2c/i2c-mux.c @@ -46,11 +46,12 @@ static int i2c_mux_master_xfer(struct i2c_adapter *adap, { struct i2c_mux_priv *priv = adap->algo_data; struct i2c_adapter *parent = priv->parent; - int ret; + int ret = 0; /* Switch to the right mux port and perform the transfer. */ - ret = priv->select(parent, priv->mux_priv, priv->chan_id); + if (priv->select) + ret = priv->select(parent, priv->mux_priv, priv->chan_id); if (ret >= 0) ret = __i2c_transfer(parent, msgs, num); if (priv->deselect) @@ -66,11 +67,12 @@ static int i2c_mux_smbus_xfer(struct i2c_adapter *adap, { struct i2c_mux_priv *priv = adap->algo_data; struct i2c_adapter *parent = priv->parent; - int ret; + int ret = 0; /* Select the right mux port and perform the transfer. */ - ret = priv->select(parent, priv->mux_priv, priv->chan_id); + if (priv->select) + ret = priv->select(parent, priv->mux_priv, priv->chan_id); if (ret >= 0) ret = parent->algo->smbus_xfer(parent, addr, flags, read_write, command, size, data);