Subject: [PATCH 11/16] media: sun6i-csi: Tidy up and unify coding style

From: Paul Kocialkowski <[email-masked]>
Date: Mon, 18 May 2026 12:24:46 +0200

Bring recent changes to the same coding style as the rest of the driver.
This is purely cosmetic and no functional change is intended.

Signed-off-by: Paul Kocialkowski <[email-masked]>
---
 .../sunxi/sun6i-csi/sun6i_csi_bridge.c        | 16 ++---
 .../sunxi/sun6i-csi/sun6i_csi_capture.c       | 72 ++++++++++---------
 2 files changed, 46 insertions(+), 42 deletions(-)

diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c
index 43a85bcc2ba2..18f79075d3ad 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c
@@ -473,6 +473,7 @@ static int sun6i_csi_bridge_s_stream(struct v4l2_subdev *subdev, int on)
 
 unlock:
 	v4l2_subdev_unlock_state(state);
+
 	return ret;
 }
 
@@ -533,7 +534,7 @@ static int sun6i_csi_bridge_set_fmt(struct v4l2_subdev *subdev,
 				    struct v4l2_subdev_state *state,
 				    struct v4l2_subdev_format *format)
 {
-	struct v4l2_mbus_framefmt *fmt;
+	struct v4l2_mbus_framefmt *mbus_format;
 
 	/* The format on the source pad always matches the sink pad. */
 	if (format->pad != SUN6I_CSI_BRIDGE_PAD_SINK)
@@ -542,12 +543,12 @@ static int sun6i_csi_bridge_set_fmt(struct v4l2_subdev *subdev,
 	sun6i_csi_bridge_mbus_format_prepare(&format->format);
 
 	/* Set the format on the sink pad. */
-	fmt = v4l2_subdev_state_get_format(state, format->pad);
-	*fmt = format->format;
+	mbus_format = v4l2_subdev_state_get_format(state, format->pad);
+	*mbus_format = format->format;
 
 	/* Propagate the format to the source pad. */
-	fmt = v4l2_subdev_state_get_format(state, SUN6I_CSI_BRIDGE_PAD_SOURCE);
-	*fmt = format->format;
+	mbus_format = v4l2_subdev_state_get_format(state, SUN6I_CSI_BRIDGE_PAD_SOURCE);
+	*mbus_format = format->format;
 
 	return 0;
 }
@@ -779,14 +780,12 @@ int sun6i_csi_bridge_setup(struct sun6i_csi_device *csi_dev)
 	if (ret < 0)
 		return ret;
 
-	/* V4L2 Subdev finalize */
+	/* V4L2 Subdev */
 
 	ret = v4l2_subdev_init_finalize(subdev);
 	if (ret < 0)
 		goto error_media_entity;
 
-	/* V4L2 Subdev */
-
 	if (csi_dev->isp_available)
 		ret = v4l2_async_register_subdev(subdev);
 	else
@@ -846,7 +845,6 @@ void sun6i_csi_bridge_cleanup(struct sun6i_csi_device *csi_dev)
 	v4l2_async_nf_cleanup(notifier);
 
 	v4l2_device_unregister_subdev(subdev);
-
 	v4l2_subdev_cleanup(subdev);
 
 	media_entity_cleanup(&subdev->entity);
diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
index 409c28621093..eea682f47eea 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
@@ -812,27 +812,6 @@ static int sun6i_csi_capture_enum_fmt(struct file *file, void *priv,
 	return -EINVAL;
 }
 
-static int sun6i_csi_capture_enum_framesize(struct file *file, void *fh,
-					    struct v4l2_frmsizeenum *fsize)
-{
-	if (fsize->index)
-		return -EINVAL;
-
-	/* Only accept format in map table. */
-	if (!sun6i_csi_capture_format_find(fsize->pixel_format))
-		return -EINVAL;
-
-	fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
-	fsize->stepwise.min_width = SUN6I_CSI_CAPTURE_WIDTH_MIN;
-	fsize->stepwise.max_width = SUN6I_CSI_CAPTURE_WIDTH_MAX;
-	fsize->stepwise.min_height = SUN6I_CSI_CAPTURE_HEIGHT_MIN;
-	fsize->stepwise.max_height = SUN6I_CSI_CAPTURE_HEIGHT_MAX;
-	fsize->stepwise.step_width = 2;
-	fsize->stepwise.step_height = 2;
-
-	return 0;
-}
-
 static int sun6i_csi_capture_g_fmt(struct file *file, void *priv,
 				   struct v4l2_format *format)
 {
@@ -867,6 +846,27 @@ static int sun6i_csi_capture_try_fmt(struct file *file, void *priv,
 	return 0;
 }
 
+static int sun6i_csi_capture_enum_framesizes(struct file *file, void *fh,
+					     struct v4l2_frmsizeenum *frmsize)
+{
+	if (frmsize->index)
+		return -EINVAL;
+
+	/* Only accept format in map table. */
+	if (!sun6i_csi_capture_format_find(frmsize->pixel_format))
+		return -EINVAL;
+
+	frmsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
+	frmsize->stepwise.min_width = SUN6I_CSI_CAPTURE_WIDTH_MIN;
+	frmsize->stepwise.max_width = SUN6I_CSI_CAPTURE_WIDTH_MAX;
+	frmsize->stepwise.min_height = SUN6I_CSI_CAPTURE_HEIGHT_MIN;
+	frmsize->stepwise.max_height = SUN6I_CSI_CAPTURE_HEIGHT_MAX;
+	frmsize->stepwise.step_width = 2;
+	frmsize->stepwise.step_height = 2;
+
+	return 0;
+}
+
 static int sun6i_csi_capture_enum_input(struct file *file, void *priv,
 					struct v4l2_input *input)
 {
@@ -900,11 +900,12 @@ static const struct v4l2_ioctl_ops sun6i_csi_capture_ioctl_ops = {
 	.vidioc_querycap		= sun6i_csi_capture_querycap,
 
 	.vidioc_enum_fmt_vid_cap	= sun6i_csi_capture_enum_fmt,
-	.vidioc_enum_framesizes		= sun6i_csi_capture_enum_framesize,
 	.vidioc_g_fmt_vid_cap		= sun6i_csi_capture_g_fmt,
 	.vidioc_s_fmt_vid_cap		= sun6i_csi_capture_s_fmt,
 	.vidioc_try_fmt_vid_cap		= sun6i_csi_capture_try_fmt,
 
+	.vidioc_enum_framesizes		= sun6i_csi_capture_enum_framesizes,
+
 	.vidioc_enum_input		= sun6i_csi_capture_enum_input,
 	.vidioc_g_input			= sun6i_csi_capture_g_input,
 	.vidioc_s_input			= sun6i_csi_capture_s_input,
@@ -984,16 +985,17 @@ static int sun6i_csi_capture_link_validate(struct media_link *link)
 		media_entity_to_video_device(link->sink->entity);
 	struct sun6i_csi_device *csi_dev = video_get_drvdata(video_dev);
 	struct v4l2_device *v4l2_dev = csi_dev->v4l2_dev;
-	struct v4l2_subdev *src_subdev =
+	struct v4l2_subdev *bridge_subdev =
 		media_entity_to_v4l2_subdev(link->source->entity);
 	const struct sun6i_csi_capture_format *capture_format;
 	const struct sun6i_csi_bridge_format *bridge_format;
 	unsigned int capture_width, capture_height;
-	struct v4l2_subdev_format src_fmt = {
-		.which = V4L2_SUBDEV_FORMAT_ACTIVE,
-		.pad = link->source->index
+	unsigned int bridge_width, bridge_height;
+	struct v4l2_subdev_format bridge_subdev_format = {
+		.which	= V4L2_SUBDEV_FORMAT_ACTIVE,
+		.pad	= link->source->index,
 	};
-	u32 pixelformat, capture_field;
+	u32 pixelformat, capture_field, mbus_code;
 	int ret;
 
 	sun6i_csi_capture_dimensions(csi_dev, &capture_width, &capture_height);
@@ -1004,21 +1006,25 @@ static int sun6i_csi_capture_link_validate(struct media_link *link)
 		return -EINVAL;
 
 	/* Resolve csi bridge format. */
-	ret = v4l2_subdev_call(src_subdev, pad, get_fmt, NULL, &src_fmt);
+	ret = v4l2_subdev_call(bridge_subdev, pad, get_fmt, NULL,
+			       &bridge_subdev_format);
 	if (ret)
 		return ret;
 
-	bridge_format = sun6i_csi_bridge_format_find(src_fmt.format.code);
+	bridge_width = bridge_subdev_format.format.width;
+	bridge_height = bridge_subdev_format.format.height;
+	mbus_code = bridge_subdev_format.format.code;
+
+	bridge_format = sun6i_csi_bridge_format_find(mbus_code);
 	if (WARN_ON(!bridge_format))
 		return -EINVAL;
 
 	/* No cropping/scaling is supported. */
-	if (capture_width != src_fmt.format.width ||
-	    capture_height != src_fmt.format.height) {
+	if (capture_width != bridge_width || capture_height != bridge_height) {
 		v4l2_err(v4l2_dev,
 			 "invalid input/output dimensions: %ux%u/%ux%u\n",
-			 src_fmt.format.width, src_fmt.format.height,
-			 capture_width, capture_height);
+			 bridge_width, bridge_height, capture_width,
+			 capture_height);
 		return -EINVAL;
 	}
 
-- 
2.54.0