Skip to contentSkip to conversation

cxl: Fix a checkpatch error

PATCH In review Jeongtae Park 2 participants 8 messages Oct 10, 2023 – Oct 11, 2023 1 message not in the archive CXL

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20231010082321epcas2p292c86c6757dcc1cfeeeb796c29a3e07b@epcas2p2.samsung.com

#1 lore raw

v3 cover cxl: Fix checkpatch issues

Changes since v2: [1]
- Modify cxl_region_invalidate_memregion() considering the context (Jonathan)
- Drop a duplicated fix (Davidlohr)
- Add reviewed-by, acked-by tags

[1]: https://lore.kernel.org/lkml/[email protected]/

---
Cover letter same as v2

This series fixes various checkpatch errors and warnings. I've been looking at the CXL driver recently and noticed that there are trivial mistake codes, so I checked all files with the script and fixed some warnings/errors.

Jeongtae Park (6):
cxl/trace: Fix improper SPDX comment style for header file cxl/region: Fix a checkpatch warning
cxl/mem: Fix a checkpatch error
cxl: Fix a checkpatch error
cxl: Fix block comment style
cxl/memdev: Fix a whitespace error

 drivers/cxl/core/memdev.c | 10 +++++-----
 drivers/cxl/core/region.c | 20 +++++++-------------
 drivers/cxl/core/trace.h  |  2 +-
 drivers/cxl/cxl.h         |  4 ++--
 drivers/cxl/cxlmem.h      |  2 +-
 5 files changed, 16 insertions(+), 22 deletions(-)

base-commit: fe77cc2e5a6a7c85f5c6ef8a39d7694ffc7f41c9

Signature · 1 line
2.34.1
#2 lore raw

PATCH v3 1/6 cxl/trace: Fix improper SPDX comment style for header file

The SPDX license identifier for C header have to be added in form of a C-like comment.

---
 drivers/cxl/core/trace.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/core/trace.h +1 -1
index a0b5819bc70b..7aee7fb008a5 100644
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0
+/* SPDX-License-Identifier: GPL-2.0 */
 /* Copyright(c) 2022 Intel Corporation. All rights reserved. */
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM cxl
Signature · 1 line
2.34.1
#3 lore raw

PATCH v3 2/6 cxl/region: Fix a checkpatch warning

In reply to Jeongtae Park

WARNING: else is not generally useful after a break or return

Since cpu_cache_invalidate_memregion() already checks for support of invalidaton operation, it can be removed. This change would make more efficient or small codes when 'CONFIG_CXL_REGION_INVALIDATION_TEST' is not set.

---
 drivers/cxl/core/region.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)
drivers/cxl/core/region.c +7 -13
index e115ba382e04..0eb7a12badb9 100644
@@ -127,21 +127,15 @@ static struct cxl_region_ref *cxl_rr_load(struct cxl_port *port,
 
 static int cxl_region_invalidate_memregion(struct cxl_region *cxlr)
 {
-	if (!cpu_cache_has_invalidate_memregion()) {
-		if (IS_ENABLED(CONFIG_CXL_REGION_INVALIDATION_TEST)) {
-			dev_warn_once(
-				&cxlr->dev,
-				"Bypassing cpu_cache_invalidate_memregion() for testing!\n");
-			return 0;
-		} else {
-			dev_err(&cxlr->dev,
-				"Failed to synchronize CPU cache state\n");
-			return -ENXIO;
-		}
+	if (IS_ENABLED(CONFIG_CXL_REGION_INVALIDATION_TEST)
+			&& cpu_cache_has_invalidate_memregion()) {
+		dev_warn_once(
+			&cxlr->dev,
+			"Bypassing cpu_cache_invalidate_memregion() for testing!\n");
+		return 0;
 	}
 
-	cpu_cache_invalidate_memregion(IORES_DESC_CXL);
-	return 0;
+	return cpu_cache_invalidate_memregion(IORES_DESC_CXL);
 }
 
 static int cxl_region_decode_reset(struct cxl_region *cxlr, int count)
Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH v3 2/6] cxl/region: Fix a checkpatch warning

Quoted 6 lines · On Tue, 10 Oct 2023 17:26:04 +0900 Jeongtae Park <[email protected]> wrote:

WARNING: else is not generally useful after a break or return

Since cpu_cache_invalidate_memregion() already checks for support of invalidaton operation, it can be removed. This change would make more efficient or small codes when 'CONFIG_CXL_REGION_INVALIDATION_TEST' is not set.

Oddly short line wrap - aim for 75 chars ish.

Quoted 28 lines
---
 drivers/cxl/core/region.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)
