mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cxl: use %pe to print error pointers
@ 2026-08-01 10:12 Shaikh Kamaluddin
  2026-08-01 17:13 ` Alison Schofield
  0 siblings, 1 reply; 3+ messages in thread
From: Shaikh Kamaluddin @ 2026-08-01 10:12 UTC (permalink / raw)
  To: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
	Vishal Verma, Dan Williams, Ira Weiny, Li Ming, Robert Richter,
	Gregory Price
  Cc: linux-cxl, linux-kernel

Make the code printing pointer error values simpler and address the
coccinelle warnings:

  drivers/cxl/core/port.c:939:3-10: WARNING: Consider using %pe to print PTR_ERR()
  drivers/cxl/core/port.c:1275:25-32: WARNING: Consider using %pe to print PTR_ERR()
  drivers/cxl/core/port.c:1309:25-32: WARNING: Consider using %pe to print PTR_ERR()
  drivers/cxl/core/region.c:686:3-10: WARNING: Consider using %pe to print PTR_ERR()
  drivers/cxl/core/region.c:3778:13-20: WARNING: Consider using %pe to print PTR_ERR()

The %pe specifier prints the error symbolically, so a failed dport
addition reports -EBUSY rather than -16, which is easier to follow
when tracing port and region setup with dynamic debug enabled.

The PTR_ERR() uses in return statements are left unchanged.

Signed-off-by: Shaikh Kamaluddin <shaikhkamal2012@gmail.com>
---
Tested with cxl config build in x86 Architecture

 drivers/cxl/core/port.c   | 13 ++++++-------
 drivers/cxl/core/region.c |  8 ++++----
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
index 1215ee4f4035..c9875e6af9f6 100644
--- a/drivers/cxl/core/port.c
+++ b/drivers/cxl/core/port.c
@@ -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));
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 1e211542b6b6..894df68a6074 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -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
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cxl: use %pe to print error pointers
  2026-08-01 10:12 [PATCH] cxl: use %pe to print error pointers Shaikh Kamaluddin
@ 2026-08-01 17:13 ` Alison Schofield
  2026-08-03 15:44   ` shaikh kamaluddin
  0 siblings, 1 reply; 3+ messages in thread
From: Alison Schofield @ 2026-08-01 17:13 UTC (permalink / raw)
  To: Shaikh Kamaluddin
  Cc: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Vishal Verma,
	Dan Williams, Ira Weiny, Li Ming, Robert Richter, Gregory Price,
	linux-cxl, linux-kernel

On Sat, Aug 01, 2026 at 03:42:17PM +0530, Shaikh Kamaluddin wrote:
> Make the code printing pointer error values simpler and address the
> coccinelle warnings:
> 
>   drivers/cxl/core/port.c:939:3-10: WARNING: Consider using %pe to print PTR_ERR()
>   drivers/cxl/core/port.c:1275:25-32: WARNING: Consider using %pe to print PTR_ERR()
>   drivers/cxl/core/port.c:1309:25-32: WARNING: Consider using %pe to print PTR_ERR()
>   drivers/cxl/core/region.c:686:3-10: WARNING: Consider using %pe to print PTR_ERR()
>   drivers/cxl/core/region.c:3778:13-20: WARNING: Consider using %pe to print PTR_ERR()
> 
> The %pe specifier prints the error symbolically, so a failed dport
> addition reports -EBUSY rather than -16, which is easier to follow
> when tracing port and region setup with dynamic debug enabled.
> 
> The PTR_ERR() uses in return statements are left unchanged.
> 
> Signed-off-by: Shaikh Kamaluddin <shaikhkamal2012@gmail.com>
> ---
> Tested with cxl config build in x86 Architecture
^  Should this say "Compile tested only with cxl ..."


Hi Shaikh,

Thanks for the patch. The code changes look perfect.

I'd like you to spin a v2 of this for the commit message and log
only. No code changes.

Commit message: follow CXL subject line format, start w uppercase.
ie: "cxl: Use %pe to print error pointers"

Commit log: Can this be reordered so that the code improvement is
the reason for the patch and coccinelle is only the tool that found
the sites?  We don't change code to address coccinelle warnings, we
use coccinelle to find code worth improving.

Please take a look at and follow the model in this commit for your v2:
c69ca4e992e3 ("mm/zswap: use %pe to print error pointers")

It would also be useful for the commit log to note that drivers/cxl
was completely scanned and that these are the only conversion candidates.
That documents the cleanup as complete and saves the next person from
wondering whether additional sites remain.

-- Alison

snip

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cxl: use %pe to print error pointers
  2026-08-01 17:13 ` Alison Schofield
