* Re: [PATCH v1 4/5] iio: accel: bma400: Add separate channel for step counter
@ 2022-03-20 4:21 kernel test robot
0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2022-03-20 4:21 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 5922 bytes --]
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
In-Reply-To: <20220319181023.8090-5-jagathjog1996@gmail.com>
References: <20220319181023.8090-5-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 v5.17-rc8]
[cannot apply to jic23-iio/togreg next-20220318]
[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/0day-ci/linux/commits/Jagath-Jog-J/iio-accel-bma400-Add-support-for-buffer-and-step/20220320-021114
base: 09688c0166e76ce2fb85e86b9d99be8b0084cdf9
:::::: branch date: 10 hours ago
:::::: commit date: 10 hours ago
config: i386-randconfig-s001 (https://download.01.org/0day-ci/archive/20220320/202203201202.2ntrQ6KC-lkp(a)intel.com/config)
compiler: gcc-9 (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://github.com/0day-ci/linux/commit/3b579e3178a37ce190fc998014d0613e053b384b
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jagath-Jog-J/iio-accel-bma400-Add-support-for-buffer-and-step/20220320-021114
git checkout 3b579e3178a37ce190fc998014d0613e053b384b
# save the config file to linux build tree
mkdir build_dir
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 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:834:42: sparse: sparse: dubious: x & !y
drivers/iio/accel/bma400_core.c:945:13: sparse: sparse: restricted __le16 degrades to integer
vim +834 drivers/iio/accel/bma400_core.c
465c811f1f201a Dan Robertson 2019-12-20 792
465c811f1f201a Dan Robertson 2019-12-20 793 static int bma400_write_raw(struct iio_dev *indio_dev,
465c811f1f201a Dan Robertson 2019-12-20 794 struct iio_chan_spec const *chan, int val, int val2,
465c811f1f201a Dan Robertson 2019-12-20 795 long mask)
465c811f1f201a Dan Robertson 2019-12-20 796 {
465c811f1f201a Dan Robertson 2019-12-20 797 struct bma400_data *data = iio_priv(indio_dev);
465c811f1f201a Dan Robertson 2019-12-20 798 int ret;
465c811f1f201a Dan Robertson 2019-12-20 799
465c811f1f201a Dan Robertson 2019-12-20 800 switch (mask) {
465c811f1f201a Dan Robertson 2019-12-20 801 case IIO_CHAN_INFO_SAMP_FREQ:
465c811f1f201a Dan Robertson 2019-12-20 802 /*
465c811f1f201a Dan Robertson 2019-12-20 803 * The sample frequency is readonly for the temperature
465c811f1f201a Dan Robertson 2019-12-20 804 * register and a fixed value in low-power mode.
465c811f1f201a Dan Robertson 2019-12-20 805 */
465c811f1f201a Dan Robertson 2019-12-20 806 if (chan->type != IIO_ACCEL)
465c811f1f201a Dan Robertson 2019-12-20 807 return -EINVAL;
465c811f1f201a Dan Robertson 2019-12-20 808
465c811f1f201a Dan Robertson 2019-12-20 809 mutex_lock(&data->mutex);
465c811f1f201a Dan Robertson 2019-12-20 810 ret = bma400_set_accel_output_data_rate(data, val, val2);
465c811f1f201a Dan Robertson 2019-12-20 811 mutex_unlock(&data->mutex);
465c811f1f201a Dan Robertson 2019-12-20 812 return ret;
465c811f1f201a Dan Robertson 2019-12-20 813 case IIO_CHAN_INFO_SCALE:
98496ccdf0dd88 Dan Carpenter 2020-01-16 814 if (val != 0 ||
98496ccdf0dd88 Dan Carpenter 2020-01-16 815 val2 < BMA400_SCALE_MIN || val2 > BMA400_SCALE_MAX)
465c811f1f201a Dan Robertson 2019-12-20 816 return -EINVAL;
465c811f1f201a Dan Robertson 2019-12-20 817
465c811f1f201a Dan Robertson 2019-12-20 818 mutex_lock(&data->mutex);
465c811f1f201a Dan Robertson 2019-12-20 819 ret = bma400_set_accel_scale(data, val2);
465c811f1f201a Dan Robertson 2019-12-20 820 mutex_unlock(&data->mutex);
465c811f1f201a Dan Robertson 2019-12-20 821 return ret;
465c811f1f201a Dan Robertson 2019-12-20 822 case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
465c811f1f201a Dan Robertson 2019-12-20 823 mutex_lock(&data->mutex);
465c811f1f201a Dan Robertson 2019-12-20 824 ret = bma400_set_accel_oversampling_ratio(data, val);
465c811f1f201a Dan Robertson 2019-12-20 825 mutex_unlock(&data->mutex);
465c811f1f201a Dan Robertson 2019-12-20 826 return ret;
3b579e3178a37c Jagath Jog J 2022-03-19 827 case IIO_CHAN_INFO_ENABLE:
3b579e3178a37c Jagath Jog J 2022-03-19 828 if (data->steps_enabled == val)
3b579e3178a37c Jagath Jog J 2022-03-19 829 return 0;
3b579e3178a37c Jagath Jog J 2022-03-19 830
3b579e3178a37c Jagath Jog J 2022-03-19 831 mutex_lock(&data->mutex);
3b579e3178a37c Jagath Jog J 2022-03-19 832 ret = regmap_update_bits(data->regmap, BMA400_INT_CONFIG1_REG,
3b579e3178a37c Jagath Jog J 2022-03-19 833 BMA400_STEP_INT_MSK,
3b579e3178a37c Jagath Jog J 2022-03-19 @834 FIELD_PREP(BMA400_STEP_INT_MSK, !!val));
3b579e3178a37c Jagath Jog J 2022-03-19 835 mutex_unlock(&data->mutex);
3b579e3178a37c Jagath Jog J 2022-03-19 836 data->steps_enabled = val;
3b579e3178a37c Jagath Jog J 2022-03-19 837 return ret;
465c811f1f201a Dan Robertson 2019-12-20 838 default:
465c811f1f201a Dan Robertson 2019-12-20 839 return -EINVAL;
465c811f1f201a Dan Robertson 2019-12-20 840 }
465c811f1f201a Dan Robertson 2019-12-20 841 }
465c811f1f201a Dan Robertson 2019-12-20 842
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v1 0/5] iio: accel: bma400: Add support for buffer and step @ 2022-03-19 18:10 Jagath Jog J 2022-03-19 18:10 ` [PATCH v1 4/5] iio: accel: bma400: Add separate channel for step counter Jagath Jog J 0 siblings, 1 reply; 5+ messages in thread From: Jagath Jog J @ 2022-03-19 18:10 UTC (permalink / raw) To: dan, jic23, andy.shevchenko; +Cc: linux-iio, linux-kernel This patch series adds trigger buffer support with data ready interrupt, separate channel for step counter and an event for step change interrupt. Jagath Jog J (5): iio: accel: bma400: conversion to device-managed function iio: accel: bma400: changing scale min and max macro values iio: accel: bma400: Add triggered buffer support iio: accel: bma400: Add separate channel for step counter iio: accel: bma400: Add step change event drivers/iio/accel/Kconfig | 2 + drivers/iio/accel/bma400.h | 19 +- drivers/iio/accel/bma400_core.c | 315 +++++++++++++++++++++++++++++--- drivers/iio/accel/bma400_i2c.c | 10 +- drivers/iio/accel/bma400_spi.c | 10 +- 5 files changed, 304 insertions(+), 52 deletions(-) -- 2.17.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 4/5] iio: accel: bma400: Add separate channel for step counter 2022-03-19 18:10 [PATCH v1 0/5] iio: accel: bma400: Add support for buffer and step Jagath Jog J @ 2022-03-19 18:10 ` Jagath Jog J 2022-03-20 17:30 ` Jonathan Cameron ` (2 more replies) 0 siblings, 3 replies; 5+ messages in thread From: Jagath Jog J @ 2022-03-19 18:10 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 | 47 ++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/drivers/iio/accel/bma400.h b/drivers/iio/accel/bma400.h index b306a5ad513a..65bbc80cbb7f 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 797403c7dd85..305643e99eb5 100644 --- a/drivers/iio/accel/bma400_core.c +++ b/drivers/iio/accel/bma400_core.c @@ -68,6 +68,7 @@ struct bma400_data { int oversampling_ratio; int scale; struct iio_trigger *trig; + int steps_enabled; /* Correct time stamp alignment */ struct { __be16 buff[3]; @@ -202,6 +203,13 @@ 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), }; @@ -686,13 +694,28 @@ static int bma400_read_raw(struct iio_dev *indio_dev, { struct bma400_data *data = iio_priv(indio_dev); int ret; + u32 steps_raw; 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_STEPS: + mutex_lock(&data->mutex); + ret = regmap_bulk_read(data->regmap, BMA400_STEP_CNT0_REG, + &steps_raw, 3 * sizeof(u8)); + mutex_unlock(&data->mutex); + if (ret) + return ret; + *val = steps_raw & 0x00FFFFFF; + return IIO_VAL_INT; + case IIO_TEMP: + mutex_lock(&data->mutex); + ret = bma400_get_temp_reg(data, val, val2); + mutex_unlock(&data->mutex); + return ret; + default: + return -EINVAL; + } case IIO_CHAN_INFO_RAW: mutex_lock(&data->mutex); ret = bma400_get_accel_reg(data, chan, val); @@ -733,6 +756,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; } @@ -798,6 +824,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; } @@ -814,6 +851,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] 5+ messages in thread
* Re: [PATCH v1 4/5] iio: accel: bma400: Add separate channel for step counter 2022-03-19 18:10 ` [PATCH v1 4/5] iio: accel: bma400: Add separate channel for step counter Jagath Jog J @ 2022-03-20 17:30 ` Jonathan Cameron 2022-03-21 8:42 ` Andy Shevchenko 2022-03-21 8:43 ` Andy Shevchenko 2 siblings, 0 replies; 5+ messages in thread From: Jonathan Cameron @ 2022-03-20 17:30 UTC (permalink / raw) To: Jagath Jog J; +Cc: dan, andy.shevchenko, linux-iio, linux-kernel On Sat, 19 Mar 2022 23:40:22 +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> hi Jagath, Been a long time since we had a steps counter. Good to have support on another device. One minor thing inline, but otherwise looks good to me. Jonathan > --- > drivers/iio/accel/bma400.h | 1 + > drivers/iio/accel/bma400_core.c | 47 ++++++++++++++++++++++++++++++--- > 2 files changed, 44 insertions(+), 4 deletions(-) > > diff --git a/drivers/iio/accel/bma400.h b/drivers/iio/accel/bma400.h > index b306a5ad513a..65bbc80cbb7f 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 797403c7dd85..305643e99eb5 100644 > --- a/drivers/iio/accel/bma400_core.c > +++ b/drivers/iio/accel/bma400_core.c > @@ -68,6 +68,7 @@ struct bma400_data { > int oversampling_ratio; > int scale; > struct iio_trigger *trig; > + int steps_enabled; > /* Correct time stamp alignment */ > struct { > __be16 buff[3]; > @@ -202,6 +203,13 @@ 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), > }; > > @@ -686,13 +694,28 @@ static int bma400_read_raw(struct iio_dev *indio_dev, > { > struct bma400_data *data = iio_priv(indio_dev); > int ret; > + u32 steps_raw; > > 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_STEPS: > + mutex_lock(&data->mutex); > + ret = regmap_bulk_read(data->regmap, BMA400_STEP_CNT0_REG, > + &steps_raw, 3 * sizeof(u8)); > + mutex_unlock(&data->mutex); > + if (ret) > + return ret; > + *val = steps_raw & 0x00FFFFFF; No need for an endian conversion in here? I'd also intialize steps_raw = 0 before the bulk read then you shouldn't need to mask as you only read 3 bytes in. > + return IIO_VAL_INT; > + case IIO_TEMP: > + mutex_lock(&data->mutex); > + ret = bma400_get_temp_reg(data, val, val2); > + mutex_unlock(&data->mutex); > + return ret; > + default: > + return -EINVAL; > + } > case IIO_CHAN_INFO_RAW: > mutex_lock(&data->mutex); > ret = bma400_get_accel_reg(data, chan, val); > @@ -733,6 +756,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; > } > @@ -798,6 +824,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; > } > @@ -814,6 +851,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] 5+ messages in thread
* Re: [PATCH v1 4/5] iio: accel: bma400: Add separate channel for step counter 2022-03-19 18:10 ` [PATCH v1 4/5] iio: accel: bma400: Add separate channel for step counter Jagath Jog J 2022-03-20 17:30 ` Jonathan Cameron @ 2022-03-21 8:42 ` Andy Shevchenko 2022-03-21 8:43 ` Andy Shevchenko 2 siblings, 0 replies; 5+ messages in thread From: Andy Shevchenko @ 2022-03-21 8:42 UTC (permalink / raw) To: Jagath Jog J Cc: Dan Robertson, Jonathan Cameron, linux-iio, Linux Kernel Mailing List On Sat, Mar 19, 2022 at 8:10 PM Jagath Jog J <jagathjog1996@gmail.com> wrote: > > Added channel for step counter which can be enable or disable > through the sysfs interface. ... > + u32 steps_raw; I would expect this to be u8 ...[3]. ... > + ret = regmap_bulk_read(data->regmap, BMA400_STEP_CNT0_REG, > + &steps_raw, 3 * sizeof(u8)); sizeof(&steps_raw); ... > + *val = steps_raw & 0x00FFFFFF; And here it seems to be be24_to_cpu() like Jonathan mentioned, -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 4/5] iio: accel: bma400: Add separate channel for step counter 2022-03-19 18:10 ` [PATCH v1 4/5] iio: accel: bma400: Add separate channel for step counter Jagath Jog J 2022-03-20 17:30 ` Jonathan Cameron 2022-03-21 8:42 ` Andy Shevchenko @ 2022-03-21 8:43 ` Andy Shevchenko 2 siblings, 0 replies; 5+ messages in thread From: Andy Shevchenko @ 2022-03-21 8:43 UTC (permalink / raw) To: Jagath Jog J Cc: Dan Robertson, Jonathan Cameron, linux-iio, Linux Kernel Mailing List On Sat, Mar 19, 2022 at 8:10 PM Jagath Jog J <jagathjog1996@gmail.com> wrote: > + { > + .type = IIO_STEPS, > + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | > + BIT(IIO_CHAN_INFO_ENABLE), > + .scan_index = -1, /* No buffer support */ > + }, > + One more thing, seems like a stray blank line addition. > IIO_CHAN_SOFT_TIMESTAMP(4), > }; -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-21 8:44 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-03-20 4:21 [PATCH v1 4/5] iio: accel: bma400: Add separate channel for step counter kernel test robot -- strict thread matches above, loose matches on Subject: below -- 2022-03-19 18:10 [PATCH v1 0/5] iio: accel: bma400: Add support for buffer and step Jagath Jog J 2022-03-19 18:10 ` [PATCH v1 4/5] iio: accel: bma400: Add separate channel for step counter Jagath Jog J 2022-03-20 17:30 ` Jonathan Cameron 2022-03-21 8:42 ` Andy Shevchenko 2022-03-21 8:43 ` Andy Shevchenko
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.