Skip to contentSkip to conversation

Fixing check patch styling issues

PATCH Superseded Raghu H 3 participants 11 messages Apr 19, 2023 – Apr 28, 2023 CXL

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Raghu H

author
#0 lore raw

cover Fixing check patch styling issues

The following patches are cleanup or fixing the styling issues found using checkpatch

In cxl/core/mbox.c, in case of null check failure, returning errno or -ENOMEM in this case is good enough, removing the redundant dev_err message.

In cxl/core/port.c, there is line of spaces in the definition which violates checkpatch coding sytle, restructured the definition to use tabs

In cxl/core/region.c, the else is not required after the return statement, cleaned it up.

Verified the build and sanity by booting the guest VM using the freshly built components.

Raghu H (3):
cxl/mbox: remove redundant debug msg cxl/core/port: Use tabs to fix styling errors cxl/core/region:Remove else after return statement

 drivers/cxl/core/mbox.c   |  4 +---
 drivers/cxl/core/port.c   | 18 +++++++++---------
 drivers/cxl/core/region.c |  7 +++----
 3 files changed, 13 insertions(+), 16 deletions(-)
Signature · 1 line
2.39.2
author
#1 lore raw

PATCH 1/3 cxl/mbox: remove redundant debug msg

A return of errno should be good enough if the memory allocation fails, the debug message here is redundatant as per the coding style, removing it.

---
 drivers/cxl/core/mbox.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/cxl/core/mbox.c +1 -3
index f2addb457172..11ea145b4b1f 100644
@@ -1112,10 +1112,8 @@ struct cxl_dev_state *cxl_dev_state_create(struct device *dev)
 	struct cxl_dev_state *cxlds;
 
 	cxlds = devm_kzalloc(dev, sizeof(*cxlds), GFP_KERNEL);
-	if (!cxlds) {
-		dev_err(dev, "No memory available\n");
+	if (!cxlds)
 		return ERR_PTR(-ENOMEM);
-	}
 
 	mutex_init(&cxlds->mbox_mutex);
 	mutex_init(&cxlds->event.log_lock);
Signature · 1 line
2.39.2
Reviewed-by on v1 1/3
#2 lore raw

Re: [STYLE v1 1/3] cxl/mbox: remove redundant debug msg

Quoted 4 lines · Raghu H

A return of errno should be good enough if the memory allocation fails, the debug message here is redundatant as per the coding style, removing it.

I'm not seeing a lot of value in this error message either. There are plenty of other places probe can fail without any errors at all.

I guess:

maintainer
#3 lore raw

Re: [STYLE v1 1/3] cxl/mbox: remove redundant debug msg

In reply to Raghu H
Quoted 2 lines · Raghu H

A return of errno should be good enough if the memory allocation fails, the debug message here is redundatant as per the coding style, removing it.

Hi Raghu,

Thanks for the patch. The code change looks fine.

Here is some feedback on the commit msg and log:

This removes a dev_err() not a debug message, dev_dbg()

Commit msg can be clearer like:
cxl/mbox: Remove redundant dev_err() after failed mem alloc

Please include PATCH in the subject line.
See Documentation/process/submitting-patches.rst or peruse other patches on the mailing list and subsystem to see examples.

Alison

Quoted 25 lines
---
 drivers/cxl/core/mbox.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/cxl/core/mbox.c +1 -3
index f2addb457172..11ea145b4b1f 100644
@@ -1112,10 +1112,8 @@ struct cxl_dev_state *cxl_dev_state_create(struct device *dev)
 	struct cxl_dev_state *cxlds;
 
 	cxlds = devm_kzalloc(dev, sizeof(*cxlds), GFP_KERNEL);
-	if (!cxlds) {
-		dev_err(dev, "No memory available\n");
+	if (!cxlds)
 		return ERR_PTR(-ENOMEM);
-	}
 
 	mutex_init(&cxlds->mbox_mutex);
 	mutex_init(&cxlds->event.log_lock);
Signature · 1 line
2.39.2
author
#4 lore raw

PATCH 2/3 cxl/core/port: Use tabs to fix styling errors

In reply to Raghu H

Styling errors due to linux of unwanted spaces in the definition, modified the definition to use tab to fix the styling issue.

---
 drivers/cxl/core/port.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/cxl/core/port.c +9 -9
index 8ee6b6e2e2a4..7c3aaed180ca 100644
@@ -95,15 +95,15 @@ static ssize_t size_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RO(size);
 
