@@ -87,6 +87,7 @@ static u32 i2c_mux_functionality(struct i2c_adapter *adap)
}
struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
+ struct device *parent_device,
void *mux_dev, u32 force_nr, u32 chan_id,
int (*select) (struct i2c_adapter *,
void *, u32),
@@ -122,7 +123,7 @@ struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
priv->adap.owner = THIS_MODULE;
priv->adap.algo = &priv->algo;
priv->adap.algo_data = priv;
- priv->adap.dev.parent = &parent->dev;
+ priv->adap.dev.parent = parent_device;
if (force_nr) {
priv->adap.nr = force_nr;
@@ -105,7 +105,7 @@ static int __devinit gpiomux_probe(struct platform_device *pdev)
for (i = 0; i < pdata->n_values; i++) {
u32 nr = pdata->base_nr ? (pdata->base_nr + i) : 0;
- mux->adap[i] = i2c_add_mux_adapter(parent, mux, nr, i,
+ mux->adap[i] = i2c_add_mux_adapter(parent, &pdev->dev, mux, nr, i,
gpiomux_select, deselect);
if (!mux->adap[i]) {
ret = -ENODEV;
@@ -353,7 +353,7 @@ static int pca9541_probe(struct i2c_client *client,
force = 0;
if (pdata)
force = pdata->modes[0].adap_id;
- data->mux_adap = i2c_add_mux_adapter(adap, client, force, 0,
+ data->mux_adap = i2c_add_mux_adapter(adap, &client->dev, client, force, 0,
pca9541_select_chan,
pca9541_release_chan);
@@ -226,7 +226,7 @@ static int pca954x_probe(struct i2c_client *client,
}
data->virt_adaps[num] =
- i2c_add_mux_adapter(adap, client,
+ i2c_add_mux_adapter(adap, &client->dev, client,
force, num, pca954x_select_chan,
(pdata && pdata->modes[num].deselect_on_exit)
? pca954x_deselect_mux : NULL);
@@ -33,6 +33,7 @@
* mux control.
*/
struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
+ struct device *parent_device,
void *mux_dev, u32 force_nr, u32 chan_id,
int (*select) (struct i2c_adapter *,
void *mux_dev, u32 chan_id),
Current implementation creates i2c-<n> busses as immediate children of their i2c-<n> parent bus. Change the topology so that they are created under the corresponding mux device. This way, multiple muxes on the same segment can coexist and children busses are grouped accordingly. So for instance, by adding a pca9547 device with address 0x70 to bus i2c-0, instead of: /sys/class/i2c-dev/i2c-0/device/i2c-1 ... /sys/class/i2c-dev/i2c-0/device/i2c-8 you get: /sys/class/i2c-dev/i2c-0/device/0-0070/i2c-1 ... /sys/class/i2c-dev/i2c-0/device/0-0070/i2c-8 Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com> --- drivers/i2c/i2c-mux.c | 3 ++- drivers/i2c/muxes/gpio-i2cmux.c | 2 +- drivers/i2c/muxes/pca9541.c | 2 +- drivers/i2c/muxes/pca954x.c | 2 +- include/linux/i2c-mux.h | 1 + 5 files changed, 6 insertions(+), 4 deletions(-)