Skip to contentSkip to conversation

cxl: Use %pe to print error pointers

PATCH Applied Shaikh Kamaluddin 4 participants 4 messages Aug 2 – Aug 3 CXL

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cxl: Use %pe to print error pointers

Use the %pe printk format specifier to report error pointers directly instead of printing PTR_ERR() as a long value. A failed dport addition then reports -EBUSY rather than -16, which is easier to follow when tracing port and region setup with dynamic debug enabled.

Convert the five affected sites in drivers/cxl/core/port.c and drivers/cxl/core/region.c. PTR_ERR() uses in return statements are unaffected and left unchanged.

drivers/cxl was scanned in full; these are the only conversion candidates.

Found by: make coccicheck MODE=report M=drivers/cxl/ No functional change intended.

---
Compile tested only with cxl config on x86.

v2:
- Reword commit message: lead with the code improvement, note coccinelle
only as the tool used to locate the sites (Alison)
- Capitalise subject per CXL convention (Alison)
- Note that drivers/cxl was scanned in full and these are the only
candidates (Alison)
- Clarify that the patch is compile tested only
- No code changes
Link to v1: https://lore.kernel.org/linux-cxl/[email protected]/

 drivers/cxl/core/port.c   | 13 ++++++-------
 drivers/cxl/core/region.c |  8 ++++----
 2 files changed, 10 insertions(+), 11 deletions(-)