-#define CXL_DECODER_FLAG_ATTR(name, flag)                            \
-static ssize_t name##_show(struct device *dev,                       \
-			   struct device_attribute *attr, char *buf) \
-{                                                                    \
-	struct cxl_decoder *cxld = to_cxl_decoder(dev);              \
-                                                                     \
-	return sysfs_emit(buf, "%s\n",                               \
-			  (cxld->flags & (flag)) ? "1" : "0");       \
-}                                                                    \
+#define CXL_DECODER_FLAG_ATTR(name, flag)				\
+static ssize_t name##_show(struct device *dev,				\
+			   struct device_attribute *attr, char *buf)	\
+{									\
+	struct cxl_decoder *cxld = to_cxl_decoder(dev);			\
+									\
+	return sysfs_emit(buf, "%s\n",					\
+			  (cxld->flags & (flag)) ? "1" : "0");		\
+}									\
 static DEVICE_ATTR_RO(name)
 
 CXL_DECODER_FLAG_ATTR(cap_pmem, CXL_DECODER_F_PMEM);
Signature · 1 line
2.39.2
#5 lore raw

Re: [STYLE v1 2/3] cxl/core/port: Use tabs to fix styling errors

Quoted 4 lines · Raghu H

Styling errors due to linux of unwanted spaces in the definition, modified the definition to use tab to fix the styling issue.

NAK

This is unnecessary churn. The formatting of the file is fine and very readable.

Ira

Quoted 36 lines
---
 drivers/cxl/core/port.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/cxl/core/port.c +9 -9
index 8ee6b6e2e2a4..7c3aaed180ca 100644
@@ -95,15 +95,15 @@ static ssize_t size_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RO(size);
 
-#define CXL_DECODER_FLAG_ATTR(name, flag)                            \
-static ssize_t name##_show(struct device *dev,                       \
-			   struct device_attribute *attr, char *buf) \
-{                                                                    \
-	struct cxl_decoder *cxld = to_cxl_decoder(dev);              \
-                                                                     \
-	return sysfs_emit(buf, "%s\n",                               \
-			  (cxld->flags & (flag)) ? "1" : "0");       \
-}                                                                    \
+#define CXL_DECODER_FLAG_ATTR(name, flag)				\
+static ssize_t name##_show(struct device *dev,				\
+			   struct device_attribute *attr, char *buf)	\
+{									\
+	struct cxl_decoder *cxld = to_cxl_decoder(dev);			\
+									\
+	return sysfs_emit(buf, "%s\n",					\
+			  (cxld->flags & (flag)) ? "1" : "0");		\
+}									\
 static DEVICE_ATTR_RO(name)
 
 CXL_DECODER_FLAG_ATTR(cap_pmem, CXL_DECODER_F_PMEM);
Signature · 1 line
2.39.2
author
#6 lore raw

PATCH 3/3 cxl/core/region:Remove else after return statement

In reply to Raghu H

The else section here is redundant after return statement, removing it. Sanity and correctness is not affected due to this fix.

---
 drivers/cxl/core/region.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/cxl/core/region.c +3 -4
index f29028148806..1d695107b4a7 100644
@@ -2666,11 +2666,10 @@ static int cxl_region_invalidate_memregion(struct cxl_region *cxlr)
 				"Bypassing cpu_cache_invalidate_memregion() for testing!\n");
 			clear_bit(CXL_REGION_F_INCOHERENT, &cxlr->flags);
 			return 0;
-		} else {
-			dev_err(&cxlr->dev,
-				"Failed to synchronize CPU cache state\n");
-			return -ENXIO;
 		}
+		dev_err(&cxlr->dev,
+			"Failed to synchronize CPU cache state\n");
+		return -ENXIO;
 	}
 
 	cpu_cache_invalidate_memregion(IORES_DESC_CXL);
Signature · 1 line
2.39.2
Reviewed-by on v1 3/3
#7 lore raw

Re: [STYLE v1 3/3] cxl/core/region:Remove else after return statement

Quoted 4 lines · Raghu H

The else section here is redundant after return statement, removing it. Sanity and correctness is not affected due to this fix.

Ok, per my eyes I would have liked an extra space before the dev_err() but...

Quoted 26 lines
---
 drivers/cxl/core/region.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/cxl/core/region.c +3 -4
index f29028148806..1d695107b4a7 100644
@@ -2666,11 +2666,10 @@ static int cxl_region_invalidate_memregion(struct cxl_region *cxlr)
 				"Bypassing cpu_cache_invalidate_memregion() for testing!\n");
 			clear_bit(CXL_REGION_F_INCOHERENT, &cxlr->flags);
 			return 0;
-		} else {
-			dev_err(&cxlr->dev,
-				"Failed to synchronize CPU cache state\n");
-			return -ENXIO;
 		}
+		dev_err(&cxlr->dev,
+			"Failed to synchronize CPU cache state\n");
+		return -ENXIO;
 	}
 
 	cpu_cache_invalidate_memregion(IORES_DESC_CXL);
Signature · 1 line
2.39.2
maintainer
#8 lore raw

