[PATCH V11 5/9] iio: imu: inv_icm42607: Add PM support for icm42607
Andy Shevchenko
andriy.shevchenko at intel.com
Thu Jun 11 01:00:17 PDT 2026
On Wed, Jun 10, 2026 at 12:54:49PM -0500, Chris Morgan wrote:
> Add power management support for the ICM42607 device driver.
...
> struct inv_icm42607_state {
> struct mutex lock;
> const struct inv_icm42607_hw *hw;
> struct regmap *map;
> struct regulator *vddio_supply;
> + bool vddio_en;
> struct iio_mount_matrix orientation;
> struct inv_icm42607_conf conf;
> + struct inv_icm42607_suspended suspended;
> };
When adding a new member to the data structure always consult with `pahole`
tool to see if the layout is the best fit.
...
> +/*
> + * Suspend delay assumed from other icm42600 series device, not
> + * documented in datasheet.
> + */
> +#define INV_ICM42607_SUSPEND_DELAY_MS 2000
2 * USEC_PER_MSEC
...
> + sleepval = 0;
> + if (temp && !oldtemp)
> + sleepval = max(sleepval, INV_ICM42607_TEMP_STARTUP_TIME_MS);
> +
> + if (accel != oldaccel)
> + sleepval = max(sleepval, INV_ICM42607_ACCEL_STARTUP_TIME_MS);
> +
> + if (gyro != oldgyro)
> + sleepval = max(sleepval, INV_ICM42607_GYRO_STARTUP_TIME_MS);
> +
> + if (sleep_ms)
> + *sleep_ms = sleepval;
> + else if (sleepval)
> + fsleep(sleepval * USEC_PER_MSEC);
Also good to have a _ms suffis in sleepval.
...
> + dev_set_drvdata(dev, st);
This what requires device.h. So, you can start with it whenever you first need
dev_printk.h, devres/*.h, but it doesn't mean you are supposed to drop other
non-device.h related headers, such as err.h.
...
> +EXPORT_NS_GPL_DEV_PM_OPS(inv_icm42607_pm_ops, IIO_ICM42607) = {
> + SYSTEM_SLEEP_PM_OPS(inv_icm42607_suspend, inv_icm42607_resume)
> + RUNTIME_PM_OPS(inv_icm42607_runtime_suspend,
> + inv_icm42607_runtime_resume, NULL)
Keep it logically split, either as
RUNTIME_PM_OPS(inv_icm42607_runtime_suspend, inv_icm42607_runtime_resume, NULL)
or as
RUNTIME_PM_OPS(inv_icm42607_runtime_suspend,
inv_icm42607_runtime_resume,
NULL)
> +};
--
With Best Regards,
Andy Shevchenko
More information about the Linux-rockchip
mailing list