Skip to contentSkip to conversation

staging: media: atomisp: pci: reposition braces as per coding style

PATCH In review Deepak R Varma 2 participants 6 messages Apr 30, 2021 – May 4, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: media: atomisp: pci: reposition braces as per coding style

Misplaced braces makes it difficult to follow the code easily. This also goes against the code style guidelines. This resolved following checkpatch complaints:

ERROR: open brace '{' following function definitions go on the next line
ERROR: that open brace { should be on the previous line

---

Please Note: There are several other checkpatch triggered warnings and errors that should be addressed in separate patches.

 .../staging/media/atomisp/pci/atomisp_csi2.c  |   3 +-
 .../staging/media/atomisp/pci/sh_css_mipi.c   |  69 +++----
 .../staging/media/atomisp/pci/sh_css_params.c | 171 ++++++++----------
 drivers/staging/media/atomisp/pci/sh_css_sp.c | 108 +++++------
 .../media/atomisp/pci/sh_css_version.c        |   3 +-
 5 files changed, 157 insertions(+), 197 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_csi2.c +2 -1
index 060b8765ae96..200f16994f3a 100644
@@ -29,7 +29,8 @@ static struct v4l2_mbus_framefmt *__csi2_get_format(struct
 	v4l2_subdev_pad_config *cfg,
 	enum
 	v4l2_subdev_format_whence
-	which, unsigned int pad) {
+	which, unsigned int pad)
+{
 	if (which == V4L2_SUBDEV_FORMAT_TRY)
 		return v4l2_subdev_get_try_format(&csi2->subdev, cfg, pad);
 	else
drivers/staging/media/atomisp/pci/sh_css_mipi.c +29 -40

194 lines not on this page · raw message

drivers/staging/media/atomisp/pci/sh_css_params.c +76 -95

494 lines not on this page · raw message

drivers/staging/media/atomisp/pci/sh_css_sp.c +48 -60

302 lines not on this page · raw message

drivers/staging/media/atomisp/pci/sh_css_version.c +2 -1
index fa6de61e4995..f5ff8ca66b50 100644
@@ -21,7 +21,8 @@
 #include "sh_css_firmware.h"
 
 int
-ia_css_get_version(char *version, int max_size) {
+ia_css_get_version(char *version, int max_size)
+{
 	char *css_version;
 
 	if (!IS_ISP2401)
Signature · 1 line
2.30.2
reviewer
#1 lore raw

Hi Deepak,

If you're touching all these lines, I might do a little more. Please see the comments below.

Quoted 26 lines · Deepak R Varma

Misplaced braces makes it difficult to follow the code easily. This also goes against the code style guidelines. This resolved following checkpatch complaints:

ERROR: open brace '{' following function definitions go on the next line
ERROR: that open brace { should be on the previous line

---

Please Note: There are several other checkpatch triggered warnings and errors that should be addressed in separate patches.

 .../staging/media/atomisp/pci/atomisp_csi2.c  |   3 +-
 .../staging/media/atomisp/pci/sh_css_mipi.c   |  69 +++----
 .../staging/media/atomisp/pci/sh_css_params.c | 171 ++++++++----------
 drivers/staging/media/atomisp/pci/sh_css_sp.c | 108 +++++------
 .../media/atomisp/pci/sh_css_version.c        |   3 +-
 5 files changed, 157 insertions(+), 197 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_csi2.c +0 -0
index 060b8765ae96..200f16994f3a 100644

drivers/staging/media/atomisp/pci/atomisp_csi2.c static struct v4l2_mbus_framefmt *__csi2_get_format(struct · line 31

Quoted 3 lines
drivers/staging/media/atomisp/pci/atomisp_csi2.c +0 -0
@@ -29,7 +29,8 @@ static struct v4l2_mbus_framefmt *__csi2_get_format(struct
 	v4l2_subdev_pad_config *cfg,
 	enum
 	v4l2_subdev_format_whence

You could have more arguments on the same line up to 80 characters per line.

Quoted 46 lines
drivers/staging/media/atomisp/pci/atomisp_csi2.c +2 -1
-	which, unsigned int pad) {
+	which, unsigned int pad)
+{
 	if (which == V4L2_SUBDEV_FORMAT_TRY)
 		return v4l2_subdev_get_try_format(&csi2->subdev, cfg, pad);
 	else
drivers/staging/media/atomisp/pci/sh_css_mipi.c +5 -7
index 3f34cc81be87..75489f7d75ee 100644
@@ -91,7 +91,8 @@ ia_css_mipi_frame_calculate_size(const unsigned int width,
 				 const enum atomisp_input_format format,
 				 const bool hasSOLandEOL,
 				 const unsigned int embedded_data_size_words,
-				 unsigned int *size_mem_words) {
+				 unsigned int *size_mem_words)
+{
 	int err = 0;
 
 	unsigned int bits_per_pixel = 0;
@@ -118,8 +119,7 @@ ia_css_mipi_frame_calculate_size(const unsigned int width,
 	IA_CSS_ENTER("padded_width=%d, height=%d, format=%d, hasSOLandEOL=%d, embedded_data_size_words=%d\n",
 		     width_padded, height, format, hasSOLandEOL, embedded_data_size_words);
 
-	switch (format)
-	{
+	switch (format) {
 	case ATOMISP_INPUT_FORMAT_RAW_6:		/* 4p, 3B, 24bits */
 		bits_per_pixel = 6;
 		break;
@@ -178,12 +178,10 @@ ia_css_mipi_frame_calculate_size(const unsigned int width,
 	/* Even lines for YUV420 formats are double in bits_per_pixel. */
 	if (format == ATOMISP_INPUT_FORMAT_YUV420_8
 	    || format == ATOMISP_INPUT_FORMAT_YUV420_10
-	    || format == ATOMISP_INPUT_FORMAT_YUV420_16)
-	{
+	    || format == ATOMISP_INPUT_FORMAT_YUV420_16) {
 		even_line_bytes = (width_padded * 2 * bits_per_pixel + 7) >>
 			3; /* ceil ( bits per line / 8) */
-	} else
-	{
+	} else {
 		even_line_bytes = odd_line_bytes;
 	}
 

drivers/staging/media/atomisp/pci/sh_css_mipi.c ia_css_mipi_frame_calculate_size(const unsigned int width, · line 237

Quoted 5 lines
drivers/staging/media/atomisp/pci/sh_css_mipi.c +1 -1
@@ -236,7 +234,8 @@ ia_css_mipi_frame_calculate_size(const unsigned int width,
 #if !defined(ISP2401)
 int
 ia_css_mipi_frame_enable_check_on_size(const enum mipi_port_id port,
-				       const unsigned int	size_mem_words) {
+				       const unsigned int	size_mem_words)

Tab after int, should be a space.

drivers/staging/media/atomisp/pci/sh_css_mipi.c ia_css_mipi_frame_enable_check_on_size(const enum mipi_port_id port, · line 249

Quoted 12 lines
drivers/staging/media/atomisp/pci/sh_css_mipi.c +2 -2
+{
 	u32 idx;
 
 	int err = -EBUSY;
@@ -246,11 +245,9 @@ ia_css_mipi_frame_enable_check_on_size(const enum mipi_port_id port,
 
 	for (idx = 0; idx < IA_CSS_MIPI_SIZE_CHECK_MAX_NOF_ENTRIES_PER_PORT &&
 	     my_css.mipi_sizes_for_check[port][idx] != 0;
-	     idx++)   /* do nothing */
-	{
+	     idx++) { /* do nothing */
 	}

A semicolon suffices here. I guess this could be also written as:

	for (idx = 0; idx < ... & ... != 0; )
		idx++;

As it's easy to just miss the semicolon at the end of the for loop.

drivers/staging/media/atomisp/pci/sh_css_mipi.c mipi_init(void) · line 271

Quoted 12 lines
drivers/staging/media/atomisp/pci/sh_css_mipi.c +2 -3
-	if (idx < IA_CSS_MIPI_SIZE_CHECK_MAX_NOF_ENTRIES_PER_PORT)
-	{
+	if (idx < IA_CSS_MIPI_SIZE_CHECK_MAX_NOF_ENTRIES_PER_PORT) {
 		my_css.mipi_sizes_for_check[port][idx] = size_mem_words;
 		err = 0;
 	}
@@ -271,7 +268,8 @@ mipi_init(void)
 int
 calculate_mipi_buff_size(
     struct ia_css_stream_config *stream_cfg,
-    unsigned int *size_mem_words) {
+    unsigned int *size_mem_words)

I think both arguments might fit on the same line. If not, then the return type (int) does. I think there are other similar cases.

drivers/staging/media/atomisp/pci/sh_css_mipi.c calculate_mipi_buff_size( · line 349

Quoted 13 lines
drivers/staging/media/atomisp/pci/sh_css_mipi.c +2 -2
+{
 #if !defined(ISP2401)
 	int err = -EINVAL;
 	(void)stream_cfg;
@@ -346,12 +344,10 @@ calculate_mipi_buff_size(
 
 	/* Even lines for YUV420 formats are double in bits_per_pixel. */
 	if (format == ATOMISP_INPUT_FORMAT_YUV420_8
-	    || format == ATOMISP_INPUT_FORMAT_YUV420_10)
-	{
+	    || format == ATOMISP_INPUT_FORMAT_YUV420_10) {
 		even_line_bytes = (width_padded * 2 * bits_per_pixel + 7) >>
 			3; /* ceil ( bits per line / 8) */

You don't need braces here.

Quoted 17 lines
drivers/staging/media/atomisp/pci/sh_css_mipi.c +3 -3
-	} else
-	{
+	} else {
 		even_line_bytes = odd_line_bytes;
 	}
 
@@ -393,7 +389,8 @@ static bool buffers_needed(struct ia_css_pipe *pipe)
 
 int
 allocate_mipi_frames(struct ia_css_pipe *pipe,
-		     struct ia_css_stream_info *info) {
+		     struct ia_css_stream_info *info)
+{
 	int err = -EINVAL;
 	unsigned int port;
 

drivers/staging/media/atomisp/pci/sh_css_mipi.c allocate_mipi_frames(struct ia_css_pipe *pipe, · line 402

Quoted 6 lines
drivers/staging/media/atomisp/pci/sh_css_mipi.c +1 -2
@@ -402,8 +399,7 @@ allocate_mipi_frames(struct ia_css_pipe *pipe,
 
 	assert(pipe);
 	assert(pipe->stream);
-	if ((!pipe) || (!pipe->stream))
-	{
+	if ((!pipe) || (!pipe->stream)) {

Extra parentheses.

Signature · 3 lines
Kind regards,

Sakari Ailus
#2 lore raw
Quoted 5 lines · Sakari Ailus

Hi Deepak,

If you're touching all these lines, I might do a little more. Please see the comments below.

Hello Sakari,
I can definitely include other changes, but then it will be many different types of changes into a single patch. Will that be okay?

I was planning to address one issue per patch as I think the volume of change is going to be high. I mentioned that in the notes section of the patch message.

Let me know if you still suggest I combine those.

Thank you,
deepak.

Quoted 170 lines · Deepak R Varma
Quoted 26 lines

Misplaced braces makes it difficult to follow the code easily. This also goes against the code style guidelines. This resolved following checkpatch complaints:

ERROR: open brace '{' following function definitions go on the next line
ERROR: that open brace { should be on the previous line

---

Please Note: There are several other checkpatch triggered warnings and errors that should be addressed in separate patches.

 .../staging/media/atomisp/pci/atomisp_csi2.c  |   3 +-
 .../staging/media/atomisp/pci/sh_css_mipi.c   |  69 +++----
 .../staging/media/atomisp/pci/sh_css_params.c | 171 ++++++++----------
 drivers/staging/media/atomisp/pci/sh_css_sp.c | 108 +++++------
 .../media/atomisp/pci/sh_css_version.c        |   3 +-
 5 files changed, 157 insertions(+), 197 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_csi2.c +0 -0
index 060b8765ae96..200f16994f3a 100644

drivers/staging/media/atomisp/pci/atomisp_csi2.c static struct v4l2_mbus_framefmt *__csi2_get_format(struct · line 31

Quoted 3 lines
drivers/staging/media/atomisp/pci/atomisp_csi2.c +0 -0
@@ -29,7 +29,8 @@ static struct v4l2_mbus_framefmt *__csi2_get_format(struct
 	v4l2_subdev_pad_config *cfg,
 	enum
 	v4l2_subdev_format_whence

You could have more arguments on the same line up to 80 characters per line.

Quoted 46 lines
drivers/staging/media/atomisp/pci/atomisp_csi2.c +2 -1
-	which, unsigned int pad) {
+	which, unsigned int pad)
+{
 	if (which == V4L2_SUBDEV_FORMAT_TRY)
 		return v4l2_subdev_get_try_format(&csi2->subdev, cfg, pad);
 	else
drivers/staging/media/atomisp/pci/sh_css_mipi.c +5 -7
index 3f34cc81be87..75489f7d75ee 100644
@@ -91,7 +91,8 @@ ia_css_mipi_frame_calculate_size(const unsigned int width,
 				 const enum atomisp_input_format format,
 				 const bool hasSOLandEOL,
 				 const unsigned int embedded_data_size_words,
-				 unsigned int *size_mem_words) {
+				 unsigned int *size_mem_words)
+{
 	int err = 0;
 
 	unsigned int bits_per_pixel = 0;
@@ -118,8 +119,7 @@ ia_css_mipi_frame_calculate_size(const unsigned int width,
 	IA_CSS_ENTER("padded_width=%d, height=%d, format=%d, hasSOLandEOL=%d, embedded_data_size_words=%d\n",
 		     width_padded, height, format, hasSOLandEOL, embedded_data_size_words);
 
-	switch (format)
-	{
+	switch (format) {
 	case ATOMISP_INPUT_FORMAT_RAW_6:		/* 4p, 3B, 24bits */
 		bits_per_pixel = 6;
 		break;
@@ -178,12 +178,10 @@ ia_css_mipi_frame_calculate_size(const unsigned int width,
 	/* Even lines for YUV420 formats are double in bits_per_pixel. */
 	if (format == ATOMISP_INPUT_FORMAT_YUV420_8
 	    || format == ATOMISP_INPUT_FORMAT_YUV420_10
-	    || format == ATOMISP_INPUT_FORMAT_YUV420_16)
-	{
+	    || format == ATOMISP_INPUT_FORMAT_YUV420_16) {
 		even_line_bytes = (width_padded * 2 * bits_per_pixel + 7) >>
 			3; /* ceil ( bits per line / 8) */
-	} else
-	{
+	} else {
 		even_line_bytes = odd_line_bytes;
 	}
 

drivers/staging/media/atomisp/pci/sh_css_mipi.c ia_css_mipi_frame_calculate_size(const unsigned int width, · line 237

Quoted 5 lines
drivers/staging/media/atomisp/pci/sh_css_mipi.c +1 -1
@@ -236,7 +234,8 @@ ia_css_mipi_frame_calculate_size(const unsigned int width,
 #if !defined(ISP2401)
 int
 ia_css_mipi_frame_enable_check_on_size(const enum mipi_port_id port,
-				       const unsigned int	size_mem_words) {
+				       const unsigned int	size_mem_words)

Tab after int, should be a space.

drivers/staging/media/atomisp/pci/sh_css_mipi.c ia_css_mipi_frame_enable_check_on_size(const enum mipi_port_id port, · line 249

Quoted 12 lines
drivers/staging/media/atomisp/pci/sh_css_mipi.c +2 -2
+{
 	u32 idx;
 
 	int err = -EBUSY;
@@ -246,11 +245,9 @@ ia_css_mipi_frame_enable_check_on_size(const enum mipi_port_id port,
 
 	for (idx = 0; idx < IA_CSS_MIPI_SIZE_CHECK_MAX_NOF_ENTRIES_PER_PORT &&
 	     my_css.mipi_sizes_for_check[port][idx] != 0;
-	     idx++)   /* do nothing */
-	{
+	     idx++) { /* do nothing */
 	}

A semicolon suffices here. I guess this could be also written as:

	for (idx = 0; idx < ... & ... != 0; )
		idx++;

As it's easy to just miss the semicolon at the end of the for loop.

drivers/staging/media/atomisp/pci/sh_css_mipi.c mipi_init(void) · line 271

Quoted 12 lines
drivers/staging/media/atomisp/pci/sh_css_mipi.c +2 -3
-	if (idx < IA_CSS_MIPI_SIZE_CHECK_MAX_NOF_ENTRIES_PER_PORT)
-	{
+	if (idx < IA_CSS_MIPI_SIZE_CHECK_MAX_NOF_ENTRIES_PER_PORT) {
 		my_css.mipi_sizes_for_check[port][idx] = size_mem_words;
 		err = 0;
 	}
@@ -271,7 +268,8 @@ mipi_init(void)
 int
 calculate_mipi_buff_size(
     struct ia_css_stream_config *stream_cfg,
-    unsigned int *size_mem_words) {
+    unsigned int *size_mem_words)

I think both arguments might fit on the same line. If not, then the return type (int) does. I think there are other similar cases.

drivers/staging/media/atomisp/pci/sh_css_mipi.c calculate_mipi_buff_size( · line 349

Quoted 13 lines
drivers/staging/media/atomisp/pci/sh_css_mipi.c +2 -2
+{
 #if !defined(ISP2401)
 	int err = -EINVAL;
 	(void)stream_cfg;
@@ -346,12 +344,10 @@ calculate_mipi_buff_size(
 
 	/* Even lines for YUV420 formats are double in bits_per_pixel. */
 	if (format == ATOMISP_INPUT_FORMAT_YUV420_8
-	    || format == ATOMISP_INPUT_FORMAT_YUV420_10)
-	{
+	    || format == ATOMISP_INPUT_FORMAT_YUV420_10) {
 		even_line_bytes = (width_padded * 2 * bits_per_pixel + 7) >>
 			3; /* ceil ( bits per line / 8) */

You don't need braces here.

Quoted 17 lines
drivers/staging/media/atomisp/pci/sh_css_mipi.c +3 -3
-	} else
-	{
+	} else {
 		even_line_bytes = odd_line_bytes;
 	}
 
@@ -393,7 +389,8 @@ static bool buffers_needed(struct ia_css_pipe *pipe)
 
 int
 allocate_mipi_frames(struct ia_css_pipe *pipe,
-		     struct ia_css_stream_info *info) {
+		     struct ia_css_stream_info *info)
+{
 	int err = -EINVAL;
 	unsigned int port;
 

drivers/staging/media/atomisp/pci/sh_css_mipi.c allocate_mipi_frames(struct ia_css_pipe *pipe, · line 402

Quoted 6 lines
drivers/staging/media/atomisp/pci/sh_css_mipi.c +1 -2
@@ -402,8 +399,7 @@ allocate_mipi_frames(struct ia_css_pipe *pipe,
 
 	assert(pipe);
 	assert(pipe->stream);
-	if ((!pipe) || (!pipe->stream))
-	{
+	if ((!pipe) || (!pipe->stream)) {

Extra parentheses.

Signature · 3 lines
Kind regards,

Sakari Ailus
reviewer
#3 lore raw

Hi Deepak,

Quoted 6 lines · Deepak R Varma
Quoted 5 lines · Sakari Ailus

Hi Deepak,

If you're touching all these lines, I might do a little more. Please see the comments below.

Quoted 7 lines

Hello Sakari,
I can definitely include other changes, but then it will be many different types of changes into a single patch. Will that be okay?

I was planning to address one issue per patch as I think the volume of change is going to be high. I mentioned that in the notes section of the patch message.

I think I'd split the patch into smaller chunks if the result becomes too big but I don't think it's necessary yet.

Splitting different kinds of simple cleanups into several patches takes longer time to review when they're touching the same piece of code. As the chunks in these patches have virtually no dependencies to other chunks, it's fine to do several kinds of cleanups at once.

Signature · 3 lines
Kind regards,

Sakari Ailus
#4 lore raw
Quoted 17 lines · Sakari Ailus

Hi Deepak,

Quoted 6 lines · Deepak R Varma
Quoted 5 lines · Sakari Ailus

Hi Deepak,

If you're touching all these lines, I might do a little more. Please see the comments below.

Quoted 7 lines

Hello Sakari,
I can definitely include other changes, but then it will be many different types of changes into a single patch. Will that be okay?

I was planning to address one issue per patch as I think the volume of change is going to be high. I mentioned that in the notes section of the patch message.

Quoted 7 lines

I think I'd split the patch into smaller chunks if the result becomes too big but I don't think it's necessary yet.

Splitting different kinds of simple cleanups into several patches takes longer time to review when they're touching the same piece of code. As the chunks in these patches have virtually no dependencies to other chunks, it's fine to do several kinds of cleanups at once.

Okay, sure. That sounds good to me. I will include other related improvements in the same area and send split patch set accordingly. I will include this patch in the patch set.

Thank you for the guidance.
deepak.

Quoted 5 lines
Signature · 4 lines
-- 
Kind regards,

Sakari Ailus
#5 lore raw
Quoted 21 lines · Deepak R Varma
Quoted 20 lines · Sakari Ailus

Hi Deepak,

Quoted 6 lines · Deepak R Varma
Quoted 5 lines · Sakari Ailus

Hi Deepak,

If you're touching all these lines, I might do a little more. Please see the comments below.

Quoted 7 lines

Hello Sakari,
I can definitely include other changes, but then it will be many different types of changes into a single patch. Will that be okay?

I was planning to address one issue per patch as I think the volume of change is going to be high. I mentioned that in the notes section of the patch message.

I think I'd split the patch into smaller chunks if the result becomes too big but I don't think it's necessary yet.

Quoted 8 lines
Quoted 4 lines

Splitting different kinds of simple cleanups into several patches takes longer time to review when they're touching the same piece of code. As the chunks in these patches have virtually no dependencies to other chunks, it's fine to do several kinds of cleanups at once.

Okay, sure. That sounds good to me. I will include other related improvements in the same area and send split patch set accordingly. I will include this patch in the patch set.

Hello Sakari and all,
I have sent in the changes as suggested in a patch set with 5 individual patches. I will wait for your review and feedback before I work on other files.

Thank you,
deepak.

Quoted 9 lines

Thank you for the guidance.
deepak.

Quoted 5 lines
Signature · 4 lines
-- 
Kind regards,

Sakari Ailus