[PATCH V12 7/9] iio: imu: inv_icm42607: Add Accelerometer for icm42607

Chris Morgan macromorgan at hotmail.com
Mon Jun 15 07:51:40 PDT 2026


On Mon, Jun 15, 2026 at 02:21:05PM +0300, Andy Shevchenko wrote:
> On Thu, Jun 11, 2026 at 03:26:04PM -0500, Chris Morgan wrote:
> 
> > Add icm42607 accelerometer sensor for icm42607.
> 
> ...
> 
> > +++ b/drivers/iio/imu/inv_icm42607/inv_icm42607_accel.c
> 
> Please, please, use IWYU! So many headers are missing...
> (Same comment to all files in this series.)
> 
> + array_size.h
> + bits.h // BIT()
> + cleanup.h // guard()()
> + device/devres.h // devm_kasprintf()
> + err.h // -EINVAL, IS_ERR()
> 
> > +#include <linux/iio/iio.h>
> > +#include <linux/mutex.h>
> > +#include <linux/pm_runtime.h>
> > +#include <linux/regmap.h>
> 
> + types.h // s16, __be16
> 
> Also you need to have
> 
> asm/byteorder.h // be16_to_cpup()

How are you running IWYU against the builds? So far I've tried but I
can't seem to get it to run properly. 

> 
> ...
> 
> > +static int inv_icm42607_accel_read_odr(struct inv_icm42607_state *st,
> > +				       int *val, int *val2)
> > +{
> > +	unsigned int odr;
> > +	unsigned int i;
> > +
> > +	guard(mutex)(&st->lock);
> > +
> > +	odr = st->conf.accel.odr;
> > +
> > +	for (i = 5; i < ARRAY_SIZE(inv_icm42607_accel_odr); ++i) {
> 
> Why pre-increment? Same for all other cases.

The register starts at 5 and all values below 5 are invalid. Starting
this increment at 5 ensures we don't expose invalid values to
userspace.

> 
> > +		if (i == odr)
> > +			break;
> > +	}
> > +	if (i >= ARRAY_SIZE(inv_icm42607_accel_odr))
> > +		return -EINVAL;
> > +
> > +	*val = inv_icm42607_accel_odr[i][0];
> > +	*val2 = inv_icm42607_accel_odr[i][1];
> > +
> > +	return IIO_VAL_INT_PLUS_MICRO;
> > +}
> 
> -- 
> With Best Regards,
> Andy Shevchenko
> 
> 

Thank you,
Chris



More information about the Linux-rockchip mailing list