[PATCH] staging: media: atomisp: comprehensive coding style cleanup

Laur posted 1 patch 1 month ago
.../staging/media/atomisp/pci/atomisp_cmd.c   | 96 ++++++++++---------
1 file changed, 53 insertions(+), 43 deletions(-)
[PATCH] staging: media: atomisp: comprehensive coding style cleanup
Posted by Laur 1 month ago
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@gmail.com>
---
 .../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
Re: [PATCH] staging: media: atomisp: comprehensive coding style cleanup
Posted by Sakari Ailus 1 month ago
Hi,

On Sun, Mar 08, 2026 at 11:58:40PM +0200, Laur wrote:
> @@ -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);

The indentation is wrong here after the change.

>  	return 0;
>  }

-- 
Regards,

Sakari Ailus
Re: [PATCH] staging: media: atomisp: comprehensive coding style cleanup
Posted by Andy Shevchenko 1 month ago
On Mon, Mar 09, 2026 at 12:21:37PM +0200, Sakari Ailus wrote:
> On Sun, Mar 08, 2026 at 11:58:40PM +0200, Laur wrote:
> > @@ -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);
> 
> The indentation is wrong here after the change.
> 
> >  	return 0;

This code probably should be changed to use iov_iter facilities.
See the ALSA driver conversions for that, exempli gratia the commit
49aa6ed94c5e ("ALSA: korg1212: Convert to generic PCM copy ops").

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH] staging: media: atomisp: comprehensive coding style cleanup
Posted by kernel test robot 1 month ago
Hi Laur,

kernel test robot noticed the following build warnings:

[auto build test WARNING on staging/staging-testing]

url:    https://github.com/intel-lab-lkp/linux/commits/Laur/staging-media-atomisp-comprehensive-coding-style-cleanup/20260309-055945
base:   staging/staging-testing
patch link:    https://lore.kernel.org/r/20260308215840.31197-1-laurentiutopai2004%40gmail.com
patch subject: [PATCH] staging: media: atomisp: comprehensive coding style cleanup
config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20260309/202603091804.DdX2VxlO-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260309/202603091804.DdX2VxlO-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603091804.DdX2VxlO-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/staging/media/atomisp/pci/atomisp_cmd.c: In function 'copy_from_compatible':
>> drivers/staging/media/atomisp/pci/atomisp_cmd.c:2033:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    2033 |         if (from_user)
         |         ^~
   In file included from include/linux/string.h:386,
                    from arch/x86/include/asm/page_32.h:18,
                    from arch/x86/include/asm/page.h:14,
                    from arch/x86/include/asm/thread_info.h:12,
                    from include/linux/thread_info.h:62,
                    from include/linux/spinlock.h:60,
                    from include/linux/mmzone.h:8,
                    from include/linux/gfp.h:7,
                    from include/linux/firmware.h:8,
                    from drivers/staging/media/atomisp/pci/atomisp_cmd.c:10:
   include/linux/fortify-string.h:624:62: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
     624 |                              p_size_field, q_size_field, op) ({         \
         |                                                              ^
   include/linux/fortify-string.h:688:26: note: in expansion of macro '__fortify_memcpy_chk'
     688 | #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
         |                          ^~~~~~~~~~~~~~~~~~~~
   drivers/staging/media/atomisp/pci/atomisp_cmd.c:2036:17: note: in expansion of macro 'memcpy'
    2036 |                 memcpy(to, from, n);
         |                 ^~~~~~


vim +/if +2033 drivers/staging/media/atomisp/pci/atomisp_cmd.c

ad85094b293e40e drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c Mauro Carvalho Chehab 2020-04-19  2029  
ad85094b293e40e drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c Mauro Carvalho Chehab 2020-04-19  2030  static unsigned int long copy_from_compatible(void *to, const void *from,
ad85094b293e40e drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c Mauro Carvalho Chehab 2020-04-19  2031  	unsigned long n, bool from_user)
ad85094b293e40e drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c Mauro Carvalho Chehab 2020-04-19  2032  {
ad85094b293e40e drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c Mauro Carvalho Chehab 2020-04-19 @2033  	if (from_user)
ad85094b293e40e drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c Mauro Carvalho Chehab 2020-04-19  2034  		return copy_from_user(to, (void __user *)from, n);
acede91286a8c6f drivers/staging/media/atomisp/pci/atomisp_cmd.c          Laur                  2026-03-08  2035  
ad85094b293e40e drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c Mauro Carvalho Chehab 2020-04-19  2036  		memcpy(to, from, n);
ad85094b293e40e drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c Mauro Carvalho Chehab 2020-04-19  2037  	return 0;
ad85094b293e40e drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c Mauro Carvalho Chehab 2020-04-19  2038  }
ad85094b293e40e drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c Mauro Carvalho Chehab 2020-04-19  2039  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH] staging: media: atomisp: comprehensive coding style cleanup
Posted by Andy Shevchenko 1 month ago
On Sun, Mar 8, 2026 at 11:59 PM Laur <laurentiutopai2004@gmail.com> wrote:
>
> 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.

At least some of the pieces may be split to separate change(s).

...

> @@ -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:

You need to understand the code you are modifying. Blind follow of the
tool that has tons of false positives (checkpatch is a recommendation
tool, it doesn't mean it's sometimes correct or useful) is not good
idea.

NAK.

-- 
With Best Regards,
Andy Shevchenko