All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v3 5/9] iio: accel: bma400: Add separate channel for step counter
@ 2022-04-12  3:14 kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-04-12  3:14 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 6096 bytes --]

CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
In-Reply-To: <20220411203133.19929-6-jagathjog1996@gmail.com>
References: <20220411203133.19929-6-jagathjog1996@gmail.com>
TO: Jagath Jog J <jagathjog1996@gmail.com>
TO: dan(a)dlrobertson.com
TO: jic23(a)kernel.org
TO: andy.shevchenko(a)gmail.com
CC: linux-iio(a)vger.kernel.org
CC: linux-kernel(a)vger.kernel.org

Hi Jagath,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on jic23-iio/togreg]
[also build test WARNING on v5.18-rc2 next-20220411]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Jagath-Jog-J/iio-accel-bma400-Add-buffer-step-and-activity-inactivity/20220412-043436
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
:::::: branch date: 6 hours ago
:::::: commit date: 6 hours ago
config: openrisc-randconfig-s031-20220411 (https://download.01.org/0day-ci/archive/20220412/202204121105.6gY7K5RD-lkp(a)intel.com/config)
compiler: or1k-linux-gcc (GCC) 11.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-dirty
        # https://github.com/intel-lab-lkp/linux/commit/24d76bc639c6eedcd5b0e0983fbf1a26c81f3a8a
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Jagath-Jog-J/iio-accel-bma400-Add-buffer-step-and-activity-inactivity/20220412-043436
        git checkout 24d76bc639c6eedcd5b0e0983fbf1a26c81f3a8a
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=openrisc SHELL=/bin/bash drivers/iio/accel/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
>> drivers/iio/accel/bma400_core.c:854:42: sparse: sparse: dubious: x & !y

vim +854 drivers/iio/accel/bma400_core.c

465c811f1f201a Dan Robertson 2019-12-20  812  
465c811f1f201a Dan Robertson 2019-12-20  813  static int bma400_write_raw(struct iio_dev *indio_dev,
465c811f1f201a Dan Robertson 2019-12-20  814  			    struct iio_chan_spec const *chan, int val, int val2,
465c811f1f201a Dan Robertson 2019-12-20  815  			    long mask)
465c811f1f201a Dan Robertson 2019-12-20  816  {
465c811f1f201a Dan Robertson 2019-12-20  817  	struct bma400_data *data = iio_priv(indio_dev);
465c811f1f201a Dan Robertson 2019-12-20  818  	int ret;
465c811f1f201a Dan Robertson 2019-12-20  819  
465c811f1f201a Dan Robertson 2019-12-20  820  	switch (mask) {
465c811f1f201a Dan Robertson 2019-12-20  821  	case IIO_CHAN_INFO_SAMP_FREQ:
465c811f1f201a Dan Robertson 2019-12-20  822  		/*
465c811f1f201a Dan Robertson 2019-12-20  823  		 * The sample frequency is readonly for the temperature
465c811f1f201a Dan Robertson 2019-12-20  824  		 * register and a fixed value in low-power mode.
465c811f1f201a Dan Robertson 2019-12-20  825  		 */
465c811f1f201a Dan Robertson 2019-12-20  826  		if (chan->type != IIO_ACCEL)
465c811f1f201a Dan Robertson 2019-12-20  827  			return -EINVAL;
465c811f1f201a Dan Robertson 2019-12-20  828  
465c811f1f201a Dan Robertson 2019-12-20  829  		mutex_lock(&data->mutex);
465c811f1f201a Dan Robertson 2019-12-20  830  		ret = bma400_set_accel_output_data_rate(data, val, val2);
465c811f1f201a Dan Robertson 2019-12-20  831  		mutex_unlock(&data->mutex);
465c811f1f201a Dan Robertson 2019-12-20  832  		return ret;
465c811f1f201a Dan Robertson 2019-12-20  833  	case IIO_CHAN_INFO_SCALE:
98496ccdf0dd88 Dan Carpenter 2020-01-16  834  		if (val != 0 ||
98496ccdf0dd88 Dan Carpenter 2020-01-16  835  		    val2 < BMA400_SCALE_MIN || val2 > BMA400_SCALE_MAX)
465c811f1f201a Dan Robertson 2019-12-20  836  			return -EINVAL;
465c811f1f201a Dan Robertson 2019-12-20  837  
465c811f1f201a Dan Robertson 2019-12-20  838  		mutex_lock(&data->mutex);
465c811f1f201a Dan Robertson 2019-12-20  839  		ret = bma400_set_accel_scale(data, val2);
465c811f1f201a Dan Robertson 2019-12-20  840  		mutex_unlock(&data->mutex);
465c811f1f201a Dan Robertson 2019-12-20  841  		return ret;
465c811f1f201a Dan Robertson 2019-12-20  842  	case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
465c811f1f201a Dan Robertson 2019-12-20  843  		mutex_lock(&data->mutex);
465c811f1f201a Dan Robertson 2019-12-20  844  		ret = bma400_set_accel_oversampling_ratio(data, val);
465c811f1f201a Dan Robertson 2019-12-20  845  		mutex_unlock(&data->mutex);
465c811f1f201a Dan Robertson 2019-12-20  846  		return ret;
24d76bc639c6ee Jagath Jog J  2022-04-12  847  	case IIO_CHAN_INFO_ENABLE:
24d76bc639c6ee Jagath Jog J  2022-04-12  848  		if (data->steps_enabled == val)
24d76bc639c6ee Jagath Jog J  2022-04-12  849  			return 0;
24d76bc639c6ee Jagath Jog J  2022-04-12  850  
24d76bc639c6ee Jagath Jog J  2022-04-12  851  		mutex_lock(&data->mutex);
24d76bc639c6ee Jagath Jog J  2022-04-12  852  		ret = regmap_update_bits(data->regmap, BMA400_INT_CONFIG1_REG,
24d76bc639c6ee Jagath Jog J  2022-04-12  853  					 BMA400_STEP_INT_MSK,
24d76bc639c6ee Jagath Jog J  2022-04-12 @854  					 FIELD_PREP(BMA400_STEP_INT_MSK, !!val));
24d76bc639c6ee Jagath Jog J  2022-04-12  855  		mutex_unlock(&data->mutex);
24d76bc639c6ee Jagath Jog J  2022-04-12  856  		data->steps_enabled = val;
24d76bc639c6ee Jagath Jog J  2022-04-12  857  		return ret;
465c811f1f201a Dan Robertson 2019-12-20  858  	default:
465c811f1f201a Dan Robertson 2019-12-20  859  		return -EINVAL;
465c811f1f201a Dan Robertson 2019-12-20  860  	}
465c811f1f201a Dan Robertson 2019-12-20  861  }
465c811f1f201a Dan Robertson 2019-12-20  862  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 5/9] iio: accel: bma400: Add separate channel for step counter
  2022-04-11 20:31 ` [PATCH v3 5/9] iio: accel: bma400: Add separate channel for step counter Jagath Jog J
@ 2022-04-16 16:41   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2022-04-16 16:41 UTC (permalink / raw)
  To: Jagath Jog J; +Cc: dan, andy.shevchenko, linux-iio, linux-kernel

On Tue, 12 Apr 2022 02:01:29 +0530
Jagath Jog J <jagathjog1996@gmail.com> wrote:

> Added channel for step counter which can be enable or disable
> through the sysfs interface.
> 
> Signed-off-by: Jagath Jog J <jagathjog1996@gmail.com>
> ---
>  drivers/iio/accel/bma400.h      |  1 +
>  drivers/iio/accel/bma400_core.c | 48 ++++++++++++++++++++++++++++++---
>  2 files changed, 45 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/accel/bma400.h b/drivers/iio/accel/bma400.h
> index a7482a66b36b..52f9ea95de81 100644
> --- a/drivers/iio/accel/bma400.h
> +++ b/drivers/iio/accel/bma400.h
> @@ -53,6 +53,7 @@
>  #define BMA400_STEP_CNT1_REG        0x16
>  #define BMA400_STEP_CNT3_REG        0x17
>  #define BMA400_STEP_STAT_REG        0x18
> +#define BMA400_STEP_INT_MSK	    BIT(0)
>  
>  /*
>   * Read-write configuration registers
> diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c
> index b7b2b67aef31..c8f147163d3c 100644
> --- a/drivers/iio/accel/bma400_core.c
> +++ b/drivers/iio/accel/bma400_core.c
> @@ -20,6 +20,8 @@
>  #include <linux/regmap.h>
>  #include <linux/regulator/consumer.h>
>  
> +#include <asm/unaligned.h>
> +
>  #include <linux/iio/iio.h>
>  #include <linux/iio/buffer.h>
>  #include <linux/iio/trigger.h>
> @@ -67,6 +69,7 @@ struct bma400_data {
>  	int oversampling_ratio;
>  	int scale;
>  	struct iio_trigger *trig;
> +	int steps_enabled;
>  	/* Correct time stamp alignment */
>  	struct {
>  		__le16 buff[3];
> @@ -201,6 +204,12 @@ static const struct iio_chan_spec bma400_channels[] = {
>  			.endianness = IIO_LE,
>  		},
>  	},
> +	{
> +		.type = IIO_STEPS,
> +		.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
> +				      BIT(IIO_CHAN_INFO_ENABLE),
> +		.scan_index = -1, /* No buffer support */
> +	},
>  	IIO_CHAN_SOFT_TIMESTAMP(4),
>  };
>  
> @@ -705,13 +714,28 @@ static int bma400_read_raw(struct iio_dev *indio_dev,
>  {
>  	struct bma400_data *data = iio_priv(indio_dev);
>  	int ret;
> +	u8 steps_raw[3];
>  
>  	switch (mask) {
>  	case IIO_CHAN_INFO_PROCESSED:
> -		mutex_lock(&data->mutex);
> -		ret = bma400_get_temp_reg(data, val, val2);
> -		mutex_unlock(&data->mutex);
> -		return ret;
> +		switch (chan->type) {
> +		case IIO_TEMP:
> +			mutex_lock(&data->mutex);
> +			ret = bma400_get_temp_reg(data, val, val2);
> +			mutex_unlock(&data->mutex);
> +			return ret;
> +		case IIO_STEPS:
> +			mutex_lock(&data->mutex);
> +			ret = regmap_bulk_read(data->regmap, BMA400_STEP_CNT0_REG,
> +					       &steps_raw, sizeof(steps_raw));

Bulk read to a non DMA safe buffer. Similar fix to before needed.
Or given this is a slow path, just use a local kmalloc() for the buffer.

The reality is you are probably fine today without such care, but last
time we discussed this the conclusion was that it would be a perfectly
valid optimisation in regmap to return to requiring DMA safe buffers
for bulk accesses.

> +			mutex_unlock(&data->mutex);
> +			if (ret)
> +				return ret;
> +			*val = get_unaligned_le24(steps_raw);
> +			return IIO_VAL_INT;
> +		default:
> +			return -EINVAL;
> +		}
>  	case IIO_CHAN_INFO_RAW:
>  		mutex_lock(&data->mutex);
>  		ret = bma400_get_accel_reg(data, chan, val);
> @@ -752,6 +776,9 @@ static int bma400_read_raw(struct iio_dev *indio_dev,
>  
>  		*val = data->oversampling_ratio;
>  		return IIO_VAL_INT;
> +	case IIO_CHAN_INFO_ENABLE:
> +		*val = data->steps_enabled;
> +		return IIO_VAL_INT;
>  	default:
>  		return -EINVAL;
>  	}
> @@ -817,6 +844,17 @@ static int bma400_write_raw(struct iio_dev *indio_dev,
>  		ret = bma400_set_accel_oversampling_ratio(data, val);
>  		mutex_unlock(&data->mutex);
>  		return ret;
> +	case IIO_CHAN_INFO_ENABLE:
> +		if (data->steps_enabled == val)
> +			return 0;
> +
> +		mutex_lock(&data->mutex);
> +		ret = regmap_update_bits(data->regmap, BMA400_INT_CONFIG1_REG,
> +					 BMA400_STEP_INT_MSK,
> +					 FIELD_PREP(BMA400_STEP_INT_MSK, !!val));

Why the lock for this one?

> +		mutex_unlock(&data->mutex);
> +		data->steps_enabled = val;
> +		return ret;
>  	default:
>  		return -EINVAL;
>  	}
> @@ -833,6 +871,8 @@ static int bma400_write_raw_get_fmt(struct iio_dev *indio_dev,
>  		return IIO_VAL_INT_PLUS_MICRO;
>  	case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
>  		return IIO_VAL_INT;
> +	case IIO_CHAN_INFO_ENABLE:
> +		return IIO_VAL_INT;
>  	default:
>  		return -EINVAL;
>  	}


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v3 5/9] iio: accel: bma400: Add separate channel for step counter
  2022-04-11 20:31 [PATCH v3 0/9] iio: accel: bma400: Add buffer, step and activity/inactivity Jagath Jog J
@ 2022-04-11 20:31 ` Jagath Jog J
  2022-04-16 16:41   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Jagath Jog J @ 2022-04-11 20:31 UTC (permalink / raw)
  To: dan, jic23, andy.shevchenko; +Cc: linux-iio, linux-kernel

