usb: Use %pe to print error pointers
Subsystems (11)
v2 cover usb: Use %pe to print error pointers
Replace PTR_ERR() in format strings with
%pe format specifier across the USB subsystem. %pe prints symbolic error names (e.g., -ENOMEM) instead of raw numbers (e.g., -12), making error logs more readable. These patches fix coccinelle reported warning: "Consider using %pe to print PTR_ERR()" in usb subsystem.
The patches are grouped by subsystem:
1/3 - chipidea
2/3 - miscellaneous USB drivers
3/3 - typec
All patches are compile-tested on x86_64. Please let me know if any more testing is needed for any patch.
---
Changes in v2:
- Remove "This patch" phrasing from the commit message body.
- Trim redundant Coccinelle warning outputs in the commit log to keep only one.
- Clean up multi-line dev_err() statements into single lines.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Subasri S (3):
usb: chipidea: Use %pe to print error pointers
usb: misc: Use %pe to print error pointers
usb: typec: Use %pe to print error pointers
drivers/usb/atm/usbatm.c | 4 ++-- drivers/usb/chipidea/ci_hdrc_imx.c | 12 ++++++------ drivers/usb/chipidea/core.c | 4 ++-- drivers/usb/core/hub.c | 3 +-- drivers/usb/dwc2/pci.c | 3 +-- drivers/usb/gadget/function/u_serial.c | 4 ++-- drivers/usb/misc/usb3503.c | 3 +-- drivers/usb/typec/mux/pi3usb30532.c | 6 ++---- drivers/usb/typec/tcpm/tcpm.c | 2 +- drivers/usb/typec/wusb3801.c | 4 ++-- 10 files changed, 20 insertions(+), 25 deletions(-)
---
base-commit: a13c140cc289c0b7b3770bce5b3ad42ab35074aa
change-id: 20260718-usb-ptr_err_patchset-7c5d1547bee7
Best regards,
Signature · 1 line
Subasri S <[email protected]>
PATCH RESEND v2 1/3 usb: chipidea: Use %pe to print error pointers
Use the %pe format specifier instead of %ld with PTR_ERR() for printing error pointers in imx_get_clks(), ci_hdrc_imx_probe(), and ci_get_platdata(). This prints symbolic error names (e.g. -ENOMEM) instead of errno numbers (e.g. -12), making error logs more readable.
Fix coccinelle reported warning:
WARNING: Consider using %pe to print PTR_ERR()
Compile-tested only.
--- drivers/usb/chipidea/ci_hdrc_imx.c | 12 ++++++------ drivers/usb/chipidea/core.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/usb/chipidea/ci_hdrc_imx.c +6 -6
@@ -218,8 +218,8 @@ static int imx_get_clks(struct device *dev)if (IS_ERR (data->clk)) { ret =PTR_ERR (data->clk);dev_err (dev, -"Failed to get clks, err=%ld,%ld\n" , -PTR_ERR (data->clk),PTR_ERR (data->clk_ipg)); +"Failed to get clks, err=%pe,%pe\n" , + data->clk, data->clk_ipg);return ret; }/* Get wakeup clock. Not all of the platforms need to
@@ -448,8 +448,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) pinctrl_hsic_idle =pinctrl_lookup_state (data->pinctrl,"idle" );if (IS_ERR (pinctrl_hsic_idle)) {dev_err (dev, -"pinctrl_hsic_idle lookup failed, err=%ld\n" , -PTR_ERR (pinctrl_hsic_idle)); +"pinctrl_hsic_idle lookup failed, err=%pe\n" , + pinctrl_hsic_idle); ret =PTR_ERR (pinctrl_hsic_idle); goto err_put; }
@@ -464,8 +464,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) "active");if (IS_ERR (data->pinctrl_hsic_active)) {dev_err (dev, -"pinctrl_hsic_active lookup failed, err=%ld\n" , -PTR_ERR (data->pinctrl_hsic_active)); +"pinctrl_hsic_active lookup failed, err=%pe\n" , + data->pinctrl_hsic_active); ret =PTR_ERR (data->pinctrl_hsic_active); goto err_put; }
drivers/usb/chipidea/core.c +2 -2
@@ -680,8 +680,8 @@ static int ci_get_platdata(struct device *dev,/* no vbus regulator is needed */ platdata->reg_vbus =NULL ; }else if (IS_ERR (platdata->reg_vbus)) { -dev_err (dev,"Getting regulator error: %ld\n" , -PTR_ERR (platdata->reg_vbus)); +dev_err (dev,"Getting regulator error: %pe\n" , + platdata->reg_vbus);return PTR_ERR (platdata->reg_vbus); }/* Get TPL support */
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH RESEND v2 1/3] usb: chipidea: Use %pe to print error pointers
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines
Use the %pe format specifier instead of %ld with
PTR_ERR()for printing error pointers inimx_get_clks(),ci_hdrc_imx_probe(), andci_get_platdata(). This prints symbolic error names (e.g.-ENOMEM) instead of errno numbers (e.g. -12), making error logs more readable.
Quoted 8 lines
Fix coccinelle reported warning:
WARNING: Consider using %pe to printPTR_ERR()Compile-tested only.
Reviewed-by Frank Li <[email protected]>Acked-by Peter Chen <[email protected]>Signed-off-by Subasri S <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH RESEND v2 2/3 usb: misc: Use %pe to print error pointers
In reply to Subasri SUse the %pe format specifier instead of %ld with PTR_ERR() for printing error pointers in various drivers across usb subsystem.
This prints symbolic error names (e.g.-ENOMEM) instead of errno numbers (e.g. -12), making error logs more readable.
Fix coccinelle reported warnings:
WARNING: Consider using %pe to print PTR_ERR()
Compile tested only.
--- drivers/usb/atm/usbatm.c | 4 ++-- drivers/usb/core/hub.c | 3 +-- drivers/usb/dwc2/pci.c | 3 +-- drivers/usb/gadget/function/u_serial.c | 4 ++-- drivers/usb/misc/usb3503.c | 3 +-- 5 files changed, 7 insertions(+), 10 deletions(-)
drivers/usb/atm/usbatm.c +2 -2
@@ -979,8 +979,8 @@ static int usbatm_heavy_init(struct usbatm_data *instance) t =kthread_create (usbatm_do_heavy_init, instance,"%s" , instance->driver->driver_name);if (IS_ERR (t)) { -usb_err (instance,"%s: failed to create kernel_thread (%ld)!\n" , - __func__,PTR_ERR (t)); +usb_err (instance,"%s: failed to create kernel_thread (%pe)!\n" , + __func__, t);return PTR_ERR (t); }
drivers/usb/core/hub.c +1 -2
@@ -5671,8 +5671,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, descr =usb_get_device_descriptor (udev);if (IS_ERR (descr)) {dev_dbg (&udev->dev, -"can't read device descriptor %ld\n" , -PTR_ERR (descr)); +"can't read device descriptor %pe\n" , descr); }else {if (descriptors_changed (udev, descr, udev->bos)) {
drivers/usb/dwc2/pci.c +1 -2
@@ -68,8 +68,7 @@ static int dwc2_pci_probe(struct pci_dev *pci, phy =usb_phy_generic_register ();if (IS_ERR (phy)) { -dev_err (dev,"error registering generic PHY (%ld)\n" , -PTR_ERR (phy)); +dev_err (dev,"error registering generic PHY (%pe)\n" , phy);return PTR_ERR (phy); }
drivers/usb/gadget/function/u_serial.c +2 -2
@@ -1311,8 +1311,8 @@ int gserial_alloc_line_no_console(unsigned char *line_num) tty_dev =tty_port_register_device (&port->port, gs_tty_driver, port_num,NULL );if (IS_ERR (tty_dev)) { -pr_err ("%s: failed to register tty for port %d, err %ld\n" , - __func__, port_num,PTR_ERR (tty_dev)); +pr_err ("%s: failed to register tty for port %d, err %pe\n" , + __func__, port_num, tty_dev); ret =PTR_ERR (tty_dev);mutex_lock (&ports[port_num].lock);
drivers/usb/misc/usb3503.c +1 -2
@@ -202,8 +202,7 @@ static int usb3503_probe(struct usb3503 *hub) hub->clk =devm_clk_get_optional (dev,"refclk" );if (IS_ERR (hub->clk)) { -dev_err (dev,"unable to request refclk (%ld)\n" , -PTR_ERR (hub->clk)); +dev_err (dev,"unable to request refclk (%pe)\n" , hub->clk);return PTR_ERR (hub->clk); }
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH RESEND v2 2/3] usb: misc: Use %pe to print error pointers
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines
Use the %pe format specifier instead of %ld with
PTR_ERR()for printing error pointers in various drivers across usb subsystem.
This prints symbolic error names (e.g.-ENOMEM) instead of errno numbers (e.g. -12), making error logs more readable.
Quoted 7 lines
Fix coccinelle reported warnings:
WARNING: Consider using %pe to printPTR_ERR()Compile tested only.
Reviewed-by Frank Li <[email protected]>Signed-off-by Subasri S <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH RESEND v2 3/3 usb: typec: Use %pe to print error pointers
In reply to Subasri SUse the %pe format specifier instead of %ld with PTR_ERR() for printing error pointers in various typec drivers. This prints symbolic error names (e.g.-ENOMEM) instead of errno numbers (e.g. -12), making error logs more readable.
Fix coccinelle reported warning:
WARNING: Consider using %pe to print PTR_ERR()
Compile tested only.
--- drivers/usb/typec/mux/pi3usb30532.c | 6 ++---- drivers/usb/typec/tcpm/tcpm.c | 2 +- drivers/usb/typec/wusb3801.c | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-)
drivers/usb/typec/mux/pi3usb30532.c +2 -4
@@ -139,8 +139,7 @@ static int pi3usb30532_probe(struct i2c_client *client) pi->sw =typec_switch_register (dev, &sw_desc);if (IS_ERR (pi->sw)) { -dev_err (dev,"Error registering typec switch: %ld\n" , -PTR_ERR (pi->sw)); +dev_err (dev,"Error registering typec switch: %pe\n" , pi->sw);return PTR_ERR (pi->sw); }
@@ -151,8 +150,7 @@ static int pi3usb30532_probe(struct i2c_client *client) pi->mux =typec_mux_register (dev, &mux_desc);if (IS_ERR (pi->mux)) {typec_switch_unregister (pi->sw); -dev_err (dev,"Error registering typec mux: %ld\n" , -PTR_ERR (pi->mux)); +dev_err (dev,"Error registering typec mux: %pe\n" , pi->mux);return PTR_ERR (pi->mux); }
drivers/usb/typec/tcpm/tcpm.c +1 -1
@@ -4796,7 +4796,7 @@ static void tcpm_typec_connect(struct tcpm_port *port) port->partner_desc.accessory =TYPEC_ACCESSORY_NONE ; partner =typec_register_partner (port->typec_port, &port->partner_desc);if (IS_ERR (partner)) { -dev_err (port->dev,"Failed to register partner (%ld)\n" ,PTR_ERR (partner)); +dev_err (port->dev,"Failed to register partner (%pe)\n" , partner);return ; }
drivers/usb/typec/wusb3801.c +2 -2
@@ -277,8 +277,8 @@ static void wusb3801_hw_update(struct wusb3801 *wusb3801)if (partner_type !=WUSB3801_STAT_PARTNER_STANDBY ) { wusb3801->partner =typec_register_partner (port, &desc);if (IS_ERR (wusb3801->partner)) -dev_err (dev,"Failed to register partner: %ld\n" , -PTR_ERR (wusb3801->partner)); +dev_err (dev,"Failed to register partner: %pe\n" , + wusb3801->partner); } data_role = pwr_role ==TYPEC_SOURCE ?TYPEC_HOST :TYPEC_DEVICE ;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH RESEND v2 3/3] usb: typec: Use %pe to print error pointers
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines
Use the %pe format specifier instead of %ld with
PTR_ERR()for printing error pointers in various typec drivers. This prints symbolic error names (e.g.-ENOMEM) instead of errno numbers (e.g. -12), making error logs more readable.Fix coccinelle reported warning:
WARNING: Consider using %pe to printPTR_ERR()
Quoted 6 lines
Compile tested only.
Reviewed-by Badhri Jagan Sridharan <[email protected]>Reviewed-by Heikki Krogerus <[email protected]>Reviewed-by Frank Li <[email protected]>Signed-off-by Subasri S <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3