Re: [PATCH v7 4/8] iio: accel: mma8452: Support interrupt sharing

From: Andy Shevchenko

Date: Mon Aug 31 2026 - 14:54:55 EST


On Mon, Aug 31, 2026 at 02:17:07PM +0200, Esben Haabendal wrote:
> Adding handling of rutnime PM suspension in the interrupt handler allows
> sharing interrupt with other devices.
>
> Keep in mind that the device by default is using push-pull for the irq pin,
> which might require additional hardware design to allow interrupt sharing.
>
> The suspended flag is added together with synchronize_irq() in order to
> protect against race conditions when doing runtime suspend and device
> removal. This way we ensure that interrupt handler does not try to access
> the device while regulators are disabled.

...

> static int mma8452_runtime_resume(struct device *dev)

> return ret;
> }
>
> + WRITE_ONCE(data->suspended, false);
> +
> ret = mma8452_active(data);
> if (ret < 0)
> goto runtime_resume_failed;

> return 0;
>
> runtime_resume_failed:
> + WRITE_ONCE(data->suspended, true);
> regulator_disable(data->vddio_reg);
> regulator_disable(data->vdd_reg);

But with this, what's the point in having WRITE_ONCE()? It can be read
just in the middle as true and be immediately changed afterwards. It
may be that I am missing something, but I think WRITE_ONCE() should be
done once in this function.

--
With Best Regards,
Andy Shevchenko