Re: [PATCH v3 1/6] iio: imu: adis: Add optional self_test callback and fix custom reset dispatch
From: Andy Shevchenko
Date: Thu Oct 15 2026 - 16:01:38 EST
On Thu, Oct 15, 2026 at 12:32:58PM +0300, Radu Sabau via B4 Relay wrote:
> Add an optional self_test callback to struct adis_data, for devices
> whose self-test doesn't fit the generic mask-write/sleep/check-status
> sequence. Purely additive: defaults to NULL, no change for existing
> drivers.
>
> Also fix __adis_initial_startup()'s no-reset-gpio path: it called
> __adis_reset() directly instead of adis->ops->reset(), silently
> ignoring any driver's custom reset implementation. Invisible until now
> since adis_default_ops.reset is __adis_reset() itself. Dispatch
> through adis->ops->reset() instead, adding the settle-time sleep at
> the call site for custom ops (documented not to sleep internally)
> while skipping it for the default op (which already sleeps
> internally).
...
> - ret = __adis_reset(adis);
> + ret = adis->ops->reset(adis);
> + if (ret)
> + return ret;
> + /*
> + * __adis_reset() already sleeps the settle time internally.
> + * Custom reset ops are documented (struct adis_ops::reset)
> + * not to, so sleep here for them.
> + */
> + if (adis->ops->reset != __adis_reset)
> + msleep(timeouts->sw_reset_ms);
Can't we simply stubbed ->reset to a wrapper on top of the msleep()?
...
> static inline int adis_reset(struct adis *adis)
> {
> + int ret;
> +
> guard(mutex)(&adis->state_lock);
> - return __adis_reset(adis);
> +
> + ret = adis->ops->reset(adis);
> + if (ret)
> + return ret;
> +
> + /*
> + * __adis_reset() already sleeps the settle time internally. Custom
> + * reset ops are documented (struct adis_ops::reset) not to, so sleep
> + * here for them.
> + */
> + if (adis->ops->reset != __adis_reset)
> + msleep(adis->data->timeouts->sw_reset_ms);
It doesn't look scalable to have this accompanying each ->reset() call.
> + return 0;
> }
--
With Best Regards,
Andy Shevchenko