All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/9] iio: accel: bma400: Add buffer, step and activity/inactivity
@ 2022-04-11 20:31 Jagath Jog J
  2022-04-11 20:31 ` [PATCH v3 1/9] iio: accel: bma400: Fix the scale min and max macro values Jagath Jog J
                   ` (8 more replies)
  0 siblings, 9 replies; 31+ 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

This patch series adds trigger buffer support with data ready interrupt,
separate channel for step counter, an event for step change interrupt,
activity recognition and activity/inactivity event support.

changes since v2
1. Reordering of header includes in the separate patch.
2. Matching the IIO syntax for multiline comment.
3. Following the preference in the interrupt handler for returning.
4. Add support for activity recognition.
5. Add support for debugfs to access registers from userspace.
6. Add support for activity and inactivity events

changes since v1
1. Added comment section that describes the math for scale calculation.
2. Added separate devm_add_action_or_reset() calls to disable regulator
   and to put the sensor in power down mode.
3. Remove the err_reg_disable and out, goto labels and returning directly
   if error occurs.
4. Added mutex calls while putting sensor in power down.
5. Added ___cacheline_aligned for device data.
6. Ordering the header includes.
7. Handling erroneous and spurious interrupts in the interrupt handler
   by returning IRQ_NONE.
8. Using dev_err_probe() instead of dev_err().
9. Configured the interrupt to open drain.
10. Using le16_to_cpu() to fix the sparse warning.
11. Checking the step change event is enabled or not.
12. Enabling the step change event will also enable the step channel.
13. Using FIELD_GET() instead of bitwise operation.
14. Removal of dead code in the _event_config().

Jagath Jog J (9):
  iio: accel: bma400: Fix the scale min and max macro values
  iio: accel: bma400: Reordering of header files
  iio: accel: bma400: conversion to device-managed function
  iio: accel: bma400: Add triggered buffer support
  iio: accel: bma400: Add separate channel for step counter
  iio: accel: bma400: Add step change event
  iio: accel: bma400: Add activity recognition support
  iio: accel: bma400: Add debugfs register access support
  iio: accel: bma400: Add support for activity and inactivity events

 drivers/iio/accel/Kconfig       |   2 +
 drivers/iio/accel/bma400.h      |  49 ++-
 drivers/iio/accel/bma400_core.c | 701 +++++++++++++++++++++++++++++---
 drivers/iio/accel/bma400_i2c.c  |  10 +-
 drivers/iio/accel/bma400_spi.c  |   8 +-
 5 files changed, 703 insertions(+), 67 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [PATCH v3 9/9] iio: accel: bma400: Add support for activity and inactivity events
  2022-04-11 20:31 ` [PATCH v3 9/9] iio: accel: bma400: Add support for activity and inactivity events Jagath Jog J
  2022-04-12  5:21   ` kernel test robot
@ 2022-04-12  7:38 ` Dan Carpenter
  2022-04-16 16:55   ` Jonathan Cameron
  2 siblings, 0 replies; 31+ messages in thread
From: kernel test robot @ 2022-04-12  6:44 UTC (permalink / raw)
  To: kbuild

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

CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
In-Reply-To: <20220411203133.19929-10-jagathjog1996@gmail.com>
References: <20220411203133.19929-10-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: 10 hours ago
:::::: commit date: 10 hours ago
config: x86_64-randconfig-m001-20220411 (https://download.01.org/0day-ci/archive/20220412/202204121411.snZVqiMy-lkp(a)intel.com/config)
compiler: gcc-11 (Debian 11.2.0-19) 11.2.0

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

smatch warnings:
drivers/iio/accel/bma400_core.c:1154 bma400_read_event_value() warn: impossible condition '(reg < 0) => (0-255 < 0)'
drivers/iio/accel/bma400_core.c:1202 bma400_write_event_value() warn: impossible condition '(reg < 0) => (0-255 < 0)'

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

15ee6de45ed7a02 Jagath Jog J 2022-04-12  1141  
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1142  static int bma400_read_event_value(struct iio_dev *indio_dev,
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1143  				   const struct iio_chan_spec *chan,
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1144  				   enum iio_event_type type,
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1145  				   enum iio_event_direction dir,
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1146  				   enum iio_event_info info,
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1147  				   int *val, int *val2)
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1148  {
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1149  	struct bma400_data *data = iio_priv(indio_dev);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1150  	int ret;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1151  	u8 reg, duration[2];
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1152  
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1153  	reg = get_gen_config_reg(dir);
15ee6de45ed7a02 Jagath Jog J 2022-04-12 @1154  	if (reg < 0)
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1155  		return -EINVAL;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1156  
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1157  	*val2 = 0;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1158  	switch (info) {
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1159  	case IIO_EV_INFO_VALUE:
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1160  		mutex_lock(&data->mutex);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1161  		ret = regmap_read(data->regmap, reg + BMA400_GEN_CONFIG2_OFF,
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1162  				  val);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1163  		mutex_unlock(&data->mutex);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1164  		if (ret)
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1165  			return ret;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1166  		return IIO_VAL_INT;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1167  	case IIO_EV_INFO_PERIOD:
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1168  		mutex_lock(&data->mutex);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1169  		ret = regmap_bulk_read(data->regmap,
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1170  				       reg + BMA400_GEN_CONFIG3_OFF,
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1171  				       duration, sizeof(duration));
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1172  		mutex_unlock(&data->mutex);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1173  		if (ret)
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1174  			return ret;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1175  		*val = get_unaligned_be16(duration);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1176  		return IIO_VAL_INT;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1177  	case IIO_EV_INFO_HYSTERESIS:
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1178  		mutex_lock(&data->mutex);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1179  		ret = regmap_read(data->regmap, reg, val);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1180  		mutex_unlock(&data->mutex);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1181  		if (ret)
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1182  			return ret;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1183  		*val = FIELD_GET(BMA400_GEN_HYST_MSK, *val);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1184  		return IIO_VAL_INT;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1185  	default:
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1186  		return -EINVAL;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1187  	}
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1188  }
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1189  
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1190  static int bma400_write_event_value(struct iio_dev *indio_dev,
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1191  				    const struct iio_chan_spec *chan,
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1192  				    enum iio_event_type type,
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1193  				    enum iio_event_direction dir,
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1194  				    enum iio_event_info info,
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1195  				    int val, int val2)
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1196  {
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1197  	struct bma400_data *data = iio_priv(indio_dev);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1198  	int ret;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1199  	u8 reg, duration[2];
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1200  
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1201  	reg = get_gen_config_reg(dir);
15ee6de45ed7a02 Jagath Jog J 2022-04-12 @1202  	if (reg < 0)
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1203  		return -EINVAL;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1204  
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1205  	switch (info) {
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1206  	case IIO_EV_INFO_VALUE:
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1207  		if (val < 1 || val > 255)
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1208  			return -EINVAL;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1209  
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1210  		mutex_lock(&data->mutex);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1211  		ret = regmap_write(data->regmap, reg + BMA400_GEN_CONFIG2_OFF,
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1212  				   val);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1213  		mutex_unlock(&data->mutex);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1214  		return ret;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1215  	case IIO_EV_INFO_PERIOD:
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1216  		if (val < 1 || val > 65535)
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1217  			return -EINVAL;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1218  
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1219  		put_unaligned_be16(val, duration);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1220  
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1221  		mutex_lock(&data->mutex);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1222  		ret = regmap_bulk_write(data->regmap,
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1223  					reg + BMA400_GEN_CONFIG3_OFF,
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1224  					duration, sizeof(duration));
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1225  		mutex_unlock(&data->mutex);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1226  		return ret;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1227  	case IIO_EV_INFO_HYSTERESIS:
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1228  		if (val < 0 || val > 3)
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1229  			return -EINVAL;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1230  
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1231  		mutex_lock(&data->mutex);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1232  		ret = regmap_update_bits(data->regmap, reg,
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1233  					 BMA400_GEN_HYST_MSK,
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1234  					 FIELD_PREP(BMA400_GEN_HYST_MSK, val));
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1235  		mutex_unlock(&data->mutex);
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1236  		return ret;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1237  	default:
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1238  		return -EINVAL;
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1239  	}
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1240  }
15ee6de45ed7a02 Jagath Jog J 2022-04-12  1241  

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

^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [PATCH v3 4/9] iio: accel: bma400: Add triggered buffer support
@ 2022-04-12  8:27 kernel test robot
  0 siblings, 0 replies; 31+ messages in thread
From: kernel test robot @ 2022-04-12  8:27 UTC (permalink / raw)
  To: kbuild

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

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
In-Reply-To: <20220411203133.19929-5-jagathjog1996@gmail.com>
References: <20220411203133.19929-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 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: 12 hours ago
:::::: commit date: 12 hours ago
config: arm-randconfig-c002-20220411 (https://download.01.org/0day-ci/archive/20220412/202204121617.YJhBD8uR-lkp(a)intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project fe2478d44e4f7f191c43fef629ac7a23d0251e72)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/intel-lab-lkp/linux/commit/6882789b10dba397445c4d97986430a20d536fbd
        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 6882789b10dba397445c4d97986430a20d536fbd
        # save the config file to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm clang-analyzer 

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


clang-analyzer warnings: (new ones prefixed by >>)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:265:2: note: expanded from macro '__fortify_memset_chk'
           __underlying_memset(p, c, __fortify_size);                      \
           ^~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:47:29: note: expanded from macro '__underlying_memset'
   #define __underlying_memset     __builtin_memset
                                   ^~~~~~~~~~~~~~~~
   drivers/hwmon/pmbus/max20730.c:730:3: note: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11
                   memset(data->vout_voltage_divider, 0, sizeof(data->vout_voltage_divider));
                   ^
   include/linux/fortify-string.h:272:25: note: expanded from macro 'memset'
   #define memset(p, c, s) __fortify_memset_chk(p, c, s,                   \
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:265:2: note: expanded from macro '__fortify_memset_chk'
           __underlying_memset(p, c, __fortify_size);                      \
           ^~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:47:29: note: expanded from macro '__underlying_memset'
   #define __underlying_memset     __builtin_memset
                                   ^~~~~~~~~~~~~~~~
   Suppressed 52 warnings (52 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   46 warnings generated.
   Suppressed 46 warnings (46 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   61 warnings generated.
   drivers/regulator/virtual.c:112:9: warning: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           return sprintf(buf, "%d\n", data->min_uV);
                  ^~~~~~~
   drivers/regulator/virtual.c:112:9: note: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11
           return sprintf(buf, "%d\n", data->min_uV);
                  ^~~~~~~
   drivers/regulator/virtual.c:138:9: warning: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           return sprintf(buf, "%d\n", data->max_uV);
                  ^~~~~~~
   drivers/regulator/virtual.c:138:9: note: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11
           return sprintf(buf, "%d\n", data->max_uV);
                  ^~~~~~~
   drivers/regulator/virtual.c:164:9: warning: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           return sprintf(buf, "%d\n", data->min_uA);
                  ^~~~~~~
   drivers/regulator/virtual.c:164:9: note: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11
           return sprintf(buf, "%d\n", data->min_uA);
                  ^~~~~~~
   drivers/regulator/virtual.c:190:9: warning: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           return sprintf(buf, "%d\n", data->max_uA);
                  ^~~~~~~
   drivers/regulator/virtual.c:190:9: note: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11
           return sprintf(buf, "%d\n", data->max_uA);
                  ^~~~~~~
   drivers/regulator/virtual.c:219:10: warning: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   return sprintf(buf, "fast\n");
                          ^~~~~~~
   drivers/regulator/virtual.c:219:10: note: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11
                   return sprintf(buf, "fast\n");
                          ^~~~~~~
   drivers/regulator/virtual.c:221:10: warning: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   return sprintf(buf, "normal\n");
                          ^~~~~~~
   drivers/regulator/virtual.c:221:10: note: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11
                   return sprintf(buf, "normal\n");
                          ^~~~~~~
   drivers/regulator/virtual.c:223:10: warning: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   return sprintf(buf, "idle\n");
                          ^~~~~~~
   drivers/regulator/virtual.c:223:10: note: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11
                   return sprintf(buf, "idle\n");
                          ^~~~~~~
   drivers/regulator/virtual.c:225:10: warning: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   return sprintf(buf, "standby\n");
                          ^~~~~~~
   drivers/regulator/virtual.c:225:10: note: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11
                   return sprintf(buf, "standby\n");
                          ^~~~~~~
   drivers/regulator/virtual.c:227:10: warning: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   return sprintf(buf, "unknown\n");
                          ^~~~~~~
   drivers/regulator/virtual.c:227:10: note: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11
                   return sprintf(buf, "unknown\n");
                          ^~~~~~~
   Suppressed 52 warnings (52 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   52 warnings generated.
   Suppressed 52 warnings (52 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   45 warnings generated.
   drivers/iio/accel/bma220_spi.c:62:8: warning: Excessive padding in 'struct bma220_data' (34 padding bytes, where 2 is optimal). 
   Optimal fields order: 
   tx_buf, 
   spi_device, 
   scan, 
   lock, 
   consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
   struct bma220_data {
   ~~~~~~~^~~~~~~~~~~~~
   drivers/iio/accel/bma220_spi.c:62:8: note: Excessive padding in 'struct bma220_data' (34 padding bytes, where 2 is optimal). Optimal fields order: tx_buf, spi_device, scan, lock, consider reordering the fields or adding explicit padding members
   struct bma220_data {
   ~~~~~~~^~~~~~~~~~~~~
   Suppressed 44 warnings (44 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   54 warnings generated.
>> drivers/iio/accel/bma400_core.c:59:8: warning: Excessive padding in 'struct bma400_data' (44 padding bytes, where 12 is optimal). 
   Optimal fields order: 
   buffer, 
   dev, 
   regmap, 
   power_mode, 
   oversampling_ratio, 
   scale, 
   trig, 
   sample_freq, 
   regulators, 
   orientation, 
   mutex, 
   consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
   struct bma400_data {
   ~~~~~~~^~~~~~~~~~~~~
   drivers/iio/accel/bma400_core.c:59:8: note: Excessive padding in 'struct bma400_data' (44 padding bytes, where 12 is optimal). Optimal fields order: buffer, dev, regmap, power_mode, oversampling_ratio, scale, trig, sample_freq, regulators, orientation, mutex, consider reordering the fields or adding explicit padding members
   struct bma400_data {
   ~~~~~~~^~~~~~~~~~~~~
   drivers/iio/accel/bma400_core.c:269:31: warning: The result of the right shift is undefined because the right operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult]
           *val = BMA400_ACC_ODR_MAX_HZ >> (BMA400_ACC_ODR_MAX_RAW - raw);
                                        ^
   drivers/iio/accel/bma400_core.c:793:2: note: Control jumps to 'case IIO_CHAN_INFO_SAMP_FREQ:'  at line 794
           switch (mask) {
           ^
   drivers/iio/accel/bma400_core.c:799:7: note: Assuming field 'type' is equal to IIO_ACCEL
                   if (chan->type != IIO_ACCEL)
                       ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/iio/accel/bma400_core.c:799:3: note: Taking false branch
                   if (chan->type != IIO_ACCEL)
                   ^
   drivers/iio/accel/bma400_core.c:803:9: note: Calling 'bma400_set_accel_output_data_rate'
                   ret = bma400_set_accel_output_data_rate(data, val, val2);
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/iio/accel/bma400_core.c:333:6: note: Assuming 'hz' is >= BMA400_ACC_ODR_MIN_WHOLE_HZ
           if (hz >= BMA400_ACC_ODR_MIN_WHOLE_HZ) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/iio/accel/bma400_core.c:333:2: note: Taking true branch
           if (hz >= BMA400_ACC_ODR_MIN_WHOLE_HZ) {
           ^
   drivers/iio/accel/bma400_core.c:334:7: note: Assuming 'uhz' is 0
                   if (uhz || hz > BMA400_ACC_ODR_MAX_HZ)
                       ^~~
   drivers/iio/accel/bma400_core.c:334:7: note: Left side of '||' is false
   drivers/iio/accel/bma400_core.c:334:14: note: Assuming 'hz' is <= BMA400_ACC_ODR_MAX_HZ
                   if (uhz || hz > BMA400_ACC_ODR_MAX_HZ)
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/iio/accel/bma400_core.c:334:3: note: Taking false branch
                   if (uhz || hz > BMA400_ACC_ODR_MAX_HZ)
                   ^
   drivers/iio/accel/bma400_core.c:340:7: note: Assuming the condition is false
                   if (hz >> idx != BMA400_ACC_ODR_MIN_WHOLE_HZ)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/iio/accel/bma400_core.c:340:3: note: Taking false branch
                   if (hz >> idx != BMA400_ACC_ODR_MIN_WHOLE_HZ)
                   ^
   drivers/iio/accel/bma400_core.c:351:6: note: Assuming 'ret' is 0
           if (ret)
               ^~~
   drivers/iio/accel/bma400_core.c:351:2: note: Taking false branch
           if (ret)
           ^
   drivers/iio/accel/bma400_core.c:358:6: note: Assuming 'ret' is 0
           if (ret)
               ^~~
   drivers/iio/accel/bma400_core.c:358:2: note: Taking false branch
           if (ret)
           ^
   drivers/iio/accel/bma400_core.c:361:2: note: Calling 'bma400_output_data_rate_from_raw'
           bma400_output_data_rate_from_raw(idx, &data->sample_freq.hz,
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/iio/accel/bma400_core.c:269:31: note: The result of the right shift is undefined because the right operand is negative
           *val = BMA400_ACC_ODR_MAX_HZ >> (BMA400_ACC_ODR_MAX_RAW - raw);
                                        ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Suppressed 52 warnings (52 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   42 warnings generated.
   Suppressed 42 warnings (42 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   42 warnings generated.
   Suppressed 42 warnings (42 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   44 warnings generated.
   kernel/cgroup/cgroup-v1.c:1103:3: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
                   strcpy(root->release_agent_path, ctx->release_agent);
                   ^~~~~~
   kernel/cgroup/cgroup-v1.c:1103:3: note: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
                   strcpy(root->release_agent_path, ctx->release_agent);
                   ^~~~~~
   Suppressed 43 warnings (43 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   43 warnings generated.
   Suppressed 43 warnings (43 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   35 warnings generated.
   Suppressed 35 warnings (35 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   18 warnings generated.
   Suppressed 18 warnings (18 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   19 warnings generated.

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

465c811f1f201a Dan Robertson 2019-12-20  58  
465c811f1f201a Dan Robertson 2019-12-20 @59  struct bma400_data {
465c811f1f201a Dan Robertson 2019-12-20  60  	struct device *dev;
465c811f1f201a Dan Robertson 2019-12-20  61  	struct regmap *regmap;
3cf7ded15e4046 Dan Robertson 2019-12-20  62  	struct regulator_bulk_data regulators[BMA400_NUM_REGULATORS];
465c811f1f201a Dan Robertson 2019-12-20  63  	struct mutex mutex; /* data register lock */
465c811f1f201a Dan Robertson 2019-12-20  64  	struct iio_mount_matrix orientation;
465c811f1f201a Dan Robertson 2019-12-20  65  	enum bma400_power_mode power_mode;
465c811f1f201a Dan Robertson 2019-12-20  66  	struct bma400_sample_freq sample_freq;
465c811f1f201a Dan Robertson 2019-12-20  67  	int oversampling_ratio;
465c811f1f201a Dan Robertson 2019-12-20  68  	int scale;
6882789b10dba3 Jagath Jog J  2022-04-12  69  	struct iio_trigger *trig;
6882789b10dba3 Jagath Jog J  2022-04-12  70  	/* Correct time stamp alignment */
6882789b10dba3 Jagath Jog J  2022-04-12  71  	struct {
6882789b10dba3 Jagath Jog J  2022-04-12  72  		__le16 buff[3];
6882789b10dba3 Jagath Jog J  2022-04-12  73  		u8 temperature;
6882789b10dba3 Jagath Jog J  2022-04-12  74  		s64 ts __aligned(8);
6882789b10dba3 Jagath Jog J  2022-04-12  75  	} buffer ____cacheline_aligned;
465c811f1f201a Dan Robertson 2019-12-20  76  };
465c811f1f201a Dan Robertson 2019-12-20  77  

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

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

end of thread, other threads:[~2022-04-25 12:03 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 1/9] iio: accel: bma400: Fix the scale min and max macro values Jagath Jog J
2022-04-12  8:59   ` Andy Shevchenko
2022-04-11 20:31 ` [PATCH v3 2/9] iio: accel: bma400: Reordering of header files Jagath Jog J
2022-04-12  9:00   ` Andy Shevchenko
2022-04-11 20:31 ` [PATCH v3 3/9] iio: accel: bma400: conversion to device-managed function Jagath Jog J
2022-04-12  9:04   ` Andy Shevchenko
2022-04-11 20:31 ` [PATCH v3 4/9] iio: accel: bma400: Add triggered buffer support Jagath Jog J
2022-04-12  9:12   ` Andy Shevchenko
2022-04-12 19:30     ` Jagath Jog J
     [not found]       ` <CAHp75Vc9MO2GxX81JQfzGRjM=nWLaQ-Uy9bV-dR1GMj1oQwjSQ@mail.gmail.com>
     [not found]         ` <CAHp75Vef21YmiKAvz-Kt-C=jb+mMCJeV_fwPAza9UwCuKy6omQ@mail.gmail.com>
2022-04-13 14:23           ` Jagath Jog J
2022-04-14 13:22             ` Jagath Jog J
2022-04-16 16:38   ` Jonathan Cameron
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
2022-04-11 20:31 ` [PATCH v3 6/9] iio: accel: bma400: Add step change event Jagath Jog J
2022-04-11 20:31 ` [PATCH v3 7/9] iio: accel: bma400: Add activity recognition support Jagath Jog J
2022-04-16 16:47   ` Jonathan Cameron
2022-04-11 20:31 ` [PATCH v3 8/9] iio: accel: bma400: Add debugfs register access support Jagath Jog J
2022-04-16 16:48   ` Jonathan Cameron
2022-04-11 20:31 ` [PATCH v3 9/9] iio: accel: bma400: Add support for activity and inactivity events Jagath Jog J
2022-04-12  5:21   ` kernel test robot
2022-04-12 10:41   ` kernel test robot
2022-04-16 16:55   ` Jonathan Cameron
2022-04-18 22:09     ` Jagath Jog J
2022-04-24 15:40       ` Jonathan Cameron
2022-04-25 12:03         ` jagath jogj
2022-04-12  6:44 kernel test robot
2022-04-12  7:38 ` Dan Carpenter
2022-04-12  7:38 ` Dan Carpenter
2022-04-12  8:27 [PATCH v3 4/9] iio: accel: bma400: Add triggered buffer support kernel test robot

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.