diff mbox series

[v2,7/7] iio: pressure bmp280: Move bmp085 interrupt to new configuration

Message ID 20240725231039.614536-8-vassilisamir@gmail.com (mailing list archive)
State Changes Requested
Headers show
Series pressure: bmp280: Minor cleanup and interrupt support | expand

Commit Message

Vasileios Amoiridis July 25, 2024, 11:10 p.m. UTC
This commit intends to add the old BMP085 sensor to the new IRQ interface
of the sensor consistence. No functional changes intended.

The BMP085 sensor is equivalent with the BMP180 with the only difference of
BMP085 having an extra interrupt pin to inform about an End of Conversion.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
---
 drivers/iio/pressure/bmp280-core.c | 72 +++++++++++++++++++++++-------
 drivers/iio/pressure/bmp280-i2c.c  |  4 +-
 drivers/iio/pressure/bmp280-spi.c  |  4 +-
 drivers/iio/pressure/bmp280.h      |  1 +
 4 files changed, 60 insertions(+), 21 deletions(-)

Comments

kernel test robot July 26, 2024, 10:41 a.m. UTC | #1
Hi Vasileios,

kernel test robot noticed the following build errors:

[auto build test ERROR on 47ee461357f9da5a35d5f43527b7804a6a5744cb]

url:    https://github.com/intel-lab-lkp/linux/commits/Vasileios-Amoiridis/iio-pressure-bmp280-Use-bulk-read-for-humidity-calibration-data/20240726-071712
base:   47ee461357f9da5a35d5f43527b7804a6a5744cb
patch link:    https://lore.kernel.org/r/20240725231039.614536-8-vassilisamir%40gmail.com
patch subject: [PATCH v2 7/7] iio: pressure bmp280: Move bmp085 interrupt to new configuration
config: i386-buildonly-randconfig-005-20240726 (https://download.01.org/0day-ci/archive/20240726/202407261832.zSKjAoTj-lkp@intel.com/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240726/202407261832.zSKjAoTj-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202407261832.zSKjAoTj-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/iio/pressure/bmp280-core.c:3146:12: error: initializer element is not constant
     .id_reg = bmp180_chip_info.id_reg,
               ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3146:12: note: (near initialization for 'bmp085_chip_info.id_reg')
   drivers/iio/pressure/bmp280-core.c:3147:13: error: initializer element is not constant
     .chip_id = bmp180_chip_info.chip_id,
                ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3147:13: note: (near initialization for 'bmp085_chip_info.chip_id')
   drivers/iio/pressure/bmp280-core.c:3148:17: error: initializer element is not constant
     .num_chip_id = bmp180_chip_info.num_chip_id,
                    ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3148:17: note: (near initialization for 'bmp085_chip_info.num_chip_id')
   drivers/iio/pressure/bmp280-core.c:3149:19: error: initializer element is not constant
     .regmap_config = bmp180_chip_info.regmap_config,
                      ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3149:19: note: (near initialization for 'bmp085_chip_info.regmap_config')
   drivers/iio/pressure/bmp280-core.c:3150:19: error: initializer element is not constant
     .start_up_time = bmp180_chip_info.start_up_time,
                      ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3150:19: note: (near initialization for 'bmp085_chip_info.start_up_time')
   drivers/iio/pressure/bmp280-core.c:3151:14: error: initializer element is not constant
     .channels = bmp180_chip_info.channels,
                 ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3151:14: note: (near initialization for 'bmp085_chip_info.channels')
   drivers/iio/pressure/bmp280-core.c:3152:18: error: initializer element is not constant
     .num_channels = bmp180_chip_info.num_channels,
                     ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3152:18: note: (near initialization for 'bmp085_chip_info.num_channels')
   drivers/iio/pressure/bmp280-core.c:3153:22: error: initializer element is not constant
     .avail_scan_masks = bmp180_chip_info.avail_scan_masks,
                         ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3153:22: note: (near initialization for 'bmp085_chip_info.avail_scan_masks')
   drivers/iio/pressure/bmp280-core.c:3155:29: error: initializer element is not constant
     .oversampling_temp_avail = bmp180_chip_info.oversampling_temp_avail,
                                ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3155:29: note: (near initialization for 'bmp085_chip_info.oversampling_temp_avail')
   drivers/iio/pressure/bmp280-core.c:3157:3: error: initializer element is not constant
      bmp180_chip_info.num_oversampling_temp_avail,
      ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3157:3: note: (near initialization for 'bmp085_chip_info.num_oversampling_temp_avail')
   drivers/iio/pressure/bmp280-core.c:3158:31: error: initializer element is not constant
     .oversampling_temp_default = bmp180_chip_info.oversampling_temp_default,
                                  ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3158:31: note: (near initialization for 'bmp085_chip_info.oversampling_temp_default')
   drivers/iio/pressure/bmp280-core.c:3160:30: error: initializer element is not constant
     .oversampling_press_avail = bmp180_chip_info.oversampling_press_avail,
                                 ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3160:30: note: (near initialization for 'bmp085_chip_info.oversampling_press_avail')
   drivers/iio/pressure/bmp280-core.c:3162:3: error: initializer element is not constant
      bmp180_chip_info.num_oversampling_press_avail,
      ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3162:3: note: (near initialization for 'bmp085_chip_info.num_oversampling_press_avail')
   drivers/iio/pressure/bmp280-core.c:3164:3: error: initializer element is not constant
      bmp180_chip_info.oversampling_press_default,
      ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3164:3: note: (near initialization for 'bmp085_chip_info.oversampling_press_default')
   drivers/iio/pressure/bmp280-core.c:3166:17: error: initializer element is not constant
     .temp_coeffs = bmp180_chip_info.temp_coeffs,
                    ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3166:17: note: (near initialization for 'bmp085_chip_info.temp_coeffs')
   drivers/iio/pressure/bmp280-core.c:3167:22: error: initializer element is not constant
     .temp_coeffs_type = bmp180_chip_info.temp_coeffs_type,
                         ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3167:22: note: (near initialization for 'bmp085_chip_info.temp_coeffs_type')
   drivers/iio/pressure/bmp280-core.c:3168:18: error: initializer element is not constant
     .press_coeffs = bmp180_chip_info.press_coeffs,
                     ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3168:18: note: (near initialization for 'bmp085_chip_info.press_coeffs')
   drivers/iio/pressure/bmp280-core.c:3169:23: error: initializer element is not constant
     .press_coeffs_type = bmp180_chip_info.press_coeffs_type,
                          ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3169:23: note: (near initialization for 'bmp085_chip_info.press_coeffs_type')
   drivers/iio/pressure/bmp280-core.c:3171:17: error: initializer element is not constant
     .chip_config = bmp180_chip_info.chip_config,
                    ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3171:17: note: (near initialization for 'bmp085_chip_info.chip_config')
   drivers/iio/pressure/bmp280-core.c:3172:15: error: initializer element is not constant
     .read_temp = bmp180_chip_info.read_temp,
                  ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3172:15: note: (near initialization for 'bmp085_chip_info.read_temp')
   drivers/iio/pressure/bmp280-core.c:3173:16: error: initializer element is not constant
     .read_press = bmp180_chip_info.read_press,
                   ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3173:16: note: (near initialization for 'bmp085_chip_info.read_press')
   drivers/iio/pressure/bmp280-core.c:3174:16: error: initializer element is not constant
     .read_calib = bmp180_chip_info.read_calib,
                   ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3174:16: note: (near initialization for 'bmp085_chip_info.read_calib')
   drivers/iio/pressure/bmp280-core.c:3175:14: error: initializer element is not constant
     .set_mode = bmp180_chip_info.set_mode,
                 ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3175:14: note: (near initialization for 'bmp085_chip_info.set_mode')
   drivers/iio/pressure/bmp280-core.c:3176:15: error: initializer element is not constant
     .wait_conv = bmp180_chip_info.wait_conv,
                  ^~~~~~~~~~~~~~~~
   drivers/iio/pressure/bmp280-core.c:3176:15: note: (near initialization for 'bmp085_chip_info.wait_conv')


vim +3146 drivers/iio/pressure/bmp280-core.c

  3144	
  3145	const struct bmp280_chip_info bmp085_chip_info = {
> 3146		.id_reg = bmp180_chip_info.id_reg,
  3147		.chip_id = bmp180_chip_info.chip_id,
  3148		.num_chip_id = bmp180_chip_info.num_chip_id,
  3149		.regmap_config = bmp180_chip_info.regmap_config,
  3150		.start_up_time = bmp180_chip_info.start_up_time,
  3151		.channels = bmp180_chip_info.channels,
  3152		.num_channels = bmp180_chip_info.num_channels,
  3153		.avail_scan_masks = bmp180_chip_info.avail_scan_masks,
  3154	
  3155		.oversampling_temp_avail = bmp180_chip_info.oversampling_temp_avail,
  3156		.num_oversampling_temp_avail =
  3157			bmp180_chip_info.num_oversampling_temp_avail,
  3158		.oversampling_temp_default = bmp180_chip_info.oversampling_temp_default,
  3159	
  3160		.oversampling_press_avail = bmp180_chip_info.oversampling_press_avail,
  3161		.num_oversampling_press_avail =
  3162			bmp180_chip_info.num_oversampling_press_avail,
  3163		.oversampling_press_default =
  3164			bmp180_chip_info.oversampling_press_default,
  3165	
  3166		.temp_coeffs = bmp180_chip_info.temp_coeffs,
  3167		.temp_coeffs_type = bmp180_chip_info.temp_coeffs_type,
  3168		.press_coeffs = bmp180_chip_info.press_coeffs,
  3169		.press_coeffs_type = bmp180_chip_info.press_coeffs_type,
  3170	
  3171		.chip_config = bmp180_chip_info.chip_config,
  3172		.read_temp = bmp180_chip_info.read_temp,
  3173		.read_press = bmp180_chip_info.read_press,
  3174		.read_calib = bmp180_chip_info.read_calib,
  3175		.set_mode = bmp180_chip_info.set_mode,
  3176		.wait_conv = bmp180_chip_info.wait_conv,
  3177	
  3178		.trigger_probe = bmp085_trigger_probe,
  3179		.trigger_handler = bmp180_trigger_handler,
  3180	};
  3181	EXPORT_SYMBOL_NS(bmp085_chip_info, IIO_BMP280);
  3182
kernel test robot July 27, 2024, 12:29 a.m. UTC | #2
Hi Vasileios,

kernel test robot noticed the following build errors:

[auto build test ERROR on 47ee461357f9da5a35d5f43527b7804a6a5744cb]

url:    https://github.com/intel-lab-lkp/linux/commits/Vasileios-Amoiridis/iio-pressure-bmp280-Use-bulk-read-for-humidity-calibration-data/20240726-071712
base:   47ee461357f9da5a35d5f43527b7804a6a5744cb
patch link:    https://lore.kernel.org/r/20240725231039.614536-8-vassilisamir%40gmail.com
patch subject: [PATCH v2 7/7] iio: pressure bmp280: Move bmp085 interrupt to new configuration
config: s390-randconfig-002-20240726 (https://download.01.org/0day-ci/archive/20240727/202407270859.izJnB7MZ-lkp@intel.com/config)
compiler: clang version 16.0.6 (https://github.com/llvm/llvm-project 7cbf1a2591520c2491aa35339f227775f4d3adf6)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240727/202407270859.izJnB7MZ-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202407270859.izJnB7MZ-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from drivers/iio/pressure/bmp280-core.c:36:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:14:
   In file included from arch/s390/include/asm/io.h:93:
   include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                             ^
   include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
   #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
                                                        ^
   In file included from drivers/iio/pressure/bmp280-core.c:36:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:14:
   In file included from arch/s390/include/asm/io.h:93:
   include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
                                                             ^
   include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
   #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
                                                        ^
   In file included from drivers/iio/pressure/bmp280-core.c:36:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:14:
   In file included from arch/s390/include/asm/io.h:93:
   include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsb(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsw(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsl(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesb(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesw(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesl(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
>> drivers/iio/pressure/bmp280-core.c:3146:29: error: initializer element is not a compile-time constant
           .id_reg = bmp180_chip_info.id_reg,
                     ~~~~~~~~~~~~~~~~~^~~~~~
   12 warnings and 1 error generated.


vim +3146 drivers/iio/pressure/bmp280-core.c

  3144	
  3145	const struct bmp280_chip_info bmp085_chip_info = {
> 3146		.id_reg = bmp180_chip_info.id_reg,
  3147		.chip_id = bmp180_chip_info.chip_id,
  3148		.num_chip_id = bmp180_chip_info.num_chip_id,
  3149		.regmap_config = bmp180_chip_info.regmap_config,
  3150		.start_up_time = bmp180_chip_info.start_up_time,
  3151		.channels = bmp180_chip_info.channels,
  3152		.num_channels = bmp180_chip_info.num_channels,
  3153		.avail_scan_masks = bmp180_chip_info.avail_scan_masks,
  3154	
  3155		.oversampling_temp_avail = bmp180_chip_info.oversampling_temp_avail,
  3156		.num_oversampling_temp_avail =
  3157			bmp180_chip_info.num_oversampling_temp_avail,
  3158		.oversampling_temp_default = bmp180_chip_info.oversampling_temp_default,
  3159	
  3160		.oversampling_press_avail = bmp180_chip_info.oversampling_press_avail,
  3161		.num_oversampling_press_avail =
  3162			bmp180_chip_info.num_oversampling_press_avail,
  3163		.oversampling_press_default =
  3164			bmp180_chip_info.oversampling_press_default,
  3165	
  3166		.temp_coeffs = bmp180_chip_info.temp_coeffs,
  3167		.temp_coeffs_type = bmp180_chip_info.temp_coeffs_type,
  3168		.press_coeffs = bmp180_chip_info.press_coeffs,
  3169		.press_coeffs_type = bmp180_chip_info.press_coeffs_type,
  3170	
  3171		.chip_config = bmp180_chip_info.chip_config,
  3172		.read_temp = bmp180_chip_info.read_temp,
  3173		.read_press = bmp180_chip_info.read_press,
  3174		.read_calib = bmp180_chip_info.read_calib,
  3175		.set_mode = bmp180_chip_info.set_mode,
  3176		.wait_conv = bmp180_chip_info.wait_conv,
  3177	
  3178		.trigger_probe = bmp085_trigger_probe,
  3179		.trigger_handler = bmp180_trigger_handler,
  3180	};
  3181	EXPORT_SYMBOL_NS(bmp085_chip_info, IIO_BMP280);
  3182
Jonathan Cameron July 28, 2024, 4:09 p.m. UTC | #3
On Fri, 26 Jul 2024 01:10:39 +0200
Vasileios Amoiridis <vassilisamir@gmail.com> wrote:

> This commit intends to add the old BMP085 sensor to the new IRQ interface
> of the sensor consistence. No functional changes intended.
> 
> The BMP085 sensor is equivalent with the BMP180 with the only difference of
> BMP085 having an extra interrupt pin to inform about an End of Conversion.
> 
> Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Trivial comments inline + as the build bot pointed out you can't use data from
one array to fill the other.

Jonathan

> ---
>  drivers/iio/pressure/bmp280-core.c | 72 +++++++++++++++++++++++-------
>  drivers/iio/pressure/bmp280-i2c.c  |  4 +-
>  drivers/iio/pressure/bmp280-spi.c  |  4 +-
>  drivers/iio/pressure/bmp280.h      |  1 +
>  4 files changed, 60 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
> index 4238f37b7805..e4d017358b68 100644
> --- a/drivers/iio/pressure/bmp280-core.c
> +++ b/drivers/iio/pressure/bmp280-core.c
> @@ -3104,13 +3104,19 @@ static irqreturn_t bmp085_eoc_irq(int irq, void *d)
>  	return IRQ_HANDLED;
>  }
>  
> -static int bmp085_fetch_eoc_irq(struct device *dev,
> -				const char *name,
> -				int irq,
> -				struct bmp280_data *data)
> +static int bmp085_trigger_probe(struct iio_dev *indio_dev)
>  {
> +	struct bmp280_data *data = iio_priv(indio_dev);
> +	struct device *dev = data->dev;
> +	struct fwnode_handle *fwnode;
>  	unsigned long irq_trig;
> -	int ret;
> +	int ret, irq;
> +
> +	fwnode = dev_fwnode(data->dev);
> +	if (!fwnode)
> +		return -ENODEV;
> +
> +	irq = fwnode_irq_get(fwnode, 0);
>  
>  	irq_trig = irqd_get_trigger_type(irq_get_irq_data(irq));
>  	if (irq_trig != IRQF_TRIGGER_RISING) {
> @@ -3120,13 +3126,12 @@ static int bmp085_fetch_eoc_irq(struct device *dev,
>  
>  	init_completion(&data->done);
>  
> -	ret = devm_request_threaded_irq(dev,
> -			irq,
> -			bmp085_eoc_irq,
> -			NULL,
> -			irq_trig,
> -			name,
> -			data);
> +	ret = devm_request_irq(dev,
> +			       irq,
> +			       bmp085_eoc_irq,
> +			       irq_trig,
> +			       indio_dev->name,
> +			       data);
Whilst here, put some of those parameters on the same line (staying below
80 chars).

>  	if (ret) {
>  		/* Bail out without IRQ but keep the driver in place */
>  		dev_err(dev, "unable to request DRDY IRQ\n");
> @@ -3137,6 +3142,44 @@ static int bmp085_fetch_eoc_irq(struct device *dev,
>  	return 0;
>  }
>  
> +const struct bmp280_chip_info bmp085_chip_info = {
> +	.id_reg = bmp180_chip_info.id_reg,
As the build bot has pointed out you can't do this.
Annoying but just duplicate the original structure with whatever
changes you need.
Vasileios Amoiridis Aug. 21, 2024, 9:58 p.m. UTC | #4
On Sun, Jul 28, 2024 at 05:09:15PM +0100, Jonathan Cameron wrote:
> On Fri, 26 Jul 2024 01:10:39 +0200
> Vasileios Amoiridis <vassilisamir@gmail.com> wrote:
> 
> > This commit intends to add the old BMP085 sensor to the new IRQ interface
> > of the sensor consistence. No functional changes intended.
> > 
> > The BMP085 sensor is equivalent with the BMP180 with the only difference of
> > BMP085 having an extra interrupt pin to inform about an End of Conversion.
> > 
> > Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
> Trivial comments inline + as the build bot pointed out you can't use data from
> one array to fill the other.
> 
> Jonathan
> 
> > ---
> >  drivers/iio/pressure/bmp280-core.c | 72 +++++++++++++++++++++++-------
> >  drivers/iio/pressure/bmp280-i2c.c  |  4 +-
> >  drivers/iio/pressure/bmp280-spi.c  |  4 +-
> >  drivers/iio/pressure/bmp280.h      |  1 +
> >  4 files changed, 60 insertions(+), 21 deletions(-)
> > 
> > diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
> > index 4238f37b7805..e4d017358b68 100644
> > --- a/drivers/iio/pressure/bmp280-core.c
> > +++ b/drivers/iio/pressure/bmp280-core.c
> > @@ -3104,13 +3104,19 @@ static irqreturn_t bmp085_eoc_irq(int irq, void *d)
> >  	return IRQ_HANDLED;
> >  }
> >  
> > -static int bmp085_fetch_eoc_irq(struct device *dev,
> > -				const char *name,
> > -				int irq,
> > -				struct bmp280_data *data)
> > +static int bmp085_trigger_probe(struct iio_dev *indio_dev)
> >  {
> > +	struct bmp280_data *data = iio_priv(indio_dev);
> > +	struct device *dev = data->dev;
> > +	struct fwnode_handle *fwnode;
> >  	unsigned long irq_trig;
> > -	int ret;
> > +	int ret, irq;
> > +
> > +	fwnode = dev_fwnode(data->dev);
> > +	if (!fwnode)
> > +		return -ENODEV;
> > +
> > +	irq = fwnode_irq_get(fwnode, 0);
> >  
> >  	irq_trig = irqd_get_trigger_type(irq_get_irq_data(irq));
> >  	if (irq_trig != IRQF_TRIGGER_RISING) {
> > @@ -3120,13 +3126,12 @@ static int bmp085_fetch_eoc_irq(struct device *dev,
> >  
> >  	init_completion(&data->done);
> >  
> > -	ret = devm_request_threaded_irq(dev,
> > -			irq,
> > -			bmp085_eoc_irq,
> > -			NULL,
> > -			irq_trig,
> > -			name,
> > -			data);
> > +	ret = devm_request_irq(dev,
> > +			       irq,
> > +			       bmp085_eoc_irq,
> > +			       irq_trig,
> > +			       indio_dev->name,
> > +			       data);
> Whilst here, put some of those parameters on the same line (staying below
> 80 chars).
> 

Ack. I was aiming for as less intrusive change as possible.

> >  	if (ret) {
> >  		/* Bail out without IRQ but keep the driver in place */
> >  		dev_err(dev, "unable to request DRDY IRQ\n");
> > @@ -3137,6 +3142,44 @@ static int bmp085_fetch_eoc_irq(struct device *dev,
> >  	return 0;
> >  }
> >  
> > +const struct bmp280_chip_info bmp085_chip_info = {
> > +	.id_reg = bmp180_chip_info.id_reg,
> As the build bot has pointed out you can't do this.
> Annoying but just duplicate the original structure with whatever
> changes you need.
> 

Extremely annoying because it is litteraly just one addition in the
new array and everything else stays the same...

Cheers,
Vasilis
diff mbox series

Patch

diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 4238f37b7805..e4d017358b68 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -3104,13 +3104,19 @@  static irqreturn_t bmp085_eoc_irq(int irq, void *d)
 	return IRQ_HANDLED;
 }
 
-static int bmp085_fetch_eoc_irq(struct device *dev,
-				const char *name,
-				int irq,
-				struct bmp280_data *data)
+static int bmp085_trigger_probe(struct iio_dev *indio_dev)
 {
+	struct bmp280_data *data = iio_priv(indio_dev);
+	struct device *dev = data->dev;
+	struct fwnode_handle *fwnode;
 	unsigned long irq_trig;
-	int ret;
+	int ret, irq;
+
+	fwnode = dev_fwnode(data->dev);
+	if (!fwnode)
+		return -ENODEV;
+
+	irq = fwnode_irq_get(fwnode, 0);
 
 	irq_trig = irqd_get_trigger_type(irq_get_irq_data(irq));
 	if (irq_trig != IRQF_TRIGGER_RISING) {
@@ -3120,13 +3126,12 @@  static int bmp085_fetch_eoc_irq(struct device *dev,
 
 	init_completion(&data->done);
 
-	ret = devm_request_threaded_irq(dev,
-			irq,
-			bmp085_eoc_irq,
-			NULL,
-			irq_trig,
-			name,
-			data);
+	ret = devm_request_irq(dev,
+			       irq,
+			       bmp085_eoc_irq,
+			       irq_trig,
+			       indio_dev->name,
+			       data);
 	if (ret) {
 		/* Bail out without IRQ but keep the driver in place */
 		dev_err(dev, "unable to request DRDY IRQ\n");
@@ -3137,6 +3142,44 @@  static int bmp085_fetch_eoc_irq(struct device *dev,
 	return 0;
 }
 
+const struct bmp280_chip_info bmp085_chip_info = {
+	.id_reg = bmp180_chip_info.id_reg,
+	.chip_id = bmp180_chip_info.chip_id,
+	.num_chip_id = bmp180_chip_info.num_chip_id,
+	.regmap_config = bmp180_chip_info.regmap_config,
+	.start_up_time = bmp180_chip_info.start_up_time,
+	.channels = bmp180_chip_info.channels,
+	.num_channels = bmp180_chip_info.num_channels,
+	.avail_scan_masks = bmp180_chip_info.avail_scan_masks,
+
+	.oversampling_temp_avail = bmp180_chip_info.oversampling_temp_avail,
+	.num_oversampling_temp_avail =
+		bmp180_chip_info.num_oversampling_temp_avail,
+	.oversampling_temp_default = bmp180_chip_info.oversampling_temp_default,
+
+	.oversampling_press_avail = bmp180_chip_info.oversampling_press_avail,
+	.num_oversampling_press_avail =
+		bmp180_chip_info.num_oversampling_press_avail,
+	.oversampling_press_default =
+		bmp180_chip_info.oversampling_press_default,
+
+	.temp_coeffs = bmp180_chip_info.temp_coeffs,
+	.temp_coeffs_type = bmp180_chip_info.temp_coeffs_type,
+	.press_coeffs = bmp180_chip_info.press_coeffs,
+	.press_coeffs_type = bmp180_chip_info.press_coeffs_type,
+
+	.chip_config = bmp180_chip_info.chip_config,
+	.read_temp = bmp180_chip_info.read_temp,
+	.read_press = bmp180_chip_info.read_press,
+	.read_calib = bmp180_chip_info.read_calib,
+	.set_mode = bmp180_chip_info.set_mode,
+	.wait_conv = bmp180_chip_info.wait_conv,
+
+	.trigger_probe = bmp085_trigger_probe,
+	.trigger_handler = bmp180_trigger_handler,
+};
+EXPORT_SYMBOL_NS(bmp085_chip_info, IIO_BMP280);
+
 static int bmp280_buffer_preenable(struct iio_dev *indio_dev)
 {
 	struct bmp280_data *data = iio_priv(indio_dev);
@@ -3308,11 +3351,6 @@  int bmp280_common_probe(struct device *dev,
 	 * so we look for an IRQ if we have that.
 	 */
 	if (irq > 0) {
-		if (chip_id == BMP180_CHIP_ID) {
-			ret = bmp085_fetch_eoc_irq(dev, name, irq, data);
-			if (ret)
-				return ret;
-		}
 		if (data->chip_info->trigger_probe) {
 			ret = data->chip_info->trigger_probe(indio_dev);
 			if (ret)
diff --git a/drivers/iio/pressure/bmp280-i2c.c b/drivers/iio/pressure/bmp280-i2c.c
index 5c3a63b4327c..2f7b25984c7b 100644
--- a/drivers/iio/pressure/bmp280-i2c.c
+++ b/drivers/iio/pressure/bmp280-i2c.c
@@ -27,7 +27,7 @@  static int bmp280_i2c_probe(struct i2c_client *client)
 }
 
 static const struct of_device_id bmp280_of_i2c_match[] = {
-	{ .compatible = "bosch,bmp085", .data = &bmp180_chip_info },
+	{ .compatible = "bosch,bmp085", .data = &bmp085_chip_info },
 	{ .compatible = "bosch,bmp180", .data = &bmp180_chip_info },
 	{ .compatible = "bosch,bmp280", .data = &bmp280_chip_info },
 	{ .compatible = "bosch,bme280", .data = &bme280_chip_info },
@@ -38,7 +38,7 @@  static const struct of_device_id bmp280_of_i2c_match[] = {
 MODULE_DEVICE_TABLE(of, bmp280_of_i2c_match);
 
 static const struct i2c_device_id bmp280_i2c_id[] = {
-	{"bmp085", (kernel_ulong_t)&bmp180_chip_info },
+	{"bmp085", (kernel_ulong_t)&bmp085_chip_info },
 	{"bmp180", (kernel_ulong_t)&bmp180_chip_info },
 	{"bmp280", (kernel_ulong_t)&bmp280_chip_info },
 	{"bme280", (kernel_ulong_t)&bme280_chip_info },
diff --git a/drivers/iio/pressure/bmp280-spi.c b/drivers/iio/pressure/bmp280-spi.c
index d18549d9bb64..49aa8c2cd85b 100644
--- a/drivers/iio/pressure/bmp280-spi.c
+++ b/drivers/iio/pressure/bmp280-spi.c
@@ -114,7 +114,7 @@  static int bmp280_spi_probe(struct spi_device *spi)
 }
 
 static const struct of_device_id bmp280_of_spi_match[] = {
-	{ .compatible = "bosch,bmp085", .data = &bmp180_chip_info },
+	{ .compatible = "bosch,bmp085", .data = &bmp085_chip_info },
 	{ .compatible = "bosch,bmp180", .data = &bmp180_chip_info },
 	{ .compatible = "bosch,bmp181", .data = &bmp180_chip_info },
 	{ .compatible = "bosch,bmp280", .data = &bmp280_chip_info },
@@ -126,7 +126,7 @@  static const struct of_device_id bmp280_of_spi_match[] = {
 MODULE_DEVICE_TABLE(of, bmp280_of_spi_match);
 
 static const struct spi_device_id bmp280_spi_id[] = {
-	{ "bmp085", (kernel_ulong_t)&bmp180_chip_info },
+	{ "bmp085", (kernel_ulong_t)&bmp085_chip_info },
 	{ "bmp180", (kernel_ulong_t)&bmp180_chip_info },
 	{ "bmp181", (kernel_ulong_t)&bmp180_chip_info },
 	{ "bmp280", (kernel_ulong_t)&bmp280_chip_info },
diff --git a/drivers/iio/pressure/bmp280.h b/drivers/iio/pressure/bmp280.h
index 754eda367941..1307eda6f283 100644
--- a/drivers/iio/pressure/bmp280.h
+++ b/drivers/iio/pressure/bmp280.h
@@ -529,6 +529,7 @@  struct bmp280_chip_info {
 };
 
 /* Chip infos for each variant */
+extern const struct bmp280_chip_info bmp085_chip_info;
 extern const struct bmp280_chip_info bmp180_chip_info;
 extern const struct bmp280_chip_info bmp280_chip_info;
 extern const struct bmp280_chip_info bme280_chip_info;