Re: [PATCH] i2c: mux: create proper topology in sysfs

Guenter Roeck
2014-11-04T14:46:49Z

On 11/04/2014 06:33 AM, Wolfram Sang wrote:
>
>> Ok, I think I know the problem. In my case, the parent adapter
>> and the mux device are the same (since both are on the same chip
>> and the mux is really merged into the i2c controller).
>>
>> I'll have to figure out how to fix that.
>
> Maybe something like this on top helps already? It skips link creation
> if the parent device is the parent i2c adapter. We should have this
> anyway...
>

I'll test tonight ... I'll be in meetings all day :-(.

Guenter

> --- a/drivers/i2c/i2c-mux.c
> +++ b/drivers/i2c/i2c-mux.c
> @@ -184,8 +184,11 @@ struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
> return NULL;
> }
>
> - WARN(sysfs_create_link(&parent->dev.kobj, &priv->adap.dev.kobj, priv->adap.dev.kobj.name),
> - "can't create compatibility link for old mux name scheme\n");
> + /* If necessary, create symlink to match old mux name scheme */
> + if (mux_dev != &parent->dev)
> + WARN(sysfs_create_link(&parent->dev.kobj, &priv->adap.dev.kobj,
> + dev_name(&priv->adap.dev)),
> + "can't create compatibility link for old mux name scheme\n");
>
> dev_info(&parent->dev, "Added multiplexed i2c bus %d\n",
> i2c_adapter_id(&priv->adap));
> @@ -198,7 +201,8 @@ void i2c_del_mux_adapter(struct i2c_adapter *adap)
> {
> struct i2c_mux_priv *priv = adap->algo_data;
>
> - sysfs_remove_link(&priv->parent->dev.kobj, adap->dev.kobj.name);
> + if (priv->adap.dev.parent != &priv->parent->dev)
> + sysfs_remove_link(&priv->parent->dev.kobj, dev_name(&adap->dev));
> i2c_del_adapter(adap);
> kfree(priv);
> }
>