public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] media: v4l2-subdev: Add cleanup macros for active state
@ 2024-09-17 14:09 Tomi Valkeinen
  2024-09-17 14:09 ` [PATCH 1/4] " Tomi Valkeinen
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Tomi Valkeinen @ 2024-09-17 14:09 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Niklas Söderlund, Hans Verkuil,
	Sakari Ailus, Laurent Pinchart
  Cc: linux-media, linux-kernel, linux-renesas-soc, Tomi Valkeinen

Add cleanup macros for the subdev active state. While we could add more
macros to handle state locking in different situations, I believe the
two macros introduced here are the ones most often needed.

A few drivers are changed to use the macros, as an example.

A few thoughts:

The scoped_v4l2_subdev_lock_and_get_active_state() macro will define an
implicitly named 'state' variable inside the scope. This is a bit
similar to scoped_guard(), which defined an implicitly named 'scope'
variable. However, adding the name of the variable as a parameter to the
macro is an easy addition, if needed. Then the usage would be:

    scoped_v4l2_subdev_lock_and_get_active_state(subdev, state) {
    }

Using the CLASS() version does take the name of the variable. The two
macros also look quite different, so I wonder if we should make a helper
macro to hide the CLASS() usage (I don't know what to call it...):

    #define init_v4l2_subdev_lock_and_get_active_state(sd) \
         CLASS(v4l2_subdev_lock_and_get_active_state, state)(sd)

The macro names are quite long, but so is the function name of
'v4l2_subdev_lock_and_get_active_state', which these macros often
replace.

 Tomi

Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
---
Tomi Valkeinen (4):
      media: v4l2-subdev: Add cleanup macros for active state
      media: v4l2-subdev: Use state cleanup macros
      media: renesas: Use state cleanup macros
      media: i2c: ds90ub9xx: Use state cleanup macros

 drivers/media/i2c/ds90ub913.c                      | 11 +++------
 drivers/media/i2c/ds90ub953.c                      | 11 +++------
 drivers/media/i2c/ds90ub960.c                      | 27 +++++++---------------
 drivers/media/platform/renesas/rcar-csi2.c         | 14 ++++-------
 .../media/platform/renesas/rzg2l-cru/rzg2l-csi2.c  |  9 ++++----
 .../media/platform/renesas/rzg2l-cru/rzg2l-ip.c    |  9 ++------
 drivers/media/v4l2-core/v4l2-subdev.c              | 14 +++--------
 include/media/v4l2-subdev.h                        | 10 ++++++++
 8 files changed, 37 insertions(+), 68 deletions(-)
---
base-commit: 98f7e32f20d28ec452afb208f9cffc08448a2652
change-id: 20240917-scoped-state-a995cc0dba33

Best regards,
-- 
Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-09-26 15:26 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-17 14:09 [PATCH 0/4] media: v4l2-subdev: Add cleanup macros for active state Tomi Valkeinen
2024-09-17 14:09 ` [PATCH 1/4] " Tomi Valkeinen
2024-09-24 17:17   ` Laurent Pinchart
2024-09-24 17:53     ` Tomi Valkeinen
2024-09-25 16:35       ` Laurent Pinchart
2024-09-26 15:26         ` Tomi Valkeinen
2024-09-17 14:09 ` [PATCH 2/4] media: v4l2-subdev: Use state cleanup macros Tomi Valkeinen
2024-09-17 14:09 ` [PATCH 3/4] media: renesas: " Tomi Valkeinen
2024-09-22 10:15   ` Niklas Söderlund
2024-09-24 17:24     ` Laurent Pinchart
2024-09-17 14:09 ` [PATCH 4/4] media: i2c: ds90ub9xx: " Tomi Valkeinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox