From: Gerlando Falauto <[email protected]> This makes the topology clearer. For instance, by adding a pca9547 device with address 0x70 to bus i2c-0, you get:
/sys/class/i2c-dev/i2c-0/device/0-0070/channel-0 -> i2c-1 ... /sys/class/i2c-dev/i2c-0/device/0-0070/channel-7 -> i2c-8 Signed-off-by: Gerlando Falauto <[email protected]> [wsa: simplified sysfs-usage and fixed format string usage] Signed-off-by: Wolfram Sang <[email protected]> Cc: Jean Delvare <[email protected]> Cc: Guenter Roeck <[email protected]> Cc: Martin Belanger <[email protected]> Cc: Rodolfo Giometti <[email protected]> Cc: Michael Lawnick <[email protected]> Cc: Jeroen De Wachter <[email protected]> --- This should also make it easier for applications to handle the topology of muxes without breaking anything. Please give opinions if it really helps. I don't use muxes myself. drivers/i2c/i2c-mux.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c index d05208232b07..f43273a92069 100644 --- a/drivers/i2c/i2c-mux.c +++ b/drivers/i2c/i2c-mux.c @@ -110,6 +110,7 @@ struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent, void *, u32)) { struct i2c_mux_priv *priv; + char symlink_name[20]; int ret; priv = kzalloc(sizeof(struct i2c_mux_priv), GFP_KERNEL); @@ -189,6 +190,9 @@ struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent, dev_name(&priv->adap.dev)), "can't create compatibility link for old mux name scheme\n"); + snprintf(symlink_name, sizeof(symlink_name), "channel-%u", chan_id); + WARN(sysfs_create_link(&mux_dev->kobj, &priv->adap.dev.kobj, symlink_name), + "can't create symlink for channel\n"); dev_info(&parent->dev, "Added multiplexed i2c bus %d\n", i2c_adapter_id(&priv->adap)); @@ -199,6 +203,10 @@ EXPORT_SYMBOL_GPL(i2c_add_mux_adapter); void i2c_del_mux_adapter(struct i2c_adapter *adap) { struct i2c_mux_priv *priv = adap->algo_data; + char symlink_name[20]; + + snprintf(symlink_name, sizeof(symlink_name), "channel-%u", priv->chan_id); + sysfs_remove_link(&adap->dev.parent->kobj, symlink_name); if (adap->dev.parent != &priv->parent->dev) sysfs_remove_link(&priv->parent->dev.kobj, dev_name(&adap->dev)); -- 2.1.1 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