drivers/cxl/core/region.c +1 -11
index e115ba382e04..0eb7a12badb9 100644
@@ -127,21 +127,15 @@ static struct cxl_region_ref *cxl_rr_load(struct cxl_port *port,
 
 static int cxl_region_invalidate_memregion(struct cxl_region *cxlr)
 {
-	if (!cpu_cache_has_invalidate_memregion()) {
-		if (IS_ENABLED(CONFIG_CXL_REGION_INVALIDATION_TEST)) {
-			dev_warn_once(
-				&cxlr->dev,
-				"Bypassing cpu_cache_invalidate_memregion() for testing!\n");
-			return 0;
-		} else {
-			dev_err(&cxlr->dev,
-				"Failed to synchronize CPU cache state\n");
-			return -ENXIO;
-		}
+	if (IS_ENABLED(CONFIG_CXL_REGION_INVALIDATION_TEST)

drivers/cxl/core/region.c static struct cxl_region_ref *cxl_rr_load(struct cxl_port *port, · line 138

Quoted 10 lines
drivers/cxl/core/region.c +6 -2
+			&& cpu_cache_has_invalidate_memregion()) {
+		dev_warn_once(
+			&cxlr->dev,
+			"Bypassing cpu_cache_invalidate_memregion() for testing!\n");
+		return 0;
 	}
 
-	cpu_cache_invalidate_memregion(IORES_DESC_CXL);
-	return 0;
+	return cpu_cache_invalidate_memregion(IORES_DESC_CXL);

This is an arch specific call. Whilst today on x86 (only option) the only way to return an error is if it's not supported, that's not necessarily going to be the case for other architectures. So I'd prefer to keep the dev_err if this fails.

Jonathan

Quoted 3 lines
drivers/cxl/core/region.c +0 -0
 }
 
 static int cxl_region_decode_reset(struct cxl_region *cxlr, int count)
#5 lore raw

PATCH v3 3/6 cxl/mem: Fix a checkpatch error

In reply to Jeongtae Park

ERROR: spaces required around that '=' (ctx:WxV)

---
 drivers/cxl/cxlmem.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/cxlmem.h +1 -1
index 79e99c873ca2..1ac3eb2be84f 100644
@@ -183,7 +183,7 @@ struct cxl_mbox_cmd_rc {
 };
 
 static const
-struct cxl_mbox_cmd_rc cxl_mbox_cmd_rctable[] ={ CMD_CMD_RC_TABLE };
+struct cxl_mbox_cmd_rc cxl_mbox_cmd_rctable[] = { CMD_CMD_RC_TABLE };
 #undef C
 
 static inline const char *cxl_mbox_cmd_rc2str(struct cxl_mbox_cmd *mbox_cmd)
Signature · 1 line
2.34.1
#6 lore raw

PATCH v3 4/6 cxl: Fix a checkpatch error

In reply to Jeongtae Park

ERROR: Macros with complex values should be enclosed in parentheses

---
 drivers/cxl/cxl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/cxl.h +1 -1
index 76d92561af29..545381355efb 100644
@@ -142,7 +142,7 @@ static inline int ways_to_eiw(unsigned int ways, u8 *eiw)
 #define CXL_RAS_HEADER_LOG_OFFSET 0x18
 #define CXL_RAS_CAPABILITY_LENGTH 0x58
 #define CXL_HEADERLOG_SIZE SZ_512
-#define CXL_HEADERLOG_SIZE_U32 SZ_512 / sizeof(u32)
+#define CXL_HEADERLOG_SIZE_U32 (SZ_512 / sizeof(u32))
 
 /* CXL 2.0 8.2.8.1 Device Capabilities Array Register */
 #define CXLDEV_CAP_ARRAY_OFFSET 0x0
Signature · 1 line
2.34.1
#7 lore raw

PATCH v3 5/6 cxl: Fix block comment style

In reply to Jeongtae Park

WARNING: Block comments should align the * on each line

---
 drivers/cxl/cxl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/cxl.h +1 -1
index 545381355efb..0bbe0c15bfa9 100644
@@ -334,7 +334,7 @@ enum cxl_decoder_type {
  * @flags: memory type capabilities and locking
  * @commit: device/decoder-type specific callback to commit settings to hw
  * @reset: device/decoder-type specific callback to reset hw settings
-*/
+ */
 struct cxl_decoder {
 	struct device dev;
 	int id;
Signature · 1 line
2.34.1
#8 lore raw

PATCH v3 6/6 cxl/memdev: Fix a whitespace error

In reply to Jeongtae Park

ERROR: code indent should use tabs where possible

---
 drivers/cxl/core/memdev.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/cxl/core/memdev.c +5 -5
index f99e7ec3cc40..7e8fca4707c0 100644
@@ -935,11 +935,11 @@ static void cxl_fw_cancel(struct fw_upload *fwl)
 }
 
 static const struct fw_upload_ops cxl_memdev_fw_ops = {
-        .prepare = cxl_fw_prepare,
-        .write = cxl_fw_write,
-        .poll_complete = cxl_fw_poll_complete,
-        .cancel = cxl_fw_cancel,
-        .cleanup = cxl_fw_cleanup,
+	.prepare = cxl_fw_prepare,
+	.write = cxl_fw_write,
+	.poll_complete = cxl_fw_poll_complete,
+	.cancel = cxl_fw_cancel,
+	.cleanup = cxl_fw_cleanup,
 };
 
 static void devm_cxl_remove_fw_upload(void *fwl)
Signature · 1 line
2.34.1