mbox series

[v2,0/2] media: v4l2-subdev: Support const-awareness in state accessors

Message ID 20240507060323.26950-1-laurent.pinchart+renesas@ideasonboard.com (mailing list archive)
Headers show
Series media: v4l2-subdev: Support const-awareness in state accessors | expand

Message

Laurent Pinchart May 7, 2024, 6:03 a.m. UTC
Hello,

This small patch series comes from a mild annoyance I experienced during
a recent patch review, where I wanted to ask for a pointer to a
v4l2_subdev_state used to access the state in a read-only fashion to be
made const. This wasn't possible as the state accessors functions take a
non-const state pointer, in order to return pointers to mutable formats
and selection rectangles.

Patch 1/2 improves the state accessors to support const states, in the
same wait as the recently introduced container_of_const() macro.
Bikeshedding of the internal macro and function names is expected. Patch
2/2 then shows how this can be used in one driver.

Compared to v1, patch 1/2 uses _Generic() in a single macro to wrap all
calls, instead of duplicating the _Generic() statement in all accessors.

Laurent Pinchart (2):
  media: v4l2-subdev: Provide const-aware subdev state accessors
  media: rkisp1: Mark subdev state pointers as const

 .../platform/rockchip/rkisp1/rkisp1-isp.c     |  8 ++--
 .../platform/rockchip/rkisp1/rkisp1-resizer.c |  8 ++--
 include/media/v4l2-subdev.h                   | 40 +++++++++++++------
 3 files changed, 35 insertions(+), 21 deletions(-)


base-commit: e695668af8523b059127dfa8b261c76e7c9cde10