RE: [PATCH v2 3/4] iio: bmc150: Split the driver into core and i2c

2015-09-09 Thread Tirdea, Irina


> -Original Message-
> From: Markus Pargmann [mailto:m...@pengutronix.de]
> Sent: 20 August, 2015 15:50
> To: Jonathan Cameron
> Cc: Srinivas Pandruvada; Tirdea, Irina; Lars-Peter Clausen; 
> linux-...@vger.kernel.org; linux-kernel@vger.kernel.org;
> ker...@pengutronix.de; Markus Pargmann
> Subject: [PATCH v2 3/4] iio: bmc150: Split the driver into core and i2c
> 
> Signed-off-by: Markus Pargmann 
> ---
>  drivers/iio/accel/Kconfig  |  9 +-
>  drivers/iio/accel/Makefile |  3 +-
>  .../accel/{bmc150-accel.c => bmc150-accel-core.c}  | 95 -
>  drivers/iio/accel/bmc150-accel-i2c.c   | 99 
> ++
>  drivers/iio/accel/bmc150-accel.h   | 21 +
>  5 files changed, 144 insertions(+), 83 deletions(-)
>  rename drivers/iio/accel/{bmc150-accel.c => bmc150-accel-core.c} (95%)
>  create mode 100644 drivers/iio/accel/bmc150-accel-i2c.c
>  create mode 100644 drivers/iio/accel/bmc150-accel.h
> 
> diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig
> index 01dd03d194d1..6da4eb0db57b 100644
> --- a/drivers/iio/accel/Kconfig
> +++ b/drivers/iio/accel/Kconfig
> @@ -19,21 +19,22 @@ config BMA180
> 
>  config BMC150_ACCEL
>   tristate "Bosch BMC150 Accelerometer Driver"
> - depends on I2C
>   select IIO_BUFFER
>   select IIO_TRIGGERED_BUFFER
>   select REGMAP
> - select REGMAP_I2C
> + select BMC150_ACCEL_I2C if I2C
>   help
> Say yes here to build support for the following Bosch accelerometers:
> BMC150, BMI055, BMA250E, BMA222E, BMA255, BMA280.
> 
> -   Currently this only supports the device via an i2c interface.
> -
> This is a combo module with both accelerometer and magnetometer.
> This driver is only implementing accelerometer part, which has
> its own address and register map.
> 
> +config BMC150_ACCEL_I2C
> + tristate
> + select REGMAP_I2C
> +
>  config HID_SENSOR_ACCEL_3D
>   depends on HID_SENSOR_HUB
>   select IIO_BUFFER
> diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile
> index ebd2675b2a02..5ef8bdbad092 100644
> --- a/drivers/iio/accel/Makefile
> +++ b/drivers/iio/accel/Makefile
> @@ -4,7 +4,8 @@
> 
>  # When adding new entries keep the list in alphabetical order
>  obj-$(CONFIG_BMA180) += bma180.o
> -obj-$(CONFIG_BMC150_ACCEL) += bmc150-accel.o
> +obj-$(CONFIG_BMC150_ACCEL) += bmc150-accel-core.o
> +obj-$(CONFIG_BMC150_ACCEL_I2C) += bmc150-accel-i2c.o
>  obj-$(CONFIG_HID_SENSOR_ACCEL_3D) += hid-sensor-accel-3d.o
>  obj-$(CONFIG_KXCJK1013) += kxcjk-1013.o
>  obj-$(CONFIG_KXSD9)  += kxsd9.o
> diff --git a/drivers/iio/accel/bmc150-accel.c 
> b/drivers/iio/accel/bmc150-accel-core.c
> similarity index 95%
> rename from drivers/iio/accel/bmc150-accel.c
> rename to drivers/iio/accel/bmc150-accel-core.c
> index e4a0691d9b88..614cf61f0110 100644
> --- a/drivers/iio/accel/bmc150-accel.c
> +++ b/drivers/iio/accel/bmc150-accel-core.c
> @@ -37,6 +37,8 @@
>  #include 
>  #include 
> 
> +#include "bmc150-accel.h"
> +
>  #define BMC150_ACCEL_DRV_NAME"bmc150_accel"
>  #define BMC150_ACCEL_IRQ_NAME"bmc150_accel_event"
>  #define BMC150_ACCEL_GPIO_NAME   "bmc150_accel_int"
> @@ -187,7 +189,6 @@ enum bmc150_accel_trigger_id {
>  struct bmc150_accel_data {
>   struct regmap *regmap;
>   struct device *dev;
> - int irq;
>   struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS];
>   atomic_t active_intr;
>   struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS];
> @@ -201,6 +202,7 @@ struct bmc150_accel_data {
>   int ev_enable_state;
>   int64_t timestamp, old_timestamp; /* Only used in hw fifo mode. */
>   const struct bmc150_accel_chip_info *chip_info;
> + int irq;
>  };
> 
>  static const struct {
> @@ -1070,15 +1072,6 @@ static const struct iio_chan_spec 
> bmc150_accel_channels[] =
>  static const struct iio_chan_spec bma280_accel_channels[] =
>   BMC150_ACCEL_CHANNELS(14);
> 
> -enum {
> - bmc150,
> - bmi055,
> - bma255,
> - bma250e,
> - bma222e,
> - bma280,
> -};
> -
>  static const struct bmc150_accel_chip_info bmc150_accel_chip_info_tbl[] = {
>   [bmc150] = {
>   .chip_id = 0xFA,
> @@ -1567,36 +1560,22 @@ static const struct iio_buffer_setup_ops 
> bmc150_accel_buffer_ops = {
>   .postdisable = bmc150_accel_buffer_postdisable,
>  };
> 
> -static int bmc150_accel_probe(struct i2c_client *client,
> -   const struct i2c_device_id *id)
> +int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int 
> irq,
> + const char *name, int chip_id, bool block_supported)
>  {
>   struct bmc150_accel_data *data;
>   struct iio_dev *indio_dev;
>   int ret;
> - const char *name = NULL;
> - int chip_id = 0;
> - struct device *dev;
> 
> -   

Re: [PATCH v2 3/4] iio: bmc150: Split the driver into core and i2c

2015-09-01 Thread Srinivas Pandruvada
On Mon, 2015-08-31 at 17:15 +0100, Jonathan Cameron wrote:
> On 20/08/15 13:49, Markus Pargmann wrote:
> > Signed-off-by: Markus Pargmann 
> A couple of little bits inline.  Again would like Srinivas to
> take a quick look at this patch as well.
Once your comments are addressed, it looks fine to me.

Thanks,
Srinivas
> 
> Jonathan
> > ---
> >  drivers/iio/accel/Kconfig  |  9 +-
> >  drivers/iio/accel/Makefile |  3 +-
> >  .../accel/{bmc150-accel.c => bmc150-accel-core.c}  | 95 --
> > ---
> >  drivers/iio/accel/bmc150-accel-i2c.c   | 99 
> > ++
> >  drivers/iio/accel/bmc150-accel.h   | 21 +
> >  5 files changed, 144 insertions(+), 83 deletions(-)
> >  rename drivers/iio/accel/{bmc150-accel.c => bmc150-accel-core.c} 
> > (95%)
> >  create mode 100644 drivers/iio/accel/bmc150-accel-i2c.c
> >  create mode 100644 drivers/iio/accel/bmc150-accel.h
> > 
> > diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig
> > index 01dd03d194d1..6da4eb0db57b 100644
> > --- a/drivers/iio/accel/Kconfig
> > +++ b/drivers/iio/accel/Kconfig
> > @@ -19,21 +19,22 @@ config BMA180
> >  
> >  config BMC150_ACCEL
> > tristate "Bosch BMC150 Accelerometer Driver"
> > -   depends on I2C
> > select IIO_BUFFER
> > select IIO_TRIGGERED_BUFFER
> > select REGMAP
> > -   select REGMAP_I2C
> > +   select BMC150_ACCEL_I2C if I2C
> > help
> >   Say yes here to build support for the following Bosch 
> > accelerometers:
> >   BMC150, BMI055, BMA250E, BMA222E, BMA255, BMA280.
> >  
> > - Currently this only supports the device via an i2c 
> > interface.
> > -
> Well technically this is true until the next patch ;)  I'll let that 
> one go
> though
> >   This is a combo module with both accelerometer and 
> > magnetometer.
> >   This driver is only implementing accelerometer part, 
> > which has
> >   its own address and register map.
> >  
> > +config BMC150_ACCEL_I2C
> > +   tristate
> > +   select REGMAP_I2C
> > +
> >  config HID_SENSOR_ACCEL_3D
> > depends on HID_SENSOR_HUB
> > select IIO_BUFFER
> > diff --git a/drivers/iio/accel/Makefile 
> > b/drivers/iio/accel/Makefile
> > index ebd2675b2a02..5ef8bdbad092 100644
> > --- a/drivers/iio/accel/Makefile
> > +++ b/drivers/iio/accel/Makefile
> > @@ -4,7 +4,8 @@
> >  
> >  # When adding new entries keep the list in alphabetical order
> >  obj-$(CONFIG_BMA180) += bma180.o
> > -obj-$(CONFIG_BMC150_ACCEL) += bmc150-accel.o
> > +obj-$(CONFIG_BMC150_ACCEL) += bmc150-accel-core.o
> > +obj-$(CONFIG_BMC150_ACCEL_I2C) += bmc150-accel-i2c.o
> >  obj-$(CONFIG_HID_SENSOR_ACCEL_3D) += hid-sensor-accel-3d.o
> >  obj-$(CONFIG_KXCJK1013) += kxcjk-1013.o
> >  obj-$(CONFIG_KXSD9)+= kxsd9.o
> > diff --git a/drivers/iio/accel/bmc150-accel.c 
> > b/drivers/iio/accel/bmc150-accel-core.c
> > similarity index 95%
> > rename from drivers/iio/accel/bmc150-accel.c
> > rename to drivers/iio/accel/bmc150-accel-core.c
> > index e4a0691d9b88..614cf61f0110 100644
> > --- a/drivers/iio/accel/bmc150-accel.c
> > +++ b/drivers/iio/accel/bmc150-accel-core.c
> > @@ -37,6 +37,8 @@
> >  #include 
> >  #include 
> >  
> > +#include "bmc150-accel.h"
> > +
> >  #define BMC150_ACCEL_DRV_NAME  "bmc150_accel
> > "
> >  #define BMC150_ACCEL_IRQ_NAME  "bmc150_accel
> > _event"
> >  #define BMC150_ACCEL_GPIO_NAME "bmc150_acce
> > l_int"
> > @@ -187,7 +189,6 @@ enum bmc150_accel_trigger_id {
> >  struct bmc150_accel_data {
> > struct regmap *regmap;
> > struct device *dev;
> > -   int irq;
> > struct bmc150_accel_interrupt 
> > interrupts[BMC150_ACCEL_INTERRUPTS];
> > atomic_t active_intr;
> > struct bmc150_accel_trigger 
> > triggers[BMC150_ACCEL_TRIGGERS];
> > @@ -201,6 +202,7 @@ struct bmc150_accel_data {
> > int ev_enable_state;
> > int64_t timestamp, old_timestamp; /* Only used in hw fifo 
> > mode. */
> > const struct bmc150_accel_chip_info *chip_info;
> > +   int irq;
> Why move the location of this element of the structure?
> 
> >  };
> >  
> >  static const struct {
> > @@ -1070,15 +1072,6 @@ static const struct iio_chan_spec 
> > bmc150_accel_channels[] =
> >  static const struct iio_chan_spec bma280_accel_channels[] =
> > BMC150_ACCEL_CHANNELS(14);
> >  
> > -enum {
> > -   bmc150,
> > -   bmi055,
> > -   bma255,
> > -   bma250e,
> > -   bma222e,
> > -   bma280,
> > -};
> > -
> >  static const struct bmc150_accel_chip_info 
> > bmc150_accel_chip_info_tbl[] = {
> > [bmc150] = {
> > .chip_id = 0xFA,
> > @@ -1567,36 +1560,22 @@ static const struct iio_buffer_setup_ops 
> > bmc150_accel_buffer_ops = {
> > .postdisable = bmc150_accel_buffer_postdisable,
> >  };
> >  
> > -static int bmc150_accel_probe(struct i2c_client *client,
> > - const struct i2c_device_id *id)
> > +int bmc150_accel_core_probe(struct device *dev, s

Re: [PATCH v2 3/4] iio: bmc150: Split the driver into core and i2c

2015-08-31 Thread Jonathan Cameron
On 20/08/15 13:49, Markus Pargmann wrote:
> Signed-off-by: Markus Pargmann 
A couple of little bits inline.  Again would like Srinivas to
take a quick look at this patch as well.

Thanks,

Jonathan
> ---
>  drivers/iio/accel/Kconfig  |  9 +-
>  drivers/iio/accel/Makefile |  3 +-
>  .../accel/{bmc150-accel.c => bmc150-accel-core.c}  | 95 -
>  drivers/iio/accel/bmc150-accel-i2c.c   | 99 
> ++
>  drivers/iio/accel/bmc150-accel.h   | 21 +
>  5 files changed, 144 insertions(+), 83 deletions(-)
>  rename drivers/iio/accel/{bmc150-accel.c => bmc150-accel-core.c} (95%)
>  create mode 100644 drivers/iio/accel/bmc150-accel-i2c.c
>  create mode 100644 drivers/iio/accel/bmc150-accel.h
> 
> diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig
> index 01dd03d194d1..6da4eb0db57b 100644
> --- a/drivers/iio/accel/Kconfig
> +++ b/drivers/iio/accel/Kconfig
> @@ -19,21 +19,22 @@ config BMA180
>  
>  config BMC150_ACCEL
>   tristate "Bosch BMC150 Accelerometer Driver"
> - depends on I2C
>   select IIO_BUFFER
>   select IIO_TRIGGERED_BUFFER
>   select REGMAP
> - select REGMAP_I2C
> + select BMC150_ACCEL_I2C if I2C
>   help
> Say yes here to build support for the following Bosch accelerometers:
> BMC150, BMI055, BMA250E, BMA222E, BMA255, BMA280.
>  
> -   Currently this only supports the device via an i2c interface.
> -
Well technically this is true until the next patch ;)  I'll let that one go
though
> This is a combo module with both accelerometer and magnetometer.
> This driver is only implementing accelerometer part, which has
> its own address and register map.
>  
> +config BMC150_ACCEL_I2C
> + tristate
> + select REGMAP_I2C
> +
>  config HID_SENSOR_ACCEL_3D
>   depends on HID_SENSOR_HUB
>   select IIO_BUFFER
> diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile
> index ebd2675b2a02..5ef8bdbad092 100644
> --- a/drivers/iio/accel/Makefile
> +++ b/drivers/iio/accel/Makefile
> @@ -4,7 +4,8 @@
>  
>  # When adding new entries keep the list in alphabetical order
>  obj-$(CONFIG_BMA180) += bma180.o
> -obj-$(CONFIG_BMC150_ACCEL) += bmc150-accel.o
> +obj-$(CONFIG_BMC150_ACCEL) += bmc150-accel-core.o
> +obj-$(CONFIG_BMC150_ACCEL_I2C) += bmc150-accel-i2c.o
>  obj-$(CONFIG_HID_SENSOR_ACCEL_3D) += hid-sensor-accel-3d.o
>  obj-$(CONFIG_KXCJK1013) += kxcjk-1013.o
>  obj-$(CONFIG_KXSD9)  += kxsd9.o
> diff --git a/drivers/iio/accel/bmc150-accel.c 
> b/drivers/iio/accel/bmc150-accel-core.c
> similarity index 95%
> rename from drivers/iio/accel/bmc150-accel.c
> rename to drivers/iio/accel/bmc150-accel-core.c
> index e4a0691d9b88..614cf61f0110 100644
> --- a/drivers/iio/accel/bmc150-accel.c
> +++ b/drivers/iio/accel/bmc150-accel-core.c
> @@ -37,6 +37,8 @@
>  #include 
>  #include 
>  
> +#include "bmc150-accel.h"
> +
>  #define BMC150_ACCEL_DRV_NAME"bmc150_accel"
>  #define BMC150_ACCEL_IRQ_NAME"bmc150_accel_event"
>  #define BMC150_ACCEL_GPIO_NAME   "bmc150_accel_int"
> @@ -187,7 +189,6 @@ enum bmc150_accel_trigger_id {
>  struct bmc150_accel_data {
>   struct regmap *regmap;
>   struct device *dev;
> - int irq;
>   struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS];
>   atomic_t active_intr;
>   struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS];
> @@ -201,6 +202,7 @@ struct bmc150_accel_data {
>   int ev_enable_state;
>   int64_t timestamp, old_timestamp; /* Only used in hw fifo mode. */
>   const struct bmc150_accel_chip_info *chip_info;
> + int irq;
Why move the location of this element of the structure?

>  };
>  
>  static const struct {
> @@ -1070,15 +1072,6 @@ static const struct iio_chan_spec 
> bmc150_accel_channels[] =
>  static const struct iio_chan_spec bma280_accel_channels[] =
>   BMC150_ACCEL_CHANNELS(14);
>  
> -enum {
> - bmc150,
> - bmi055,
> - bma255,
> - bma250e,
> - bma222e,
> - bma280,
> -};
> -
>  static const struct bmc150_accel_chip_info bmc150_accel_chip_info_tbl[] = {
>   [bmc150] = {
>   .chip_id = 0xFA,
> @@ -1567,36 +1560,22 @@ static const struct iio_buffer_setup_ops 
> bmc150_accel_buffer_ops = {
>   .postdisable = bmc150_accel_buffer_postdisable,
>  };
>  
> -static int bmc150_accel_probe(struct i2c_client *client,
> -   const struct i2c_device_id *id)
> +int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int 
> irq,
> + const char *name, int chip_id, bool block_supported)
>  {
>   struct bmc150_accel_data *data;
>   struct iio_dev *indio_dev;
>   int ret;
> - const char *name = NULL;
> - int chip_id = 0;
> - struct device *dev;
>  
> - indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*da