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

Laurent Pinchart laurent.pinchart+renesas at ideasonboard.com
Tue May 7 09:19:05 PDT 2024


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 v2, patch 1/2 uses explicit types as _Generic() selectors,
and fixes an issue with the const cast of the value.

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
-- 
Regards,

Laurent Pinchart




More information about the Linux-rockchip mailing list