i2c: mux: create symlink to actual mux device
authorWolfram Sang <wsa@the-dreams.de>
Thu, 13 Nov 2014 13:39:55 +0000 (14:39 +0100)
committerWolfram Sang <wsa@the-dreams.de>
Tue, 18 Nov 2014 15:08:41 +0000 (16:08 +0100)
The current implementation creates muxed i2c-<n> busses as immediate
children of their i2c-<n> parent bus. In case of multiple muxes on one
bus, it is impossible to determine which muxed bus comes from which mux.

It could be argued that the parent device should be changed from the
parent adapter to the mux device. This has pros and cons. To improve the
topology, simply add a "mux_device" symlink pointing to the actual
muxing device, so we can distinguish muxed busses. Doing it this way, we
don't break the ABI.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Tested-by: Guenter Roeck <linux@roeck-us.net>
drivers/i2c/i2c-mux.c

index 2d0847b6be626d00ee642daab806aeb259f6eb0b..f246a9f7dd22bdc39b7773f7acd86308185d533c 100644 (file)
@@ -183,6 +183,9 @@ struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
                return NULL;
        }
 
+       WARN(sysfs_create_link(&priv->adap.dev.kobj, &mux_dev->kobj, "mux_device"),
+                              "can't create symlink to mux device\n");
+
        dev_info(&parent->dev, "Added multiplexed i2c bus %d\n",
                 i2c_adapter_id(&priv->adap));
 
@@ -194,6 +197,7 @@ void i2c_del_mux_adapter(struct i2c_adapter *adap)
 {
        struct i2c_mux_priv *priv = adap->algo_data;
 
+       sysfs_remove_link(&priv->adap.dev.kobj, "mux_device");
        i2c_del_adapter(adap);
        kfree(priv);
 }
This page took 0.024694 seconds and 5 git commands to generate.