Re: [PATCH v2 5/9] media: i2c: ov7251: Use sub-device active state
From: Antoine Pichot
Date: Fri Oct 30 2026 - 10:28:21 EST
Hi Andy,
On Thu, Oct 29, 2026 at 04:02:47PM +0200, Andy Shevchenko wrote:
> I'm wondering if v4l2 provides the set of conditional guards and hence
> some kind of ACQUIRE() macro.
Not today. Nothing under include/media or drivers/media defines a
guard class (no DEFINE_GUARD, DEFINE_CLASS, DEFINE_LOCK_GUARD or
DEFINE_FREE), and the state lock is unconditional:
v4l2_subdev_lock_state() is a plain mutex_lock(), so ACQUIRE_ERR()
would have nothing to report.
A guard class could be added: Tomi proposed one in September 2024
[1]; Laurent preferred a __free() annotation and the series stalled.
I would rather not add it in this series. The explicit pair is what
imx290, imx415, ov2740 and ov8858 do in s_stream, and what Sakari
asked to keep in the ov5647 conversion last December [2] until the
driver moves to .enable_streams() and .disable_streams(), after which
the core takes the state lock itself and the pairs go away.
[1] https://lore.kernel.org/linux-media/20240917-scoped-state-v1-0-b8ba3fbe5952@xxxxxxxxxxxxxxxx/
[2] https://lore.kernel.org/linux-media/aVLOlkqSHn-N5Wi0@kekkonen.localdomain/
Thanks,
Antoine