]> www.infradead.org Git - users/jedix/linux-maple.git/commit
media: v4l2-subdev: Provide const-aware subdev state accessors
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Wed, 8 May 2024 21:40:43 +0000 (00:40 +0300)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Tue, 4 Jun 2024 06:31:25 +0000 (08:31 +0200)
commit85af84852f115d3c9d4b45b0500315e630baa82c
treede5f903cceb731ca2172285291f62f326ad34589
parente73412fdeb541e777b3fd50b665781c1856422b5
media: v4l2-subdev: Provide const-aware subdev state accessors

It would be useful to mark instances of v4l2_subdev_state structures as
const when code needs to access them read-only. This isn't currently
possible, as the v4l2_subdev_state_get_*() accessor functions take a
non-const pointer to the state.

Use _Generic() to provide two different versions of the accessors, for
const and non-const states respectively. The former returns a const
pointer to the requested format, rectangle or interval, implementing
const-correctness. The latter returns a non-const pointer, preserving
the current behaviour for drivers.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
[Sakari Ailus: Drop the word "below" from the text.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
include/media/v4l2-subdev.h