Re: [PATCH v2 3/8] i2c-mux: move the slave side adapter management to i2c_mux_core

2016-01-05 Thread kbuild test robot
Hi Peter,

[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on v4.4-rc8 next-20160105]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improving the system]

url:
https://github.com/0day-ci/linux/commits/Peter-Rosin/i2c-mux-cleanup-and-locking-update/20160106-000205
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux i2c/for-next
config: i386-randconfig-s1-201601 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c: In function 
'inv_mpu_acpi_create_mux_client':
>> drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c:185:37: error: 'struct 
>> inv_mpu6050_state' has no member named 'mux_adapter'
  st->mux_client = i2c_new_device(st->mux_adapter, );
^

vim +185 drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c

a35c5d1a Srinivas Pandruvada 2015-01-30  179
*name = '\0';
a35c5d1a Srinivas Pandruvada 2015-01-30  180
strlcat(info.type, "-client",
a35c5d1a Srinivas Pandruvada 2015-01-30  181
sizeof(info.type));
a35c5d1a Srinivas Pandruvada 2015-01-30  182} else
a35c5d1a Srinivas Pandruvada 2015-01-30  183return 
0; /* no secondary addr, which is OK */
a35c5d1a Srinivas Pandruvada 2015-01-30  184}
a35c5d1a Srinivas Pandruvada 2015-01-30 @185st->mux_client = 
i2c_new_device(st->mux_adapter, );
a35c5d1a Srinivas Pandruvada 2015-01-30  186if (!st->mux_client)
a35c5d1a Srinivas Pandruvada 2015-01-30  187return -ENODEV;
a35c5d1a Srinivas Pandruvada 2015-01-30  188  

:: The code at line 185 was first introduced by commit
:: a35c5d1aa96aa6cc70e91786cbe9be4db23f8f4a iio: imu: inv_mpu6050: Create 
mux clients for ACPI

:: TO: Srinivas Pandruvada 
:: CC: Jonathan Cameron 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH v2 3/8] i2c-mux: move the slave side adapter management to i2c_mux_core

2016-01-05 Thread Peter Rosin
Hi,

This should fix it (I'm not sending a v3 right away).

Cheers,
Peter

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c 
b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
index 1c982a56acd5..5de993deca7e 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
@@ -16,6 +16,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "inv_mpu_iio.h"
@@ -182,7 +183,7 @@ int inv_mpu_acpi_create_mux_client(struct inv_mpu6050_state 
*st)
} else
return 0; /* no secondary addr, which is OK */
}
-   st->mux_client = i2c_new_device(st->mux_adapter, );
+   st->mux_client = i2c_new_device(st->muxc->adapter[0], );
if (!st->mux_client)
return -ENODEV;
 
-- 


On 2016-01-05 17:49, kbuild test robot wrote:
> Hi Peter,
> 
> [auto build test ERROR on wsa/i2c/for-next]
> [also build test ERROR on v4.4-rc8 next-20160105]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improving the system]
> 
> url:
> https://github.com/0day-ci/linux/commits/Peter-Rosin/i2c-mux-cleanup-and-locking-update/20160106-000205
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux i2c/for-next
> config: i386-randconfig-s1-201601 (attached as .config)
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386 
> 
> All errors (new ones prefixed by >>):
> 
>drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c: In function 
> 'inv_mpu_acpi_create_mux_client':
>>> drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c:185:37: error: 'struct 
>>> inv_mpu6050_state' has no member named 'mux_adapter'
>   st->mux_client = i2c_new_device(st->mux_adapter, );
> ^
> 
> vim +185 drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
> 
> a35c5d1a Srinivas Pandruvada 2015-01-30  179  
> *name = '\0';
> a35c5d1a Srinivas Pandruvada 2015-01-30  180  
> strlcat(info.type, "-client",
> a35c5d1a Srinivas Pandruvada 2015-01-30  181  
> sizeof(info.type));
> a35c5d1a Srinivas Pandruvada 2015-01-30  182  } else
> a35c5d1a Srinivas Pandruvada 2015-01-30  183  
> return 0; /* no secondary addr, which is OK */
> a35c5d1a Srinivas Pandruvada 2015-01-30  184  }
> a35c5d1a Srinivas Pandruvada 2015-01-30 @185  st->mux_client 
> = i2c_new_device(st->mux_adapter, );
> a35c5d1a Srinivas Pandruvada 2015-01-30  186  if 
> (!st->mux_client)
> a35c5d1a Srinivas Pandruvada 2015-01-30  187  return 
> -ENODEV;
> a35c5d1a Srinivas Pandruvada 2015-01-30  188  
> 
> :: The code at line 185 was first introduced by commit
> :: a35c5d1aa96aa6cc70e91786cbe9be4db23f8f4a iio: imu: inv_mpu6050: Create 
> mux clients for ACPI
> 
> :: TO: Srinivas Pandruvada 
> :: CC: Jonathan Cameron 
> 
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 3/8] i2c-mux: move the slave side adapter management to i2c_mux_core

