Skip to content

Commit 1337784

Browse files
Wolfram SangWolfram Sang
authored andcommitted
i2c: mux: use proper dev when removing "channel-X" symlinks
Those symlinks are created for the mux_dev, so we need to remove it from there. Currently, it breaks for muxes where the mux_dev is not the device of the parent adapter like this: [ 78.234644] WARNING: CPU: 0 PID: 365 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x5c/0x78() [ 78.242438] sysfs: cannot create duplicate filename '/devices/platform/i2cbus@8/channel-0' Remove confusing comments while we are here. Signed-off-by: Wolfram Sang <[email protected]> Signed-off-by: Wolfram Sang <[email protected]> Fixes: c9449af Cc: [email protected]
1 parent 4c8979b commit 1337784

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/i2c/i2c-mux.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ struct i2c_mux_priv {
3232
struct i2c_algorithm algo;
3333

3434
struct i2c_adapter *parent;
35-
void *mux_priv; /* the mux chip/device */
36-
u32 chan_id; /* the channel id */
35+
struct device *mux_dev;
36+
void *mux_priv;
37+
u32 chan_id;
3738

3839
int (*select)(struct i2c_adapter *, void *mux_priv, u32 chan_id);
3940
int (*deselect)(struct i2c_adapter *, void *mux_priv, u32 chan_id);
@@ -119,6 +120,7 @@ struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
119120

120121
/* Set up private adapter data */
121122
priv->parent = parent;
123+
priv->mux_dev = mux_dev;
122124
priv->mux_priv = mux_priv;
123125
priv->chan_id = chan_id;
124126
priv->select = select;
@@ -203,7 +205,7 @@ void i2c_del_mux_adapter(struct i2c_adapter *adap)
203205
char symlink_name[20];
204206

205207
snprintf(symlink_name, sizeof(symlink_name), "channel-%u", priv->chan_id);
206-
sysfs_remove_link(&adap->dev.parent->kobj, symlink_name);
208+
sysfs_remove_link(&priv->mux_dev->kobj, symlink_name);
207209

208210
sysfs_remove_link(&priv->adap.dev.kobj, "mux_device");
209211
i2c_del_adapter(adap);

0 commit comments

Comments
 (0)