[PATCH] staging: media: atomisp: comprehensive coding style cleanup
From: Laur
Date: Sun Mar 08 2026 - 17:59:26 EST
Clean up atomisp_cmd.c to comply with Linux Kernel coding standards.
This patch addresses multiple checkpatch.pl issues:
-Fixed block comment formatting(trailing */ on separate lines).
-Replaced hardcoded function names in logs with %s and __func__.
-Fixed comma spacing and converted leading spaces to tabs.
-Removed redundant else branches and void return statements.
-Merged multiple line dereferences to improve readability.
Signed-off-by: Laur <laurentiutopai2004@xxxxxxxxx>
---
.../staging/media/atomisp/pci/atomisp_cmd.c | 96 ++++++++++---------
1 file changed, 53 insertions(+), 43 deletions(-)
diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index fec369575..dc9176918 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -262,8 +262,6 @@ int atomisp_reset(struct atomisp_device *isp)
/* Reset ISP by power-cycling it */
int ret = 0;
- dev_dbg(isp->dev, "%s\n", __func__);
-
ret = atomisp_power_off(isp->dev);
if (ret < 0)
dev_err(isp->dev, "atomisp_power_off failed, %d\n", ret);
@@ -1024,11 +1022,9 @@ v4l2_fmt_to_sh_fmt(u32 fmt)
return IA_CSS_FRAME_FORMAT_RGBA888;
case V4L2_PIX_FMT_RGB565:
return IA_CSS_FRAME_FORMAT_RGB565;
-#if 0
case V4L2_PIX_FMT_JPEG:
case V4L2_PIX_FMT_CUSTOM_M10MO_RAW:
return IA_CSS_FRAME_FORMAT_BINARY_8;
-#endif
case V4L2_PIX_FMT_SBGGR16:
case V4L2_PIX_FMT_SBGGR10:
case V4L2_PIX_FMT_SGBRG10:
@@ -1380,8 +1376,10 @@ static void atomisp_update_grid_info(struct atomisp_sub_device *asd,
if (atomisp_css_get_grid_info(asd, pipe_id))
return;
- /* We must free all buffers because they no longer match
- the grid size. */
+ /*
+ * We must free all buffers because they no longer match
+ * the grid size.
+ */
atomisp_css_free_stat_buffers(asd);
err = atomisp_alloc_css_stat_bufs(asd, ATOMISP_INPUT_STREAM_GENERAL);
@@ -1393,8 +1391,10 @@ static void atomisp_update_grid_info(struct atomisp_sub_device *asd,
if (atomisp_alloc_3a_output_buf(asd)) {
/* Failure for 3A buffers does not influence DIS buffers */
if (asd->params.s3a_output_bytes != 0) {
- /* For SOC sensor happens s3a_output_bytes == 0,
- * using if condition to exclude false error log */
+ /*
+ * For SOC sensor happens s3a_output_bytes == 0,
+ * using if condition to exclude false error log
+ */
dev_err(isp->dev, "Failed to allocate memory for 3A statistics\n");
}
goto err;
@@ -1415,7 +1415,7 @@ static void atomisp_update_grid_info(struct atomisp_sub_device *asd,
err:
atomisp_css_free_stat_buffers(asd);
- return;
+
}
static void atomisp_curr_user_grid_info(struct atomisp_sub_device *asd,
@@ -1589,7 +1589,6 @@ int atomisp_get_dis_stat(struct atomisp_sub_device *asd,
int atomisp_set_array_res(struct atomisp_sub_device *asd,
struct atomisp_resolution *config)
{
- dev_dbg(asd->isp->dev, ">%s start\n", __func__);
if (!config) {
dev_err(asd->isp->dev, "Set sensor array size is not valid\n");
return -EINVAL;
@@ -1687,8 +1686,9 @@ int atomisp_3a_stat(struct atomisp_sub_device *asd, int flag,
if (atomisp_compare_grid(asd, &config->grid_info) != 0) {
/* If the grid info in the argument differs from the current
- grid info, we tell the caller to reset the grid size and
- try again. */
+ * grid info, we tell the caller to reset the grid size and
+ * try again.
+ */
return -EAGAIN;
}
@@ -1885,8 +1885,8 @@ int atomisp_calculate_real_zoom_region(struct atomisp_sub_device *asd,
* Function to check the zoom region whether is effective
*/
static bool atomisp_check_zoom_region(
- struct atomisp_sub_device *asd,
- struct ia_css_dz_config *dz_config)
+ struct atomisp_sub_device *asd,
+ struct ia_css_dz_config *dz_config)
{
struct atomisp_resolution config;
bool flag = false;
@@ -1920,8 +1920,8 @@ static bool atomisp_check_zoom_region(
}
void atomisp_apply_css_parameters(
- struct atomisp_sub_device *asd,
- struct atomisp_css_params *css_param)
+ struct atomisp_sub_device *asd,
+ struct atomisp_css_params *css_param)
{
if (css_param->update_flag.wb_config)
asd->params.config.wb_config = &css_param->wb_config;
@@ -2032,7 +2032,7 @@ static unsigned int long copy_from_compatible(void *to, const void *from,
{
if (from_user)
return copy_from_user(to, (void __user *)from, n);
- else
+
memcpy(to, from, n);
return 0;
}
@@ -2462,9 +2462,11 @@ int atomisp_css_cp_dvs2_coefs(struct atomisp_sub_device *asd,
if (sizeof(*cur) != sizeof(coefs->grid) ||
memcmp(&coefs->grid, cur, sizeof(coefs->grid))) {
dev_err(asd->isp->dev, "dvs grid mismatch!\n");
- /* If the grid info in the argument differs from the current
- grid info, we tell the caller to reset the grid size and
- try again. */
+ /*
+ * If the grid info in the argument differs from the current
+ * grid info, we tell the caller to reset the grid size and
+ * try again.
+ */
return -EAGAIN;
}
@@ -2518,9 +2520,11 @@ int atomisp_css_cp_dvs2_coefs(struct atomisp_sub_device *asd,
if (sizeof(*cur) != sizeof(dvs2_coefs.grid) ||
memcmp(&dvs2_coefs.grid, cur, sizeof(dvs2_coefs.grid))) {
dev_err(asd->isp->dev, "dvs grid mismatch!\n");
- /* If the grid info in the argument differs from the current
- grid info, we tell the caller to reset the grid size and
- try again. */
+ /*
+ * If the grid info in the argument differs from the current
+ * grid info, we tell the caller to reset the grid size and
+ * try again.
+ */
return -EAGAIN;
}
@@ -3016,6 +3020,8 @@ int atomisp_param(struct atomisp_sub_device *asd, int flag,
struct ia_css_pipe_config *vp_cfg =
&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].
pipe_configs[IA_CSS_PIPE_ID_VIDEO];
+ struct ia_css_stream_info *s_info =
+ &asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream_info;
/* Read parameter for 3A binary info */
if (flag == 0) {
@@ -3027,13 +3033,12 @@ int atomisp_param(struct atomisp_sub_device *asd, int flag,
/* We always return the resolution and stride even if there is
* no valid metadata. This allows the caller to get the
- * information needed to allocate user-space buffers. */
- config->metadata_config.metadata_height = asd->
- stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream_info.
- metadata_info.resolution.height;
- config->metadata_config.metadata_stride = asd->
- stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream_info.
- metadata_info.stride;
+ * information needed to allocate user-space buffers.
+ */
+ config->metadata_config.metadata_height =
+ s_info->metadata_info.resolution.height;
+ config->metadata_config.metadata_stride =
+ s_info->metadata_info.stride;
/* update dvs grid info */
if (dvs_grid_info)
@@ -3277,8 +3282,10 @@ atomisp_bytesperline_to_padded_width(unsigned int bytesperline,
return bytesperline / 2;
case IA_CSS_FRAME_FORMAT_RGBA888:
return bytesperline / 4;
- /* The following cases could be removed, but we leave them
- in to document the formats that are included. */
+ /*
+ * The following cases could be removed, but we leave them
+ * in to document the formats that are included.
+ */
case IA_CSS_FRAME_FORMAT_NV11:
case IA_CSS_FRAME_FORMAT_NV12:
case IA_CSS_FRAME_FORMAT_NV16:
@@ -3314,9 +3321,11 @@ atomisp_v4l2_framebuffer_to_css_frame(const struct v4l2_framebuffer *arg,
padded_width = atomisp_bytesperline_to_padded_width(
arg->fmt.bytesperline, sh_format);
- /* Note: the padded width on an ia_css_frame is in elements, not in
- bytes. The RAW frame we use here should always be a 16bit RAW
- frame. This is why we bytesperline/2 is equal to the padded with */
+ /*
+ * Note: the padded width on an ia_css_frame is in elements, not in
+ * bytes. The RAW frame we use here should always be a 16bit RAW
+ * frame. This is why we bytesperline/2 is equal to the padded with
+ */
if (ia_css_frame_allocate(&res, arg->fmt.width, arg->fmt.height,
sh_format, padded_width, 0)) {
ret = -ENOMEM;
@@ -3889,9 +3898,9 @@ enum mipi_port_id atomisp_port_to_mipi_port(struct atomisp_device *isp,
}
static inline int atomisp_set_sensor_mipi_to_isp(
- struct atomisp_sub_device *asd,
- enum atomisp_input_stream_id stream_id,
- struct camera_mipi_info *mipi_info)
+ struct atomisp_sub_device *asd,
+ enum atomisp_input_stream_id stream_id,
+ struct camera_mipi_info *mipi_info)
{
struct v4l2_control ctrl;
struct atomisp_device *isp = asd->isp;
@@ -3926,7 +3935,8 @@ static inline int atomisp_set_sensor_mipi_to_isp(
}
/* Compatibility for sensors which provide no media bus code
- * in s_mbus_framefmt() nor support pad formats. */
+ * in s_mbus_framefmt() nor support pad formats.
+ */
if (mipi_info && mipi_info->input_format != -1) {
bayer_order = mipi_info->raw_bayer_order;
@@ -3998,13 +4008,12 @@ static int get_frame_info_nop(struct atomisp_sub_device *asd,
* handled in CSS when the input resolution is changed.
*/
static int css_input_resolution_changed(struct atomisp_sub_device *asd,
- struct v4l2_mbus_framefmt *ffmt)
+ struct v4l2_mbus_framefmt *ffmt)
{
struct atomisp_metadata_buf *md_buf = NULL, *_md_buf;
unsigned int i;
- dev_dbg(asd->isp->dev, "css_input_resolution_changed to %ux%u\n",
- ffmt->width, ffmt->height);
+ dev_dbg(asd->isp->dev, "%s to %ux%u\n", __func__, ffmt->width, ffmt->height);
if (IS_ISP2401)
atomisp_css_input_set_two_pixels_per_clock(asd, false);
@@ -4385,7 +4394,8 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f)
V4L2_SEL_TGT_CROP);
/* Try to enable YUV downscaling if ISP input is 10 % (either
- * width or height) bigger than the desired result. */
+ * width or height) bigger than the desired result.
+ */
if (!IS_MOFD ||
isp_sink_crop.width * 9 / 10 < f->fmt.pix.width ||
isp_sink_crop.height * 9 / 10 < f->fmt.pix.height ||
--
2.43.0