2016-01-05 Thread Peter Rosin
Ouch, this got lost in the shuffle, don't bother testing without it.
It will be included in v3.

[the reason is that my test hw relies on vendor patches, and I have to
rebase before sending. I.e., I can only compile-test the stuff I'm
actually sending out. Inconvenient.]

diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
index c4d4b14a5399..c5a5886d8be1 100644
--- a/drivers/i2c/i2c-mux.c
+++ b/drivers/i2c/i2c-mux.c
@@ -215,10 +215,12 @@ int i2c_mux_reserve_adapters(struct i2c_mux_core *muxc, 
int adapters)
if (!adapter)
return -ENOMEM;
 
-   memcpy(adapter, muxc->adapter,
-  muxc->max_adapters * sizeof(*adapter));
+   if (muxc->adapter) {
+   memcpy(adapter, muxc->adapter,
+  muxc->max_adapters * sizeof(*adapter));
+   devm_kfree(muxc->dev, muxc->adapter);
+   }
 
-   devm_kfree(muxc->dev, muxc->adapter);
muxc->adapter = adapter;
muxc->max_adapters = adapters;
return 0;
-- 


On 2016-01-05 16:57, Peter Rosin wrote:
> From: Peter Rosin 
> 
> All muxes have slave side adapters, many have some arbitrary number of
> them. Handle this in the mux core, so that drivers are simplified.
> 
> Add i2c_mux_reserve_adapter that can be used when it is known in advance
> how many child adapters that is to be added. This avoids reallocating
> memory.
> 
> Drop i2c_del_mux_adapter and replace it with i2c_del_mux_adapters, since
> no mux driver is dynamically deleting individual child adapters anyway.
> 
> Signed-off-by: Peter Rosin 
> ---
>  drivers/i2c/i2c-mux.c| 71 
> ++--
>  drivers/i2c/muxes/i2c-arb-gpio-challenge.c   | 10 ++--
>  drivers/i2c/muxes/i2c-mux-gpio.c | 23 +++--
>  drivers/i2c/muxes/i2c-mux-pca9541.c  | 13 ++---
>  drivers/i2c/muxes/i2c-mux-pca954x.c  | 26 --
>  drivers/i2c/muxes/i2c-mux-pinctrl.c  | 27 +++
>  drivers/i2c/muxes/i2c-mux-reg.c  | 28 ---
>  drivers/iio/imu/inv_mpu6050/inv_mpu_core.c   | 12 ++---
>  drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h|  1 -
>  drivers/media/dvb-frontends/m88ds3103.c  | 11 ++---
>  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| 11 ++---
>  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  | 26 +-
>  drivers/media/usb/cx231xx/cx231xx.h  |  2 +-
>  drivers/of/unittest.c| 28 ---
>  include/linux/i2c-mux.h  | 15 --
>  22 files changed, 149 insertions(+), 182 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
> index 6c5cb9f7649b..7ba0308537a8 100644
> --- a/drivers/i2c/i2c-mux.c
> +++ b/drivers/i2c/i2c-mux.c
> @@ -99,6 +99,29 @@ static unsigned int i2c_mux_parent_classes(struct 
> i2c_adapter *parent)
>   return class;
>  }
>  
> +int i2c_mux_reserve_adapters(struct i2c_mux_core *muxc, int adapters)
> +{
> + struct i2c_adapter **adapter;
> +
> + if (adapters <= muxc->max_adapters)
> + return 0;
> +
> + adapter = devm_kmalloc_array(muxc->dev,
> +  adapters, sizeof(*adapter),
> +  GFP_KERNEL);
> + if (!adapter)
> + return -ENOMEM;
> +
> + memcpy(adapter, muxc->adapter,
> +muxc->max_adapters * sizeof(*adapter));
> +
> + devm_kfree(muxc->dev, muxc->adapter);
> + muxc->adapter = adapter;
> + muxc->max_adapters = adapters;
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(i2c_mux_reserve_adapters);
> +
>  struct i2c_mux_core *i2c_mux_alloc(struct device *dev, int sizeof_priv)
>  {
>   struct i2c_mux_core *muxc;
> @@ -113,19 +136,29 @@ struct i2c_mux_core *i2c_mux_alloc(struct device *dev, 
> int sizeof_priv)
>  }
>  EXPORT_SYMBOL_GPL(i2c_mux_alloc);
>  
> -struct i2c_adapter *i2c_add_mux_adapter(struct i2c_mux_core *muxc,
> - struct device *mux_dev,
> - u32 force_nr, u32 chan_id,
> - unsigned int class)
> +int i2c_add_mux_adapter(struct i2c_mux_core *muxc,
> + struct device *mux_dev,
> + u32 force_nr, u32 chan_id,
> + unsigned int class)
>  {
>   struct i2c_adapter *parent = muxc->parent;
>   struct i2c_mux_priv *priv;
>   char symlink_name[20];
>   int ret;
>  
> + if (muxc->adapters >= muxc->max_adapters) {
> + int new_max = 2 * muxc->max_adapters;
> +
> + if (!new_max)
> +