Added channel for step counter which can be enable or disable
through the sysfs interface.

Signed-off-by: Jagath Jog J <jagathjog1996@gmail.com>
---
 drivers/iio/accel/bma400.h      |  1 +
 drivers/iio/accel/bma400_core.c | 48 ++++++++++++++++++++++++++++++---
 2 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/accel/bma400.h b/drivers/iio/accel/bma400.h
index a7482a66b36b..52f9ea95de81 100644
--- a/drivers/iio/accel/bma400.h
+++ b/drivers/iio/accel/bma400.h
@@ -53,6 +53,7 @@
 #define BMA400_STEP_CNT1_REG        0x16
 #define BMA400_STEP_CNT3_REG        0x17
 #define BMA400_STEP_STAT_REG        0x18
+#define BMA400_STEP_INT_MSK	    BIT(0)
 
 /*
  * Read-write configuration registers
diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c
index b7b2b67aef31..c8f147163d3c 100644
--- a/drivers/iio/accel/bma400_core.c
+++ b/drivers/iio/accel/bma400_core.c
@@ -20,6 +20,8 @@
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
 
+#include <asm/unaligned.h>
+
 #include <linux/iio/iio.h>
 #include <linux/iio/buffer.h>
 #include <linux/iio/trigger.h>
@@ -67,6 +69,7 @@ struct bma400_data {
 	int oversampling_ratio;
 	int scale;
 	struct iio_trigger *trig;
+	int steps_enabled;
 	/* Correct time stamp alignment */
 	struct {
 		__le16 buff[3];
@@ -201,6 +204,12 @@ static const struct iio_chan_spec bma400_channels[] = {
 			.endianness = IIO_LE,
 		},
 	},
