Hi Guenter,
[BTW, if anyone feels spammed by this series, please drop me a note]
On 2016-01-05 17:42, Guenter Roeck wrote:
> On 01/05/2016 07:57 AM, Peter Rosin wrote:
>> From: Peter Rosin
>>
>> The initial core mux structure starts off small with only the parent
>> adapter pointer, which all muxes have, and a priv pointer for mux
>> driver private data.
>>
>> Add i2c_mux_alloc function to unify the creation of a mux.
>>
>> Where appropriate, pass around the mux core structure instead of the
>> parent adapter or the driver private data.
>>
>> Remove the parent adapter pointer from the driver private data for all
>> mux drivers.
>>
>> Signed-off-by: Peter Rosin
>> ---
>> drivers/i2c/i2c-mux.c| 28 +-
>> drivers/i2c/muxes/i2c-arb-gpio-challenge.c | 24 +--
>> drivers/i2c/muxes/i2c-mux-gpio.c | 20
>> drivers/i2c/muxes/i2c-mux-pca9541.c | 35
>> ++--
>> drivers/i2c/muxes/i2c-mux-pca954x.c | 19 ++-
>> drivers/i2c/muxes/i2c-mux-pinctrl.c | 23 +-
>> drivers/i2c/muxes/i2c-mux-reg.c | 23 ++
>> drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 10 +++-
>> drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h| 1 +
>> drivers/media/dvb-frontends/m88ds3103.c | 10 +++-
>> drivers/media/dvb-frontends/m88ds3103_priv.h | 1 +
>> drivers/media/dvb-frontends/rtl2830.c| 10 +++-
>> drivers/media/dvb-frontends/rtl2830_priv.h | 1 +
>> drivers/media/dvb-frontends/rtl2832.c| 10 +++-
>> drivers/media/dvb-frontends/rtl2832_priv.h | 1 +
>> drivers/media/dvb-frontends/si2168.c | 10 +++-
>> drivers/media/dvb-frontends/si2168_priv.h| 1 +
>> drivers/media/usb/cx231xx/cx231xx-core.c | 3 +++
>> drivers/media/usb/cx231xx/cx231xx-i2c.c | 13 +--
>> drivers/media/usb/cx231xx/cx231xx.h | 2 ++
>> drivers/of/unittest.c| 16 +++--
>> include/linux/i2c-mux.h | 14 ++-
>> 22 files changed, 187 insertions(+), 88 deletions(-)
>>
>> diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
>> index 00fc5b1c7b66..c2163f6b51d5 100644
>> --- a/drivers/i2c/i2c-mux.c
>> +++ b/drivers/i2c/i2c-mux.c
>> @@ -31,8 +31,8 @@
>> struct i2c_mux_priv {
>> struct i2c_adapter adap;
>> struct i2c_algorithm algo;
>> +struct i2c_mux_core *muxc;
>>
>> -struct i2c_adapter *parent;
>> struct device *mux_dev;
>> void *mux_priv;
>> u32 chan_id;
>> @@ -45,7 +45,8 @@ static int i2c_mux_master_xfer(struct i2c_adapter *adap,
>> struct i2c_msg msgs[], int num)
>> {
>> struct i2c_mux_priv *priv = adap->algo_data;
>> -struct i2c_adapter *parent = priv->parent;
>> +struct i2c_mux_core *muxc = priv->muxc;
>> +struct i2c_adapter *parent = muxc->parent;
>> int ret;
>>
>> /* Switch to the right mux port and perform the transfer. */
>> @@ -65,7 +66,8 @@ static int i2c_mux_smbus_xfer(struct i2c_adapter *adap,
>> int size, union i2c_smbus_data *data)
>> {
>> struct i2c_mux_priv *priv = adap->algo_data;
>> -struct i2c_adapter *parent = priv->parent;
>> +struct i2c_mux_core *muxc = priv->muxc;
>> +struct i2c_adapter *parent = muxc->parent;
>> int ret;
>>
>> /* Select the right mux port and perform the transfer. */
>> @@ -84,7 +86,7 @@ static int i2c_mux_smbus_xfer(struct i2c_adapter *adap,
>> static u32 i2c_mux_functionality(struct i2c_adapter *adap)
>> {
>> struct i2c_mux_priv *priv = adap->algo_data;
>> -struct i2c_adapter *parent = priv->parent;
>> +struct i2c_adapter *parent = priv->muxc->parent;
>>
>> return parent->algo->functionality(parent);
>> }
>> @@ -102,7 +104,20 @@ static unsigned int i2c_mux_parent_classes(struct
>> i2c_adapter *parent)
>> return class;
>> }
>>
>> -struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
>> +struct i2c_mux_core *i2c_mux_alloc(struct device *dev, int sizeof_priv)
>> +{
>> +struct i2c_mux_core *muxc;
>> +
>> +muxc = devm_kzalloc(dev, sizeof(*muxc) + sizeof_priv, GFP_KERNEL);
>> +if (!muxc)
>> +return NULL;
>> +if (sizeof_priv)
>> +muxc->priv = muxc + 1;
>> +return muxc;
>> +}
>> +EXPORT_SYMBOL_GPL(i2c_mux_alloc);
>> +
>> +struct i2c_adapter *i2c_add_mux_adapter(struct i2c_mux_core *muxc,
>> struct device *mux_dev,
>> void *mux_priv, u32 force_nr, u32 chan_id,
>> unsigned int class,
>> @@ -111,6 +126,7 @@ struct i2c_adapter *i2c_add_mux_adapter(struct
>> i2c_adapter *parent,
>> int (*deselect) (struct i2c_adapter *,
>>void *, u32))
>> {
>> +struct i2c_adapter *parent = muxc->parent;
>> struct i2c_mux_priv