Re: [PATCH v2 2/3] iio: accel: adxl380: Introduce helper function for activity detection
From: Andy Shevchenko
Date: Thu Jan 15 2026 - 15:28:12 EST
On Thu, Jan 15, 2026 at 06:53:49PM +0100, Francesco Lavra wrote:
> Motion detection functionalities (such as activity and inactivity
> detection) are only available when the chip is in a low-power mode; this
> affects the available sampling frequency values.
> In preparation for adding support for a new frequency value, introduce a
> helper function that checks whether activity/inactivity detection is
> currently enabled; this function will be reused in a future commit to
> determine what frequency values are available at any given time.
> No functional changes.
...
> +static int adxl380_act_inact_enabled(struct adxl380_state *st, bool *enabled)
> +{
> + unsigned int act_inact_ctl;
> + int ret;
> +
> + if (!st->chip_info->has_low_power) {
> + *enabled = false;
> + return 0;
> + }
> +
> + ret = regmap_read(st->regmap, ADXL380_ACT_INACT_CTL_REG, &act_inact_ctl);
> + if (!ret)
What's wrong with the standard pattern?
if (ret)
return ret;
> + *enabled = FIELD_GET(ADXL380_ACT_EN_MSK, act_inact_ctl) ||
> + FIELD_GET(ADXL380_INACT_EN_MSK, act_inact_ctl);
> +
> + return ret;
return 0;
> +}
--
With Best Regards,
Andy Shevchenko