drivers/cxl/core/port.c +6 -7
index 1215ee4f4035..c9875e6af9f6 100644
@@ -932,11 +932,10 @@ struct cxl_port *devm_cxl_add_port(struct device *host,
 
 	parent_port = parent_dport ? parent_dport->port : NULL;
 	if (IS_ERR(port)) {
-		dev_dbg(uport_dev, "Failed to add%s%s%s: %ld\n",
+		dev_dbg(uport_dev, "Failed to add%s%s%s: %pe\n",
 			parent_port ? " port to " : "",
 			parent_port ? dev_name(&parent_port->dev) : "",
-			parent_port ? "" : " root port",
-			PTR_ERR(port));
+			parent_port ? "" : " root port", port);
 	} else {
 		dev_dbg(uport_dev, "%s added%s%s%s\n",
 			dev_name(&port->dev),
@@ -1271,8 +1270,8 @@ struct cxl_dport *devm_cxl_add_dport(struct cxl_port *port,
 	dport = __devm_cxl_add_dport(port, dport_dev, port_id,
 				     component_reg_phys, CXL_RESOURCE_NONE);
 	if (IS_ERR(dport)) {
-		dev_dbg(dport_dev, "failed to add dport to %s: %ld\n",
-			dev_name(&port->dev), PTR_ERR(dport));
+		dev_dbg(dport_dev, "failed to add dport to %s: %pe\n",
+			dev_name(&port->dev), dport);
 	} else {
 		dev_dbg(dport_dev, "dport added to %s\n",
 			dev_name(&port->dev));
@@ -1305,8 +1304,8 @@ struct cxl_dport *devm_cxl_add_rch_dport(struct cxl_port *port,
 	dport = __devm_cxl_add_dport(port, dport_dev, port_id,
 				     CXL_RESOURCE_NONE, rcrb);
 	if (IS_ERR(dport)) {
-		dev_dbg(dport_dev, "failed to add RCH dport to %s: %ld\n",
-			dev_name(&port->dev), PTR_ERR(dport));
+		dev_dbg(dport_dev, "failed to add RCH dport to %s: %pe\n",
+			dev_name(&port->dev), dport);
 	} else {
 		dev_dbg(dport_dev, "RCH dport added to %s\n",
 			dev_name(&port->dev));
drivers/cxl/core/region.c +4 -4
index 1e211542b6b6..894df68a6074 100644
@@ -682,8 +682,8 @@ static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size)
 				    dev_name(&cxlr->dev));
 	if (IS_ERR(res)) {
 		dev_dbg(&cxlr->dev,
-			"HPA allocation error (%ld) for size:%pap in %s %pr\n",
-			PTR_ERR(res), &size, cxlrd->res->name, cxlrd->res);
+			"HPA allocation error (%pe) for size:%pap in %s %pr\n",
+			res, &size, cxlrd->res->name, cxlrd->res);
 		return PTR_ERR(res);
 	}
 
@@ -3773,9 +3773,9 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd,
 
 	if (IS_ERR(cxlr)) {
 		dev_err(cxlmd->dev.parent,
-			"%s:%s: %s failed assign region: %ld\n",
+			"%s:%s: %s failed assign region: %pe\n",
 			dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev),
-			__func__, PTR_ERR(cxlr));
+			__func__, cxlr);
 		return cxlr;
 	}
 

base-commit: f5098b6bae761e346ebcd9da7f95622c04733cff

Signature · 1 line
2.43.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Shaikh Kamaluddin

Use the %pe printk format specifier to report error pointers directly instead of printing PTR_ERR() as a long value. A failed dport addition then reports -EBUSY rather than -16, which is easier to follow when tracing port and region setup with dynamic debug enabled.

Convert the five affected sites in drivers/cxl/core/port.c and drivers/cxl/core/region.c. PTR_ERR() uses in return statements are unaffected and left unchanged.

Quoted 7 lines

drivers/cxl was scanned in full; these are the only conversion candidates.

Found by: make coccicheck MODE=report M=drivers/cxl/ No functional change intended.

Quoted 90 lines

---
Compile tested only with cxl config on x86.

v2:
- Reword commit message: lead with the code improvement, note coccinelle
only as the tool used to locate the sites (Alison)
- Capitalise subject per CXL convention (Alison)
- Note that drivers/cxl was scanned in full and these are the only
candidates (Alison)
- Clarify that the patch is compile tested only
- No code changes
Link to v1: https://lore.kernel.org/linux-cxl/[email protected]/

 drivers/cxl/core/port.c   | 13 ++++++-------
 drivers/cxl/core/region.c |  8 ++++----
 2 files changed, 10 insertions(+), 11 deletions(-)
drivers/cxl/core/port.c +6 -7
index 1215ee4f4035..c9875e6af9f6 100644
@@ -932,11 +932,10 @@ struct cxl_port *devm_cxl_add_port(struct device *host,
 
 	parent_port = parent_dport ? parent_dport->port : NULL;
 	if (IS_ERR(port)) {
-		dev_dbg(uport_dev, "Failed to add%s%s%s: %ld\n",
+		dev_dbg(uport_dev, "Failed to add%s%s%s: %pe\n",
 			parent_port ? " port to " : "",
 			parent_port ? dev_name(&parent_port->dev) : "",
-			parent_port ? "" : " root port",
-			PTR_ERR(port));
+			parent_port ? "" : " root port", port);
 	} else {
 		dev_dbg(uport_dev, "%s added%s%s%s\n",
 			dev_name(&port->dev),
@@ -1271,8 +1270,8 @@ struct cxl_dport *devm_cxl_add_dport(struct cxl_port *port,
 	dport = __devm_cxl_add_dport(port, dport_dev, port_id,
 				     component_reg_phys, CXL_RESOURCE_NONE);
 	if (IS_ERR(dport)) {
-		dev_dbg(dport_dev, "failed to add dport to %s: %ld\n",
-			dev_name(&port->dev), PTR_ERR(dport));
+		dev_dbg(dport_dev, "failed to add dport to %s: %pe\n",
+			dev_name(&port->dev), dport);
 	} else {
 		dev_dbg(dport_dev, "dport added to %s\n",
 			dev_name(&port->dev));
@@ -1305,8 +1304,8 @@ struct cxl_dport *devm_cxl_add_rch_dport(struct cxl_port *port,
 	dport = __devm_cxl_add_dport(port, dport_dev, port_id,
 				     CXL_RESOURCE_NONE, rcrb);
 	if (IS_ERR(dport)) {
-		dev_dbg(dport_dev, "failed to add RCH dport to %s: %ld\n",
-			dev_name(&port->dev), PTR_ERR(dport));
+		dev_dbg(dport_dev, "failed to add RCH dport to %s: %pe\n",
+			dev_name(&port->dev), dport);
 	} else {
 		dev_dbg(dport_dev, "RCH dport added to %s\n",
 			dev_name(&port->dev));
drivers/cxl/core/region.c +4 -4
index 1e211542b6b6..894df68a6074 100644
@@ -682,8 +682,8 @@ static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size)
 				    dev_name(&cxlr->dev));
 	if (IS_ERR(res)) {
 		dev_dbg(&cxlr->dev,
-			"HPA allocation error (%ld) for size:%pap in %s %pr\n",
-			PTR_ERR(res), &size, cxlrd->res->name, cxlrd->res);
+			"HPA allocation error (%pe) for size:%pap in %s %pr\n",
+			res, &size, cxlrd->res->name, cxlrd->res);
 		return PTR_ERR(res);
 	}
 
@@ -3773,9 +3773,9 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd,
 
 	if (IS_ERR(cxlr)) {
 		dev_err(cxlmd->dev.parent,
-			"%s:%s: %s failed assign region: %ld\n",
+			"%s:%s: %s failed assign region: %pe\n",
 			dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev),
-			__func__, PTR_ERR(cxlr));
+			__func__, cxlr);
 		return cxlr;
 	}
 

base-commit: f5098b6bae761e346ebcd9da7f95622c04733cff

Signature · 1 line
2.43.0
maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to Shaikh Kamaluddin
Quoted 9 lines · Shaikh Kamaluddin

Use the %pe printk format specifier to report error pointers directly instead of printing PTR_ERR() as a long value. A failed dport addition then reports -EBUSY rather than -16, which is easier to follow when tracing port and region setup with dynamic debug enabled.

Convert the five affected sites in drivers/cxl/core/port.c and drivers/cxl/core/region.c. PTR_ERR() uses in return statements are unaffected and left unchanged.

Quoted 7 lines

drivers/cxl was scanned in full; these are the only conversion candidates.

Found by: make coccicheck MODE=report M=drivers/cxl/ No functional change intended.

maintainer Applied
#3 lore raw
In reply to Shaikh Kamaluddin
Quoted 9 lines · Shaikh Kamaluddin

Use the %pe printk format specifier to report error pointers directly instead of printing PTR_ERR() as a long value. A failed dport addition then reports -EBUSY rather than -16, which is easier to follow when tracing port and region setup with dynamic debug enabled.

Convert the five affected sites in drivers/cxl/core/port.c and drivers/cxl/core/region.c. PTR_ERR() uses in return statements are unaffected and left unchanged.

Quoted 7 lines

drivers/cxl was scanned in full; these are the only conversion candidates.

Found by: make coccicheck MODE=report M=drivers/cxl/ No functional change intended.

Applied to cxl/next
4ee75140669c

Quoted 86 lines

---
Compile tested only with cxl config on x86.

v2:
- Reword commit message: lead with the code improvement, note coccinelle
only as the tool used to locate the sites (Alison)
- Capitalise subject per CXL convention (Alison)
- Note that drivers/cxl was scanned in full and these are the only
candidates (Alison)
- Clarify that the patch is compile tested only
- No code changes
Link to v1: https://lore.kernel.org/linux-cxl/[email protected]/

 drivers/cxl/core/port.c   | 13 ++++++-------
 drivers/cxl/core/region.c |  8 ++++----
 2 files changed, 10 insertions(+), 11 deletions(-)
drivers/cxl/core/port.c +6 -7
index 1215ee4f4035..c9875e6af9f6 100644
@@ -932,11 +932,10 @@ struct cxl_port *devm_cxl_add_port(struct device *host,
 
 	parent_port = parent_dport ? parent_dport->port : NULL;
 	if (IS_ERR(port)) {
-		dev_dbg(uport_dev, "Failed to add%s%s%s: %ld\n",
+		dev_dbg(uport_dev, "Failed to add%s%s%s: %pe\n",
 			parent_port ? " port to " : "",
 			parent_port ? dev_name(&parent_port->dev) : "",
-			parent_port ? "" : " root port",
-			PTR_ERR(port));
+			parent_port ? "" : " root port", port);
 	} else {
 		dev_dbg(uport_dev, "%s added%s%s%s\n",
 			dev_name(&port->dev),
@@ -1271,8 +1270,8 @@ struct cxl_dport *devm_cxl_add_dport(struct cxl_port *port,
 	dport = __devm_cxl_add_dport(port, dport_dev, port_id,
 				     component_reg_phys, CXL_RESOURCE_NONE);
 	if (IS_ERR(dport)) {
-		dev_dbg(dport_dev, "failed to add dport to %s: %ld\n",
-			dev_name(&port->dev), PTR_ERR(dport));
+		dev_dbg(dport_dev, "failed to add dport to %s: %pe\n",
+			dev_name(&port->dev), dport);
 	} else {
 		dev_dbg(dport_dev, "dport added to %s\n",
 			dev_name(&port->dev));
@@ -1305,8 +1304,8 @@ struct cxl_dport *devm_cxl_add_rch_dport(struct cxl_port *port,
 	dport = __devm_cxl_add_dport(port, dport_dev, port_id,
 				     CXL_RESOURCE_NONE, rcrb);
 	if (IS_ERR(dport)) {
-		dev_dbg(dport_dev, "failed to add RCH dport to %s: %ld\n",
-			dev_name(&port->dev), PTR_ERR(dport));
+		dev_dbg(dport_dev, "failed to add RCH dport to %s: %pe\n",
+			dev_name(&port->dev), dport);
 	} else {
 		dev_dbg(dport_dev, "RCH dport added to %s\n",
 			dev_name(&port->dev));
drivers/cxl/core/region.c +4 -4
index 1e211542b6b6..894df68a6074 100644
@@ -682,8 +682,8 @@ static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size)
 				    dev_name(&cxlr->dev));
 	if (IS_ERR(res)) {
 		dev_dbg(&cxlr->dev,
-			"HPA allocation error (%ld) for size:%pap in %s %pr\n",
-			PTR_ERR(res), &size, cxlrd->res->name, cxlrd->res);
+			"HPA allocation error (%pe) for size:%pap in %s %pr\n",
+			res, &size, cxlrd->res->name, cxlrd->res);
 		return PTR_ERR(res);
 	}
 
@@ -3773,9 +3773,9 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd,
 
 	if (IS_ERR(cxlr)) {
 		dev_err(cxlmd->dev.parent,
-			"%s:%s: %s failed assign region: %ld\n",
+			"%s:%s: %s failed assign region: %pe\n",
 			dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev),
-			__func__, PTR_ERR(cxlr));
+			__func__, cxlr);
 		return cxlr;
 	}
 

base-commit: f5098b6bae761e346ebcd9da7f95622c04733cff