+	{
+		.type = IIO_STEPS,
+		.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
+				      BIT(IIO_CHAN_INFO_ENABLE),
+		.scan_index = -1, /* No buffer support */
+	},
 	IIO_CHAN_SOFT_TIMESTAMP(4),
 };
 
@@ -705,13 +714,28 @@ static int bma400_read_raw(struct iio_dev *indio_dev,
 {
 	struct bma400_data *data = iio_priv(indio_dev);
 	int ret;
+	u8 steps_raw[3];
 
 	switch (mask) {
 	case IIO_CHAN_INFO_PROCESSED:
-		mutex_lock(&data->mutex);
-		ret = bma400_get_temp_reg(data, val, val2);
-		mutex_unlock(&data->mutex);
-		return ret;
+		switch (chan->type) {
+		case IIO_TEMP:
+			mutex_lock(&data->mutex);
+			ret = bma400_get_temp_reg(data, val, val2);
+			mutex_unlock(&data->mutex);
+			return ret;
+		case IIO_STEPS:
+			mutex_lock(&data->mutex);
+			ret = regmap_bulk_read(data->regmap, BMA400_STEP_CNT0_REG,
+					       &steps_raw, sizeof(steps_raw));
+			mutex_unlock(&data->mutex);
+			if (ret)
+				return ret;
+			*val = get_unaligned_le24(steps_raw);
+			return IIO_VAL_INT;
+		default:
+			return -EINVAL;
+		}
 	case IIO_CHAN_INFO_RAW:
 		mutex_lock(&data->mutex);
 		ret = bma400_get_accel_reg(data, chan, val);
@@ -752,6 +776,9 @@ static int bma400_read_raw(struct iio_dev *indio_dev,
 
 		*val = data->oversampling_ratio;
 		return IIO_VAL_INT;
+	case IIO_CHAN_INFO_ENABLE:
+		*val = data->steps_enabled;
+		return IIO_VAL_INT;
 	default:
 		return -EINVAL;
 	}
@@ -817,6 +844,17 @@ static int bma400_write_raw(struct iio_dev *indio_dev,
 		ret = bma400_set_accel_oversampling_ratio(data, val);
 		mutex_unlock(&data->mutex);
 		return ret;
+	case IIO_CHAN_INFO_ENABLE:
+		if (data->steps_enabled == val)
+			return 0;
+
+		mutex_lock(&data->mutex);
+		ret = regmap_update_bits(data->regmap, BMA400_INT_CONFIG1_REG,
+					 BMA400_STEP_INT_MSK,
+					 FIELD_PREP(BMA400_STEP_INT_MSK, !!val));
+		mutex_unlock(&data->mutex);
+		data->steps_enabled = val;
+		return ret;
 	default:
 		return -EINVAL;
 	}
@@ -833,6 +871,8 @@ static int bma400_write_raw_get_fmt(struct iio_dev *indio_dev,
 		return IIO_VAL_INT_PLUS_MICRO;
 	case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
 		return IIO_VAL_INT;
+	case IIO_CHAN_INFO_ENABLE:
+		return IIO_VAL_INT;
 	default:
 		return -EINVAL;
 	}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-16 16:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12  3:14 [PATCH v3 5/9] iio: accel: bma400: Add separate channel for step counter kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2022-04-11 20:31 [PATCH v3 0/9] iio: accel: bma400: Add buffer, step and activity/inactivity Jagath Jog J
2022-04-11 20:31 ` [PATCH v3 5/9] iio: accel: bma400: Add separate channel for step counter Jagath Jog J
2022-04-16 16:41   ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.