@ 2026-08-03 15:44   ` shaikh kamaluddin
  0 siblings, 0 replies; 3+ messages in thread
From: shaikh kamaluddin @ 2026-08-03 15:44 UTC (permalink / raw)
  To: Alison Schofield
  Cc: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Vishal Verma,
	Dan Williams, Ira Weiny, Li Ming, Robert Richter, Gregory Price,
	linux-cxl, linux-kernel

On Sat, Aug 01, 2026 at 10:13:16AM -0700, Alison Schofield wrote:
> On Sat, Aug 01, 2026 at 03:42:17PM +0530, Shaikh Kamaluddin wrote:
> > Make the code printing pointer error values simpler and address the
> > coccinelle warnings:
> > 
> >   drivers/cxl/core/port.c:939:3-10: WARNING: Consider using %pe to print PTR_ERR()
> >   drivers/cxl/core/port.c:1275:25-32: WARNING: Consider using %pe to print PTR_ERR()
> >   drivers/cxl/core/port.c:1309:25-32: WARNING: Consider using %pe to print PTR_ERR()
> >   drivers/cxl/core/region.c:686:3-10: WARNING: Consider using %pe to print PTR_ERR()
> >   drivers/cxl/core/region.c:3778:13-20: WARNING: Consider using %pe to print PTR_ERR()
> > 
> > The %pe specifier prints the error symbolically, so a failed dport
> > addition reports -EBUSY rather than -16, which is easier to follow
> > when tracing port and region setup with dynamic debug enabled.
> > 
> > The PTR_ERR() uses in return statements are left unchanged.
> > 
> > Signed-off-by: Shaikh Kamaluddin <shaikhkamal2012@gmail.com>
> > ---
> > Tested with cxl config build in x86 Architecture
> ^  Should this say "Compile tested only with cxl ..."
> 
> 
> Hi Shaikh,
> 
> Thanks for the patch. The code changes look perfect.
> 
> I'd like you to spin a v2 of this for the commit message and log
> only. No code changes.
> 
> Commit message: follow CXL subject line format, start w uppercase.
> ie: "cxl: Use %pe to print error pointers"
> 
> Commit log: Can this be reordered so that the code improvement is
> the reason for the patch and coccinelle is only the tool that found
> the sites?  We don't change code to address coccinelle warnings, we
> use coccinelle to find code worth improving.
> 
> Please take a look at and follow the model in this commit for your v2:
> c69ca4e992e3 ("mm/zswap: use %pe to print error pointers")
> 
> It would also be useful for the commit log to note that drivers/cxl
> was completely scanned and that these are the only conversion candidates.
> That documents the cleanup as complete and saves the next person from
> wondering whether additional sites remain.
> 
> -- Alison
>
Hi Alison,

Thanks for the review and the helpful suggestions. I've incorporated them into v2.
v2 link: https://lore.kernel.org/all/20260802112029.28767-1-shaikhkamal2012@gmail.com/

Thanks,
Shaikh
> snip

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-03 15:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-01 10:12 [PATCH] cxl: use %pe to print error pointers Shaikh Kamaluddin
2026-08-01 17:13 ` Alison Schofield
2026-08-03 15:44   ` shaikh kamaluddin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®