]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.19.7/i2c-mux-use-proper-dev-when-removing-channel-x-symlinks.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.19.7 / i2c-mux-use-proper-dev-when-removing-channel-x-symlinks.patch
1 From 133778482ec6c8fde69406be380333963627c17a Mon Sep 17 00:00:00 2001
2 From: Wolfram Sang <wsa+renesas@sang-engineering.com>
3 Date: Thu, 23 Apr 2015 10:29:09 +0200
4 Subject: i2c: mux: use proper dev when removing "channel-X" symlinks
5
6 From: Wolfram Sang <wsa+renesas@sang-engineering.com>
7
8 commit 133778482ec6c8fde69406be380333963627c17a upstream.
9
10 Those symlinks are created for the mux_dev, so we need to remove it from
11 there. Currently, it breaks for muxes where the mux_dev is not the device
12 of the parent adapter like this:
13
14 [ 78.234644] WARNING: CPU: 0 PID: 365 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x5c/0x78()
15 [ 78.242438] sysfs: cannot create duplicate filename '/devices/platform/i2cbus@8/channel-0'
16
17 Remove confusing comments while we are here.
18
19 Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
20 Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
21 Fixes: c9449affad2ae0
22 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23
24 ---
25 drivers/i2c/i2c-mux.c | 8 +++++---
26 1 file changed, 5 insertions(+), 3 deletions(-)
27
28 --- a/drivers/i2c/i2c-mux.c
29 +++ b/drivers/i2c/i2c-mux.c
30 @@ -32,8 +32,9 @@ struct i2c_mux_priv {
31 struct i2c_algorithm algo;
32
33 struct i2c_adapter *parent;
34 - void *mux_priv; /* the mux chip/device */
35 - u32 chan_id; /* the channel id */
36 + struct device *mux_dev;
37 + void *mux_priv;
38 + u32 chan_id;
39
40 int (*select)(struct i2c_adapter *, void *mux_priv, u32 chan_id);
41 int (*deselect)(struct i2c_adapter *, void *mux_priv, u32 chan_id);
42 @@ -119,6 +120,7 @@ struct i2c_adapter *i2c_add_mux_adapter(
43
44 /* Set up private adapter data */
45 priv->parent = parent;
46 + priv->mux_dev = mux_dev;
47 priv->mux_priv = mux_priv;
48 priv->chan_id = chan_id;
49 priv->select = select;
50 @@ -203,7 +205,7 @@ void i2c_del_mux_adapter(struct i2c_adap
51 char symlink_name[20];
52
53 snprintf(symlink_name, sizeof(symlink_name), "channel-%u", priv->chan_id);
54 - sysfs_remove_link(&adap->dev.parent->kobj, symlink_name);
55 + sysfs_remove_link(&priv->mux_dev->kobj, symlink_name);
56
57 sysfs_remove_link(&priv->adap.dev.kobj, "mux_device");
58 i2c_del_adapter(adap);