Re: [STYLE v1 3/3] cxl/core/region:Remove else after return statement

Quoted 8 lines · Ira Weiny
Quoted 4 lines · Raghu H

The else section here is redundant after return statement, removing it. Sanity and correctness is not affected due to this fix.

Ok, per my eyes I would have liked an extra space before the dev_err() but...

Well, I asked Rahgu to give us a v2 with mostly patch formatting fixups, so let's get that extra space too :)

Quoted 29 lines
Quoted 26 lines
---
 drivers/cxl/core/region.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/cxl/core/region.c +3 -4
index f29028148806..1d695107b4a7 100644
@@ -2666,11 +2666,10 @@ static int cxl_region_invalidate_memregion(struct cxl_region *cxlr)
 				"Bypassing cpu_cache_invalidate_memregion() for testing!\n");
 			clear_bit(CXL_REGION_F_INCOHERENT, &cxlr->flags);
 			return 0;
-		} else {
-			dev_err(&cxlr->dev,
-				"Failed to synchronize CPU cache state\n");
-			return -ENXIO;
 		}
+		dev_err(&cxlr->dev,
+			"Failed to synchronize CPU cache state\n");
+		return -ENXIO;
 	}
 
 	cpu_cache_invalidate_memregion(IORES_DESC_CXL);
Signature · 1 line
2.39.2
author
#9 lore raw

Re: [STYLE v1 3/3] cxl/core/region:Remove else after return statement

Thanks Alison & Ira for comments

I missed your messages due to personal reasons.

Will clean and follow it up with v2 very soon.

Quoted 43 lines · Alison Schofield
Quoted 8 lines · Ira Weiny
Quoted 4 lines · Raghu H

The else section here is redundant after return statement, removing it. Sanity and correctness is not affected due to this fix.

Ok, per my eyes I would have liked an extra space before the dev_err() but...

Well, I asked Rahgu to give us a v2 with mostly patch formatting fixups, so let's get that extra space too :)

Quoted 29 lines
Quoted 26 lines
---
 drivers/cxl/core/region.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/cxl/core/region.c +3 -5
index f29028148806..1d695107b4a7 100644
@@ -2666,11 +2666,10 @@ static int cxl_region_invalidate_memregion(struct cxl_region *cxlr)
                            "Bypassing cpu_cache_invalidate_memregion() for testing!\n");
                    clear_bit(CXL_REGION_F_INCOHERENT, &cxlr->flags);
                    return 0;
-           } else {
-                   dev_err(&cxlr->dev,
-                           "Failed to synchronize CPU cache state\n");
-                   return -ENXIO;
            }
+           dev_err(&cxlr->dev,
+                   "Failed to synchronize CPU cache state\n");
+           return -ENXIO;
    }
 
    cpu_cache_invalidate_memregion(IORES_DESC_CXL);
--

2.39.2

maintainer
#10 lore raw
In reply to Raghu H

On Wed, Apr 19, 2023 at 11:14:40AM +0000, Raghu H wrote:

Hi Raghu,

Thanks for the cleanup patches.
Sometime maintainers don't want cleanup, but these look good, and hopefully they can get queued, after you send a v2.

I see Ira already commented to drop the tab reformatting, so drop that in a v2 of this set.

I notice only 'me' in the 'To;' list here. The cover letter needs to get the same maintainer list as your patches.

Each patches commit log (now 2 patches) should say 'Issue found with checkpatch', or something similar. We like to know what tool to credit, and like that to be in the git history/changelog, not just the cover letter.

Quoted 14 lines

The following patches are cleanup or fixing the styling issues found using checkpatch

In cxl/core/mbox.c, in case of null check failure, returning errno or -ENOMEM in this case is good enough, removing the redundant dev_err message.

In cxl/core/port.c, there is line of spaces in the definition which violates checkpatch coding sytle, restructured the definition to use tabs

In cxl/core/region.c, the else is not required after the return statement, cleaned it up.

Quoted 7 lines

Verified the build and sanity by booting the guest VM using the freshly built components.

Raghu H (3):
cxl/mbox: remove redundant debug msg cxl/core/port: Use tabs to fix styling errors cxl/core/region:Remove else after return statement

Assumes you are dropping the port changes.

Do this:

$git log --oneline mbox.c
$git log --oneline region.c

Your commit messages 'look' different than the existing message. Please fix their formatting, in addition to the reword I mention in patch 1 reply.

Thanks,
Alison

Quoted 9 lines
 drivers/cxl/core/mbox.c   |  4 +---
 drivers/cxl/core/port.c   | 18 +++++++++---------
 drivers/cxl/core/region.c |  7 +++----
 3 files changed, 13 insertions(+), 16 deletions(-)
Signature · 1 line
2.39.2