* [PATCH 01/17] usb: vhci-hcd: Ensure lines do not end with '('
2025-09-02 11:56 [PATCH 00/17] USB/IP VHCI driver cleanup Cristian Ciocaltea
@ 2025-09-02 11:56 ` Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 02/17] usb: vhci-hcd: Consistently use the braces Cristian Ciocaltea
` (15 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-09-02 11:56 UTC (permalink / raw)
To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman
Cc: kernel, linux-usb, linux-kernel
Format code to get rid of the checkpatch complaint:
CHECK: Lines should not end with a '('
While at it, also remove the leading whitespace from the quoted
strings passed as arguments to the affected functions.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/usb/usbip/vhci_hcd.c | 46 +++++++++++++++++---------------------------
1 file changed, 18 insertions(+), 28 deletions(-)
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index e70fba9f55d6a0edf3c5fde56a614dd3799406a1..764ade343bd4fb9d680f518ead997f6165214214 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -289,8 +289,8 @@ ss_hub_descriptor(struct usb_hub_descriptor *desc)
memset(desc, 0, sizeof *desc);
desc->bDescriptorType = USB_DT_SS_HUB;
desc->bDescLength = 12;
- desc->wHubCharacteristics = cpu_to_le16(
- HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_COMMON_OCPM);
+ desc->wHubCharacteristics = cpu_to_le16(HUB_CHAR_INDV_PORT_LPSM |
+ HUB_CHAR_COMMON_OCPM);
desc->bNbrPorts = VHCI_HC_PORTS;
desc->u.ss.bHubHdrDecLat = 0x04; /* Worst case: 0.4 micro sec*/
desc->u.ss.DeviceRemovable = 0xffff;
@@ -302,9 +302,8 @@ static inline void hub_descriptor(struct usb_hub_descriptor *desc)
memset(desc, 0, sizeof(*desc));
desc->bDescriptorType = USB_DT_HUB;
- desc->wHubCharacteristics = cpu_to_le16(
- HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_COMMON_OCPM);
-
+ desc->wHubCharacteristics = cpu_to_le16(HUB_CHAR_INDV_PORT_LPSM |
+ HUB_CHAR_COMMON_OCPM);
desc->bNbrPorts = VHCI_HC_PORTS;
BUILD_BUG_ON(VHCI_HC_PORTS > USB_MAXCHILDREN);
width = desc->bNbrPorts / 8 + 1;
@@ -378,8 +377,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
"supported for USB 3.0 roothub\n");
goto error;
}
- usbip_dbg_vhci_rh(
- " ClearPortFeature: USB_PORT_FEAT_SUSPEND\n");
+
+ usbip_dbg_vhci_rh("ClearPortFeature: USB_PORT_FEAT_SUSPEND\n");
if (vhci_hcd->port_status[rhport] & USB_PORT_STAT_SUSPEND) {
/* 20msec signaling */
vhci_hcd->resuming = 1;
@@ -387,8 +386,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
}
break;
case USB_PORT_FEAT_POWER:
- usbip_dbg_vhci_rh(
- " ClearPortFeature: USB_PORT_FEAT_POWER\n");
+ usbip_dbg_vhci_rh("ClearPortFeature: USB_PORT_FEAT_POWER\n");
if (hcd->speed >= HCD_USB3)
vhci_hcd->port_status[rhport] &= ~USB_SS_PORT_STAT_POWER;
else
@@ -464,10 +462,9 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
VDEV_ST_NOTASSIGNED ||
vhci_hcd->vdev[rhport].ud.status ==
VDEV_ST_USED) {
- usbip_dbg_vhci_rh(
- " enable rhport %d (status %u)\n",
- rhport,
- vhci_hcd->vdev[rhport].ud.status);
+ usbip_dbg_vhci_rh("enable rhport %d (status %u)\n",
+ rhport,
+ vhci_hcd->vdev[rhport].ud.status);
vhci_hcd->port_status[rhport] |=
USB_PORT_STAT_ENABLE;
}
@@ -502,8 +499,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
case SetPortFeature:
switch (wValue) {
case USB_PORT_FEAT_LINK_STATE:
- usbip_dbg_vhci_rh(
- " SetPortFeature: USB_PORT_FEAT_LINK_STATE\n");
+ usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_LINK_STATE\n");
if (hcd->speed < HCD_USB3) {
pr_err("USB_PORT_FEAT_LINK_STATE req not "
"supported for USB 2.0 roothub\n");
@@ -515,12 +511,10 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
*/
break;
case USB_PORT_FEAT_U1_TIMEOUT:
- usbip_dbg_vhci_rh(
- " SetPortFeature: USB_PORT_FEAT_U1_TIMEOUT\n");
+ usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_U1_TIMEOUT\n");
fallthrough;
case USB_PORT_FEAT_U2_TIMEOUT:
- usbip_dbg_vhci_rh(
- " SetPortFeature: USB_PORT_FEAT_U2_TIMEOUT\n");
+ usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_U2_TIMEOUT\n");
/* TODO: add suspend/resume support! */
if (hcd->speed < HCD_USB3) {
pr_err("USB_PORT_FEAT_U1/2_TIMEOUT req not "
@@ -529,8 +523,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
}
break;
case USB_PORT_FEAT_SUSPEND:
- usbip_dbg_vhci_rh(
- " SetPortFeature: USB_PORT_FEAT_SUSPEND\n");
+ usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_SUSPEND\n");
/* Applicable only for USB2.0 hub */
if (hcd->speed >= HCD_USB3) {
pr_err("USB_PORT_FEAT_SUSPEND req not "
@@ -546,8 +539,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
vhci_hcd->port_status[rhport] |= USB_PORT_STAT_SUSPEND;
break;
case USB_PORT_FEAT_POWER:
- usbip_dbg_vhci_rh(
- " SetPortFeature: USB_PORT_FEAT_POWER\n");
+ usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_POWER\n");
if (invalid_rhport) {
pr_err("invalid port number %d\n", wIndex);
goto error;
@@ -558,8 +550,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
vhci_hcd->port_status[rhport] |= USB_PORT_STAT_POWER;
break;
case USB_PORT_FEAT_BH_PORT_RESET:
- usbip_dbg_vhci_rh(
- " SetPortFeature: USB_PORT_FEAT_BH_PORT_RESET\n");
+ usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_BH_PORT_RESET\n");
if (invalid_rhport) {
pr_err("invalid port number %d\n", wIndex);
goto error;
@@ -572,8 +563,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
}
fallthrough;
case USB_PORT_FEAT_RESET:
- usbip_dbg_vhci_rh(
- " SetPortFeature: USB_PORT_FEAT_RESET\n");
+ usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_RESET\n");
if (invalid_rhport) {
pr_err("invalid port number %d\n", wIndex);
goto error;
@@ -781,7 +771,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
case USB_REQ_GET_DESCRIPTOR:
if (ctrlreq->wValue == cpu_to_le16(USB_DT_DEVICE << 8))
- usbip_dbg_vhci_hc(
+ usbip_dbg_vhci_hc(/**/
"Not yet?:Get_Descriptor to device 0 (get max pipe size)\n");
vdev->udev = usb_get_dev(urb->dev);
--
2.51.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 02/17] usb: vhci-hcd: Consistently use the braces
2025-09-02 11:56 [PATCH 00/17] USB/IP VHCI driver cleanup Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 01/17] usb: vhci-hcd: Ensure lines do not end with '(' Cristian Ciocaltea
@ 2025-09-02 11:56 ` Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 03/17] usb: vhci-hcd: Avoid unnecessary use of braces Cristian Ciocaltea
` (14 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-09-02 11:56 UTC (permalink / raw)
To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman
Cc: kernel, linux-usb, linux-kernel
Fix the inconsistent usage of braces as reported by checkpatch:
CHECK: braces {} should be used on all arms of this statement
CHECK: Unbalanced braces around else statement
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/usb/usbip/vhci_hcd.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 764ade343bd4fb9d680f518ead997f6165214214..437c5dd8fa077310f4f15c3dd03cd805650b8999 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -346,8 +346,9 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
invalid_rhport = true;
if (wIndex > VHCI_HC_PORTS)
pr_err("invalid port number %d\n", wIndex);
- } else
+ } else {
rhport = wIndex - 1;
+ }
vhci_hcd = hcd_to_vhci_hcd(hcd);
vhci = vhci_hcd->vhci;
@@ -598,11 +599,12 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
USB_SS_PORT_STAT_POWER) != 0) {
vhci_hcd->port_status[rhport] |= (1 << wValue);
}
- } else
+ } else {
if ((vhci_hcd->port_status[rhport] &
USB_PORT_STAT_POWER) != 0) {
vhci_hcd->port_status[rhport] |= (1 << wValue);
}
+ }
}
break;
case GetPortErrorCount:
--
2.51.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 03/17] usb: vhci-hcd: Avoid unnecessary use of braces
2025-09-02 11:56 [PATCH 00/17] USB/IP VHCI driver cleanup Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 01/17] usb: vhci-hcd: Ensure lines do not end with '(' Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 02/17] usb: vhci-hcd: Consistently use the braces Cristian Ciocaltea
@ 2025-09-02 11:56 ` Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 04/17] usb: vhci-hcd: Consistently use blank lines Cristian Ciocaltea
` (13 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-09-02 11:56 UTC (permalink / raw)
To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman
Cc: kernel, linux-usb, linux-kernel
Improve code readability in vhci_urb_dequeue() by getting rid of a pair
of braces and reduce the indentation level of the related code block.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/usb/usbip/vhci_hcd.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 437c5dd8fa077310f4f15c3dd03cd805650b8999..8b8012440f66f97c34ffc39d1a927b74f035ac91 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -866,6 +866,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
struct vhci_priv *priv;
struct vhci_device *vdev;
unsigned long flags;
+ int ret;
spin_lock_irqsave(&vhci->lock, flags);
@@ -877,14 +878,10 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
return -EIDRM;
}
- {
- int ret = 0;
-
- ret = usb_hcd_check_unlink_urb(hcd, urb, status);
- if (ret) {
- spin_unlock_irqrestore(&vhci->lock, flags);
- return ret;
- }
+ ret = usb_hcd_check_unlink_urb(hcd, urb, status);
+ if (ret) {
+ spin_unlock_irqrestore(&vhci->lock, flags);
+ return ret;
}
/* send unlink request here? */
--
2.51.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 04/17] usb: vhci-hcd: Consistently use blank lines
2025-09-02 11:56 [PATCH 00/17] USB/IP VHCI driver cleanup Cristian Ciocaltea
` (2 preceding siblings ...)
2025-09-02 11:56 ` [PATCH 03/17] usb: vhci-hcd: Avoid unnecessary use of braces Cristian Ciocaltea
@ 2025-09-02 11:56 ` Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 05/17] usb: vhci-hcd: Drop spaces after casts Cristian Ciocaltea
` (12 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-09-02 11:56 UTC (permalink / raw)
To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman
Cc: kernel, linux-usb, linux-kernel
Add blank lines where it helps improve code readability and drop those
which are really not required, as indicated by checkpatch:
CHECK: Blank lines aren't necessary after an open brace '{'
CHECK: Blank lines aren't necessary before a close brace '}'
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/usb/usbip/vhci_hcd.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 8b8012440f66f97c34ffc39d1a927b74f035ac91..59478e8f6c97ac4dad0aaa887df3d169c13aee27 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -145,6 +145,7 @@ static void dump_port_status_diff(u32 prev_status, u32 new_status, bool usb3)
if (bit == 1) /* USB_PORT_STAT_CONNECTION */
pr_debug(" %c%s\n", change, "USB_PORT_STAT_SPEED_5GBPS");
}
+
bit <<= 1;
i++;
}
@@ -267,7 +268,6 @@ static struct {
struct usb_bos_descriptor bos;
struct usb_ss_cap_descriptor ss_cap;
} __packed usb3_bos_desc = {
-
.bos = {
.bLength = USB_DT_BOS_SIZE,
.bDescriptorType = USB_DT_BOS,
@@ -306,6 +306,7 @@ static inline void hub_descriptor(struct usb_hub_descriptor *desc)
HUB_CHAR_COMMON_OCPM);
desc->bNbrPorts = VHCI_HC_PORTS;
BUILD_BUG_ON(VHCI_HC_PORTS > USB_MAXCHILDREN);
+
width = desc->bNbrPorts / 8 + 1;
desc->bDescLength = USB_DT_HUB_NONVAR_SIZE + 2 * width;
memset(&desc->u.hs.DeviceRemovable[0], 0, width);
@@ -371,6 +372,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
pr_err("invalid port number %d\n", wIndex);
goto error;
}
+
switch (wValue) {
case USB_PORT_FEAT_SUSPEND:
if (hcd->speed >= HCD_USB3) {
@@ -398,6 +400,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
wValue);
if (wValue >= 32)
goto error;
+
vhci_hcd->port_status[rhport] &= ~(1 << wValue);
break;
}
@@ -410,6 +413,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
pr_err("Wrong hub descriptor type for USB 3.0 roothub.\n");
goto error;
}
+
if (hcd->speed >= HCD_USB3)
ss_hub_descriptor((struct usb_hub_descriptor *) buf);
else
@@ -506,6 +510,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
"supported for USB 2.0 roothub\n");
goto error;
}
+
/*
* Since this is dummy we don't have an actual link so
* there is nothing to do for the SET_LINK_STATE cmd
@@ -545,6 +550,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
pr_err("invalid port number %d\n", wIndex);
goto error;
}
+
if (hcd->speed >= HCD_USB3)
vhci_hcd->port_status[rhport] |= USB_SS_PORT_STAT_POWER;
else
@@ -556,6 +562,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
pr_err("invalid port number %d\n", wIndex);
goto error;
}
+
/* Applicable only for USB3.0 hub */
if (hcd->speed < HCD_USB3) {
pr_err("USB_PORT_FEAT_BH_PORT_RESET req not "
@@ -569,6 +576,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
pr_err("invalid port number %d\n", wIndex);
goto error;
}
+
/* if it's already enabled, disable */
if (hcd->speed >= HCD_USB3) {
vhci_hcd->port_status[rhport] = 0;
@@ -592,8 +600,10 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
pr_err("invalid port number %d\n", wIndex);
goto error;
}
+
if (wValue >= 32)
goto error;
+
if (hcd->speed >= HCD_USB3) {
if ((vhci_hcd->port_status[rhport] &
USB_SS_PORT_STAT_POWER) != 0) {
@@ -722,6 +732,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
spin_unlock_irqrestore(&vhci->lock, flags);
return -ENODEV;
}
+
spin_unlock(&vdev->ud.lock);
ret = usb_hcd_link_urb_to_ep(hcd, urb);
@@ -789,7 +800,6 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
ret = -EINVAL;
goto no_need_xmit;
}
-
}
out:
@@ -810,6 +820,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
usb_hcd_giveback_urb(hcd, urb, urb->status);
local_irq_enable();
}
+
return ret;
}
@@ -1200,12 +1211,14 @@ static int vhci_start(struct usb_hcd *hcd)
dev_err(hcd_dev(hcd), "init attr group failed, err = %d\n", err);
return err;
}
+
err = sysfs_create_group(&hcd_dev(hcd)->kobj, &vhci_attr_group);
if (err) {
dev_err(hcd_dev(hcd), "create sysfs files failed, err = %d\n", err);
vhci_finish_attr_group();
return err;
}
+
pr_info("created sysfs %s\n", hcd_name(hcd));
}
@@ -1267,10 +1280,12 @@ static int vhci_bus_resume(struct usb_hcd *hcd)
dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__);
spin_lock_irqsave(&vhci->lock, flags);
+
if (!HCD_HW_ACCESSIBLE(hcd))
rc = -ESHUTDOWN;
else
hcd->state = HC_STATE_RUNNING;
+
spin_unlock_irqrestore(&vhci->lock, flags);
return rc;
@@ -1343,6 +1358,7 @@ static int vhci_hcd_probe(struct platform_device *pdev)
pr_err("create primary hcd failed\n");
return -ENOMEM;
}
+
hcd_hs->has_tt = 1;
/*
@@ -1458,6 +1474,7 @@ static int vhci_hcd_resume(struct platform_device *pdev)
hcd = platform_get_drvdata(pdev);
if (!hcd)
return 0;
+
set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
usb_hcd_poll_rh_status(hcd);
@@ -1489,6 +1506,7 @@ static void del_platform_devices(void)
platform_device_unregister(vhcis[i].pdev);
vhcis[i].pdev = NULL;
}
+
sysfs_remove_link(&platform_bus.kobj, driver_name);
}
--
2.51.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 05/17] usb: vhci-hcd: Drop spaces after casts
2025-09-02 11:56 [PATCH 00/17] USB/IP VHCI driver cleanup Cristian Ciocaltea
` (3 preceding siblings ...)
2025-09-02 11:56 ` [PATCH 04/17] usb: vhci-hcd: Consistently use blank lines Cristian Ciocaltea
@ 2025-09-02 11:56 ` Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 06/17] usb: vhci-hcd: Add spaces around operators Cristian Ciocaltea
` (11 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-09-02 11:56 UTC (permalink / raw)
To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman
Cc: kernel, linux-usb, linux-kernel
Fix a bunch of checkpatch reports:
CHECK: No space is necessary after a cast
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/usb/usbip/vhci_hcd.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 59478e8f6c97ac4dad0aaa887df3d169c13aee27..df25ac939a2273571391562227d5c1628a6377e2 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -415,9 +415,9 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
}
if (hcd->speed >= HCD_USB3)
- ss_hub_descriptor((struct usb_hub_descriptor *) buf);
+ ss_hub_descriptor((struct usb_hub_descriptor *)buf);
else
- hub_descriptor((struct usb_hub_descriptor *) buf);
+ hub_descriptor((struct usb_hub_descriptor *)buf);
break;
case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
if (hcd->speed < HCD_USB3)
@@ -431,7 +431,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
break;
case GetHubStatus:
usbip_dbg_vhci_rh(" GetHubStatus\n");
- *(__le32 *) buf = cpu_to_le32(0);
+ *(__le32 *)buf = cpu_to_le32(0);
break;
case GetPortStatus:
usbip_dbg_vhci_rh(" GetPortStatus port %x\n", wIndex);
@@ -490,8 +490,9 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
}
}
}
- ((__le16 *) buf)[0] = cpu_to_le16(vhci_hcd->port_status[rhport]);
- ((__le16 *) buf)[1] =
+
+ ((__le16 *)buf)[0] = cpu_to_le16(vhci_hcd->port_status[rhport]);
+ ((__le16 *)buf)[1] =
cpu_to_le16(vhci_hcd->port_status[rhport] >> 16);
usbip_dbg_vhci_rh(" GetPortStatus bye %x %x\n", ((u16 *)buf)[0],
@@ -625,7 +626,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
goto error;
}
/* We'll always return 0 since this is a dummy hub */
- *(__le32 *) buf = cpu_to_le32(0);
+ *(__le32 *)buf = cpu_to_le32(0);
break;
case SetHubDepth:
usbip_dbg_vhci_rh(" SetHubDepth\n");
@@ -685,7 +686,7 @@ static void vhci_tx_urb(struct urb *urb, struct vhci_device *vdev)
priv->vdev = vdev;
priv->urb = urb;
- urb->hcpriv = (void *) priv;
+ urb->hcpriv = (void *)priv;
list_add_tail(&priv->list, &vdev->priv_tx);
@@ -752,7 +753,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
struct usb_device *old;
__u8 type = usb_pipetype(urb->pipe);
struct usb_ctrlrequest *ctrlreq =
- (struct usb_ctrlrequest *) urb->setup_packet;
+ (struct usb_ctrlrequest *)urb->setup_packet;
if (type != PIPE_CONTROL || !ctrlreq) {
dev_err(dev, "invalid request to devnum 0\n");
--
2.51.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 06/17] usb: vhci-hcd: Add spaces around operators
2025-09-02 11:56 [PATCH 00/17] USB/IP VHCI driver cleanup Cristian Ciocaltea
` (4 preceding siblings ...)
2025-09-02 11:56 ` [PATCH 05/17] usb: vhci-hcd: Drop spaces after casts Cristian Ciocaltea
@ 2025-09-02 11:56 ` Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 07/17] usb: vhci-hcd: Drop unnecessary parentheses Cristian Ciocaltea
` (10 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-09-02 11:56 UTC (permalink / raw)
To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman
Cc: kernel, linux-usb, linux-kernel
Fix a couple of checkpatch reports:
CHECK: spaces preferred around that '-' (ctx:VxV)
CHECK: spaces preferred around that '+' (ctx:VxV)
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/usb/usbip/vhci_hcd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index df25ac939a2273571391562227d5c1628a6377e2..1b442bc564ed26185d172daa32cabd1a3f50f322 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -708,7 +708,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
pr_err("invalid port number %d\n", portnum);
return -ENODEV;
}
- vdev = &vhci_hcd->vdev[portnum-1];
+ vdev = &vhci_hcd->vdev[portnum - 1];
if (!urb->transfer_buffer && !urb->num_sgs &&
urb->transfer_buffer_length) {
@@ -1135,7 +1135,7 @@ static int hcd_name_to_id(const char *name)
if (c == NULL)
return 0;
- ret = kstrtol(c+1, 10, &val);
+ ret = kstrtol(c + 1, 10, &val);
if (ret < 0)
return ret;
--
2.51.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 07/17] usb: vhci-hcd: Drop unnecessary parentheses
2025-09-02 11:56 [PATCH 00/17] USB/IP VHCI driver cleanup Cristian Ciocaltea
` (5 preceding siblings ...)
2025-09-02 11:56 ` [PATCH 06/17] usb: vhci-hcd: Add spaces around operators Cristian Ciocaltea
@ 2025-09-02 11:56 ` Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 08/17] usb: vhci-hcd: Fix open parenthesis alignment Cristian Ciocaltea
` (9 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-09-02 11:56 UTC (permalink / raw)
To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman
Cc: kernel, linux-usb, linux-kernel
Fix a checkpatch complaint:
CHECK: Unnecessary parentheses around
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/usb/usbip/vhci_hcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 1b442bc564ed26185d172daa32cabd1a3f50f322..4ddf7972490d115620f180aa7d4c9bf09e2aaae7 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -255,7 +255,7 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
}
}
- if ((hcd->state == HC_STATE_SUSPENDED) && (changed == 1))
+ if (hcd->state == HC_STATE_SUSPENDED && changed == 1)
usb_hcd_resume_root_hub(hcd);
done:
--
2.51.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 08/17] usb: vhci-hcd: Fix open parenthesis alignment
2025-09-02 11:56 [PATCH 00/17] USB/IP VHCI driver cleanup Cristian Ciocaltea
` (6 preceding siblings ...)
2025-09-02 11:56 ` [PATCH 07/17] usb: vhci-hcd: Drop unnecessary parentheses Cristian Ciocaltea
@ 2025-09-02 11:56 ` Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 09/17] usb: vhci-hcd: Simplify NULL comparison Cristian Ciocaltea
` (8 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-09-02 11:56 UTC (permalink / raw)
To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman
Cc: kernel, linux-usb, linux-kernel
Address a bunch of checkpatch complaints:
CHECK: Alignment should match open parenthesis
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/usb/usbip/vhci_hcd.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 4ddf7972490d115620f180aa7d4c9bf09e2aaae7..d3933979689f8cd141b3554e902c1e7b9fc6c694 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -360,7 +360,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
if (usbip_dbg_flag_vhci_rh) {
if (!invalid_rhport)
memcpy(prev_port_status, vhci_hcd->port_status,
- sizeof(prev_port_status));
+ sizeof(prev_port_status));
}
switch (typeReq) {
@@ -408,8 +408,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
case GetHubDescriptor:
usbip_dbg_vhci_rh(" GetHubDescriptor\n");
if (hcd->speed >= HCD_USB3 &&
- (wLength < USB_DT_SS_HUB_SIZE ||
- wValue != (USB_DT_SS_HUB << 8))) {
+ (wLength < USB_DT_SS_HUB_SIZE || wValue != (USB_DT_SS_HUB << 8))) {
pr_err("Wrong hub descriptor type for USB 3.0 roothub.\n");
goto error;
}
@@ -711,7 +710,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
vdev = &vhci_hcd->vdev[portnum - 1];
if (!urb->transfer_buffer && !urb->num_sgs &&
- urb->transfer_buffer_length) {
+ urb->transfer_buffer_length) {
dev_dbg(dev, "Null URB transfer buffer\n");
return -EINVAL;
}
@@ -956,7 +955,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
}
static void vhci_cleanup_unlink_list(struct vhci_device *vdev,
- struct list_head *unlink_list)
+ struct list_head *unlink_list)
{
struct vhci_hcd *vhci_hcd = vdev_to_vhci_hcd(vdev);
struct usb_hcd *hcd = vhci_hcd_to_hcd(vhci_hcd);
@@ -1300,8 +1299,8 @@ static int vhci_bus_resume(struct usb_hcd *hcd)
/* Change a group of bulk endpoints to support multiple stream IDs */
static int vhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev,
- struct usb_host_endpoint **eps, unsigned int num_eps,
- unsigned int num_streams, gfp_t mem_flags)
+ struct usb_host_endpoint **eps, unsigned int num_eps,
+ unsigned int num_streams, gfp_t mem_flags)
{
dev_dbg(&hcd->self.root_hub->dev, "vhci_alloc_streams not implemented\n");
return 0;
@@ -1309,8 +1308,8 @@ static int vhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev,
/* Reverts a group of bulk endpoints back to not using stream IDs. */
static int vhci_free_streams(struct usb_hcd *hcd, struct usb_device *udev,
- struct usb_host_endpoint **eps, unsigned int num_eps,
- gfp_t mem_flags)
+ struct usb_host_endpoint **eps, unsigned int num_eps,
+ gfp_t mem_flags)
{
dev_dbg(&hcd->self.root_hub->dev, "vhci_free_streams not implemented\n");
return 0;
--
2.51.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 09/17] usb: vhci-hcd: Simplify NULL comparison
2025-09-02 11:56 [PATCH 00/17] USB/IP VHCI driver cleanup Cristian Ciocaltea
` (7 preceding siblings ...)
2025-09-02 11:56 ` [PATCH 08/17] usb: vhci-hcd: Fix open parenthesis alignment Cristian Ciocaltea
@ 2025-09-02 11:56 ` Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 10/17] usb: vhci-hcd: Simplify kzalloc usage Cristian Ciocaltea
` (7 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-09-02 11:56 UTC (permalink / raw)
To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman
Cc: kernel, linux-usb, linux-kernel
Use the shorter variants as suggested by checkpatch.pl:
CHECK: Comparison to NULL could be written "!c"
CHECK: Comparison to NULL could be written "!vhcis"
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/usb/usbip/vhci_hcd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index d3933979689f8cd141b3554e902c1e7b9fc6c694..e989be33ada00d5073f5753b72bb71d349c67b83 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -1131,7 +1131,7 @@ static int hcd_name_to_id(const char *name)
int ret;
c = strchr(name, '.');
- if (c == NULL)
+ if (!c)
return 0;
ret = kstrtol(c + 1, 10, &val);
@@ -1521,7 +1521,7 @@ static int __init vhci_hcd_init(void)
vhci_num_controllers = 1;
vhcis = kcalloc(vhci_num_controllers, sizeof(struct vhci), GFP_KERNEL);
- if (vhcis == NULL)
+ if (!vhcis)
return -ENOMEM;
ret = platform_driver_register(&vhci_driver);
--
2.51.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 10/17] usb: vhci-hcd: Simplify kzalloc usage
2025-09-02 11:56 [PATCH 00/17] USB/IP VHCI driver cleanup Cristian Ciocaltea
` (8 preceding siblings ...)
2025-09-02 11:56 ` [PATCH 09/17] usb: vhci-hcd: Simplify NULL comparison Cristian Ciocaltea
@ 2025-09-02 11:56 ` Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 11/17] usb: vhci-hcd: Use the paranthesized form of sizeof Cristian Ciocaltea
` (6 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-09-02 11:56 UTC (permalink / raw)
To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman
Cc: kernel, linux-usb, linux-kernel
Use the shorter variants as suggested by checkpatch.pl:
CHECK: Prefer kzalloc(sizeof(*priv)...) over kzalloc(sizeof(struct vhci_priv)...)
CHECK: Prefer kzalloc(sizeof(*unlink)...) over kzalloc(sizeof(struct vhci_unlink)...)
This also improves further maintainability.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/usb/usbip/vhci_hcd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index e989be33ada00d5073f5753b72bb71d349c67b83..5b9cc84947781f79d69751ebda950cb293db7cb6 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -670,7 +670,7 @@ static void vhci_tx_urb(struct urb *urb, struct vhci_device *vdev)
struct vhci_hcd *vhci_hcd = vdev_to_vhci_hcd(vdev);
unsigned long flags;
- priv = kzalloc(sizeof(struct vhci_priv), GFP_ATOMIC);
+ priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
if (!priv) {
usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_MALLOC);
return;
@@ -926,7 +926,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
spin_lock(&vdev->priv_lock);
/* setup CMD_UNLINK pdu */
- unlink = kzalloc(sizeof(struct vhci_unlink), GFP_ATOMIC);
+ unlink = kzalloc(sizeof(*unlink), GFP_ATOMIC);
if (!unlink) {
spin_unlock(&vdev->priv_lock);
spin_unlock_irqrestore(&vhci->lock, flags);
--
2.51.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 11/17] usb: vhci-hcd: Use the paranthesized form of sizeof
2025-09-02 11:56 [PATCH 00/17] USB/IP VHCI driver cleanup Cristian Ciocaltea
` (9 preceding siblings ...)
2025-09-02 11:56 ` [PATCH 10/17] usb: vhci-hcd: Simplify kzalloc usage Cristian Ciocaltea
@ 2025-09-02 11:56 ` Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 12/17] usb: vhci-hcd: Fix block comments Cristian Ciocaltea
` (5 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-09-02 11:56 UTC (permalink / raw)
To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman
Cc: kernel, linux-usb, linux-kernel
Fix the sizeof usage issue reported by checkpatch.pl:
WARNING: sizeof *desc should be sizeof(*desc)
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/usb/usbip/vhci_hcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 5b9cc84947781f79d69751ebda950cb293db7cb6..3296914dc89e6e7b7754b92d02b44de441c6714e 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -286,7 +286,7 @@ static struct {
static inline void
ss_hub_descriptor(struct usb_hub_descriptor *desc)
{
- memset(desc, 0, sizeof *desc);
+ memset(desc, 0, sizeof(*desc));
desc->bDescriptorType = USB_DT_SS_HUB;
desc->bDescLength = 12;
desc->wHubCharacteristics = cpu_to_le16(HUB_CHAR_INDV_PORT_LPSM |
--
2.51.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 12/17] usb: vhci-hcd: Fix block comments
2025-09-02 11:56 [PATCH 00/17] USB/IP VHCI driver cleanup Cristian Ciocaltea
` (10 preceding siblings ...)
2025-09-02 11:56 ` [PATCH 11/17] usb: vhci-hcd: Use the paranthesized form of sizeof Cristian Ciocaltea
@ 2025-09-02 11:56 ` Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 13/17] usb: vhci-hcd: Remove ftrace-like logging Cristian Ciocaltea
` (4 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-09-02 11:56 UTC (permalink / raw)
To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman
Cc: kernel, linux-usb, linux-kernel
Address a couple of comment formatting issues indicated by
checkpatch.pl:
WARNING: Block comments use a trailing */ on a separate line
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/usb/usbip/vhci_hcd.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 3296914dc89e6e7b7754b92d02b44de441c6714e..5b4133f08d370499bdbc50fbea7ecbbc0fbd4b71 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -883,8 +883,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
priv = urb->hcpriv;
if (!priv) {
- /* URB was never linked! or will be soon given back by
- * vhci_rx. */
+ /* URB was never linked! or will be soon given back by vhci_rx */
spin_unlock_irqrestore(&vhci->lock, flags);
return -EIDRM;
}
@@ -940,8 +939,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
unlink->unlink_seqnum = priv->seqnum;
- /* send cmd_unlink and try to cancel the pending URB in the
- * peer */
+ /* Send cmd_unlink and try to cancel the pending URB in the peer */
list_add_tail(&unlink->list, &vdev->unlink_tx);
wake_up(&vdev->waitq_tx);
--
2.51.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 13/17] usb: vhci-hcd: Remove ftrace-like logging
2025-09-02 11:56 [PATCH 00/17] USB/IP VHCI driver cleanup Cristian Ciocaltea
` (11 preceding siblings ...)
2025-09-02 11:56 ` [PATCH 12/17] usb: vhci-hcd: Fix block comments Cristian Ciocaltea
@ 2025-09-02 11:56 ` Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 14/17] usb: vhci-hcd: Consistently use __func__ Cristian Ciocaltea
` (3 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-09-02 11:56 UTC (permalink / raw)
To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman
Cc: kernel, linux-usb, linux-kernel
Drop all superfluous log entries as reported by checkpatch:
WARNING: Unnecessary ftrace-like logging - prefer using ftrace
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/usb/usbip/vhci_hcd.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 5b4133f08d370499bdbc50fbea7ecbbc0fbd4b71..a71a542e6eec42c79cff091fe0168f44c8c9b4b2 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -1260,8 +1260,6 @@ static int vhci_bus_suspend(struct usb_hcd *hcd)
struct vhci *vhci = *((void **)dev_get_platdata(hcd->self.controller));
unsigned long flags;
- dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__);
-
spin_lock_irqsave(&vhci->lock, flags);
hcd->state = HC_STATE_SUSPENDED;
spin_unlock_irqrestore(&vhci->lock, flags);
@@ -1275,8 +1273,6 @@ static int vhci_bus_resume(struct usb_hcd *hcd)
int rc = 0;
unsigned long flags;
- dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__);
-
spin_lock_irqsave(&vhci->lock, flags);
if (!HCD_HW_ACCESSIBLE(hcd))
@@ -1428,8 +1424,6 @@ static int vhci_hcd_suspend(struct platform_device *pdev, pm_message_t state)
int ret = 0;
unsigned long flags;
- dev_dbg(&pdev->dev, "%s\n", __func__);
-
hcd = platform_get_drvdata(pdev);
if (!hcd)
return 0;
@@ -1467,8 +1461,6 @@ static int vhci_hcd_resume(struct platform_device *pdev)
{
struct usb_hcd *hcd;
- dev_dbg(&pdev->dev, "%s\n", __func__);
-
hcd = platform_get_drvdata(pdev);
if (!hcd)
return 0;
--
2.51.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 14/17] usb: vhci-hcd: Consistently use __func__
2025-09-02 11:56 [PATCH 00/17] USB/IP VHCI driver cleanup Cristian Ciocaltea
` (12 preceding siblings ...)
2025-09-02 11:56 ` [PATCH 13/17] usb: vhci-hcd: Remove ftrace-like logging Cristian Ciocaltea
@ 2025-09-02 11:56 ` Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 15/17] usb: vhci-hcd: Do not split quoted strings Cristian Ciocaltea
` (2 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-09-02 11:56 UTC (permalink / raw)
To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman
Cc: kernel, linux-usb, linux-kernel
Replace all explicit function names in string literals with __func__ and
silent several checkpatch complaints similar to the following one:
WARNING: Prefer using '"%s...", __func__' to using 'vhci_start', this function's name, in a string
In case of the usbip_dbg_*() helpers, which are wrappers over
pr_debug(), the function names end up duplicated, hence replace the
superfluous strings with some useful info or simply drop the log entries
altogether if they become ftrace-like.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/usb/usbip/vhci_hcd.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index a71a542e6eec42c79cff091fe0168f44c8c9b4b2..c790e3a435e2b1493c1ed88d3a98edb7c2e35912 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -160,8 +160,6 @@ void rh_port_connect(struct vhci_device *vdev, enum usb_device_speed speed)
u32 status;
unsigned long flags;
- usbip_dbg_vhci_rh("rh_port_connect %d\n", rhport);
-
spin_lock_irqsave(&vhci->lock, flags);
status = vhci_hcd->port_status[rhport];
@@ -183,6 +181,8 @@ void rh_port_connect(struct vhci_device *vdev, enum usb_device_speed speed)
spin_unlock_irqrestore(&vhci->lock, flags);
+ usbip_dbg_vhci_rh("rhport: %d status: %u\n", rhport, status);
+
usb_hcd_poll_rh_status(vhci_hcd_to_hcd(vhci_hcd));
}
@@ -194,8 +194,6 @@ static void rh_port_disconnect(struct vhci_device *vdev)
u32 status;
unsigned long flags;
- usbip_dbg_vhci_rh("rh_port_disconnect %d\n", rhport);
-
spin_lock_irqsave(&vhci->lock, flags);
status = vhci_hcd->port_status[rhport];
@@ -206,6 +204,9 @@ static void rh_port_disconnect(struct vhci_device *vdev)
vhci_hcd->port_status[rhport] = status;
spin_unlock_irqrestore(&vhci->lock, flags);
+
+ usbip_dbg_vhci_rh("rhport: %d status: %u\n", rhport, status);
+
usb_hcd_poll_rh_status(vhci_hcd_to_hcd(vhci_hcd));
}
@@ -1173,8 +1174,6 @@ static int vhci_start(struct usb_hcd *hcd)
int id, rhport;
int err;
- usbip_dbg_vhci_hc("enter vhci_start\n");
-
if (usb_hcd_is_primary_hcd(hcd))
spin_lock_init(&vhci_hcd->vhci->lock);
@@ -1296,7 +1295,7 @@ static int vhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev,
struct usb_host_endpoint **eps, unsigned int num_eps,
unsigned int num_streams, gfp_t mem_flags)
{
- dev_dbg(&hcd->self.root_hub->dev, "vhci_alloc_streams not implemented\n");
+ dev_dbg(&hcd->self.root_hub->dev, "%s not implemented\n", __func__);
return 0;
}
@@ -1305,7 +1304,7 @@ static int vhci_free_streams(struct usb_hcd *hcd, struct usb_device *udev,
struct usb_host_endpoint **eps, unsigned int num_eps,
gfp_t mem_flags)
{
- dev_dbg(&hcd->self.root_hub->dev, "vhci_free_streams not implemented\n");
+ dev_dbg(&hcd->self.root_hub->dev, "%s not implemented\n", __func__);
return 0;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 15/17] usb: vhci-hcd: Do not split quoted strings
2025-09-02 11:56 [PATCH 00/17] USB/IP VHCI driver cleanup Cristian Ciocaltea
` (13 preceding siblings ...)
2025-09-02 11:56 ` [PATCH 14/17] usb: vhci-hcd: Consistently use __func__ Cristian Ciocaltea
@ 2025-09-02 11:56 ` Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 16/17] usb: vhci-hcd: Switch to dev_err_probe() in probe path Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 17/17] usb: vhci-hcd: Replace pr_*() with dev_*() logging Cristian Ciocaltea
16 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-09-02 11:56 UTC (permalink / raw)
To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman
Cc: kernel, linux-usb, linux-kernel
Join the split strings to make checkpatch happy and regain ability to
grep for those log messages in the source code:
WARNING: quoted string split across lines
While at it, replace the affected pr_err() calls with dev_err().
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/usb/usbip/vhci_hcd.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index c790e3a435e2b1493c1ed88d3a98edb7c2e35912..9e88fe6424f723709c07e91df21481ae91c1f1b5 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -377,8 +377,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
switch (wValue) {
case USB_PORT_FEAT_SUSPEND:
if (hcd->speed >= HCD_USB3) {
- pr_err(" ClearPortFeature: USB_PORT_FEAT_SUSPEND req not "
- "supported for USB 3.0 roothub\n");
+ dev_err(hcd_dev(hcd),
+ "ClearPortFeature: USB_PORT_FEAT_SUSPEND req not supported for USB 3.0 roothub\n");
goto error;
}
@@ -507,8 +507,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
case USB_PORT_FEAT_LINK_STATE:
usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_LINK_STATE\n");
if (hcd->speed < HCD_USB3) {
- pr_err("USB_PORT_FEAT_LINK_STATE req not "
- "supported for USB 2.0 roothub\n");
+ dev_err(hcd_dev(hcd),
+ "USB_PORT_FEAT_LINK_STATE req not supported for USB 2.0 roothub\n");
goto error;
}
@@ -524,8 +524,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_U2_TIMEOUT\n");
/* TODO: add suspend/resume support! */
if (hcd->speed < HCD_USB3) {
- pr_err("USB_PORT_FEAT_U1/2_TIMEOUT req not "
- "supported for USB 2.0 roothub\n");
+ dev_err(hcd_dev(hcd),
+ "USB_PORT_FEAT_U1/2_TIMEOUT req not supported for USB 2.0 roothub\n");
goto error;
}
break;
@@ -533,8 +533,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_SUSPEND\n");
/* Applicable only for USB2.0 hub */
if (hcd->speed >= HCD_USB3) {
- pr_err("USB_PORT_FEAT_SUSPEND req not "
- "supported for USB 3.0 roothub\n");
+ dev_err(hcd_dev(hcd),
+ "USB_PORT_FEAT_SUSPEND req not supported for USB 3.0 roothub\n");
goto error;
}
@@ -566,8 +566,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
/* Applicable only for USB3.0 hub */
if (hcd->speed < HCD_USB3) {
- pr_err("USB_PORT_FEAT_BH_PORT_RESET req not "
- "supported for USB 2.0 roothub\n");
+ dev_err(hcd_dev(hcd),
+ "USB_PORT_FEAT_BH_PORT_RESET req not supported for USB 2.0 roothub\n");
goto error;
}
fallthrough;
@@ -621,8 +621,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
case GetPortErrorCount:
usbip_dbg_vhci_rh(" GetPortErrorCount\n");
if (hcd->speed < HCD_USB3) {
- pr_err("GetPortErrorCount req not "
- "supported for USB 2.0 roothub\n");
+ dev_err(hcd_dev(hcd),
+ "GetPortErrorCount req not supported for USB 2.0 roothub\n");
goto error;
}
/* We'll always return 0 since this is a dummy hub */
@@ -631,8 +631,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
case SetHubDepth:
usbip_dbg_vhci_rh(" SetHubDepth\n");
if (hcd->speed < HCD_USB3) {
- pr_err("SetHubDepth req not supported for "
- "USB 2.0 roothub\n");
+ dev_err(hcd_dev(hcd),
+ "SetHubDepth req not supported for USB 2.0 roothub\n");
goto error;
}
break;
--
2.51.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 16/17] usb: vhci-hcd: Switch to dev_err_probe() in probe path
2025-09-02 11:56 [PATCH 00/17] USB/IP VHCI driver cleanup Cristian Ciocaltea
` (14 preceding siblings ...)
2025-09-02 11:56 ` [PATCH 15/17] usb: vhci-hcd: Do not split quoted strings Cristian Ciocaltea
@ 2025-09-02 11:56 ` Cristian Ciocaltea
2025-09-02 11:56 ` [PATCH 17/17] usb: vhci-hcd: Replace pr_*() with dev_*() logging Cristian Ciocaltea
16 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-09-02 11:56 UTC (permalink / raw)
To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman
Cc: kernel, linux-usb, linux-kernel
Replace pr_err() calls in vhci_hcd_probe() with dev_err_probe(), to
simplify error handling a bit and improve consistency.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/usb/usbip/vhci_hcd.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 9e88fe6424f723709c07e91df21481ae91c1f1b5..8304df3dc94c415bea5252dc0044611f4c862ba5 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -1347,10 +1347,8 @@ static int vhci_hcd_probe(struct platform_device *pdev)
* Our private data is also allocated automatically.
*/
hcd_hs = usb_create_hcd(&vhci_hc_driver, &pdev->dev, dev_name(&pdev->dev));
- if (!hcd_hs) {
- pr_err("create primary hcd failed\n");
- return -ENOMEM;
- }
+ if (!hcd_hs)
+ return dev_err_probe(&pdev->dev, -ENOMEM, "create primary hcd failed\n");
hcd_hs->has_tt = 1;
@@ -1359,22 +1357,21 @@ static int vhci_hcd_probe(struct platform_device *pdev)
* Call the driver's reset() and start() routines.
*/
ret = usb_add_hcd(hcd_hs, 0, 0);
- if (ret != 0) {
- pr_err("usb_add_hcd hs failed %d\n", ret);
+ if (ret) {
+ dev_err_probe(&pdev->dev, ret, "usb_add_hcd hs failed\n");
goto put_usb2_hcd;
}
hcd_ss = usb_create_shared_hcd(&vhci_hc_driver, &pdev->dev,
dev_name(&pdev->dev), hcd_hs);
if (!hcd_ss) {
- ret = -ENOMEM;
- pr_err("create shared hcd failed\n");
+ ret = dev_err_probe(&pdev->dev, -ENOMEM, "create shared hcd failed\n");
goto remove_usb2_hcd;
}
ret = usb_add_hcd(hcd_ss, 0, 0);
if (ret) {
- pr_err("usb_add_hcd ss failed %d\n", ret);
+ dev_err_probe(&pdev->dev, ret, "usb_add_hcd ss failed\n");
goto put_usb3_hcd;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 17/17] usb: vhci-hcd: Replace pr_*() with dev_*() logging
2025-09-02 11:56 [PATCH 00/17] USB/IP VHCI driver cleanup Cristian Ciocaltea
` (15 preceding siblings ...)
2025-09-02 11:56 ` [PATCH 16/17] usb: vhci-hcd: Switch to dev_err_probe() in probe path Cristian Ciocaltea
@ 2025-09-02 11:56 ` Cristian Ciocaltea
16 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-09-02 11:56 UTC (permalink / raw)
To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman
Cc: kernel, linux-usb, linux-kernel
Where possible, use driver model logging helpers dev_*() instead of
pr_*() to ensure the messages are always associated with the
corresponding device/driver.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/usb/usbip/vhci_hcd.c | 43 +++++++++++++++++++++++--------------------
1 file changed, 23 insertions(+), 20 deletions(-)
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 8304df3dc94c415bea5252dc0044611f4c862ba5..64fe2f9e22f13b7d0234319521e0a7282c65411a 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -347,7 +347,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
if (wIndex < 1 || wIndex > VHCI_HC_PORTS) {
invalid_rhport = true;
if (wIndex > VHCI_HC_PORTS)
- pr_err("invalid port number %d\n", wIndex);
+ dev_err(hcd_dev(hcd), "invalid port number %d\n", wIndex);
} else {
rhport = wIndex - 1;
}
@@ -370,7 +370,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
break;
case ClearPortFeature:
if (invalid_rhport) {
- pr_err("invalid port number %d\n", wIndex);
+ dev_err(hcd_dev(hcd), "invalid port number %d\n", wIndex);
goto error;
}
@@ -410,7 +410,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
usbip_dbg_vhci_rh(" GetHubDescriptor\n");
if (hcd->speed >= HCD_USB3 &&
(wLength < USB_DT_SS_HUB_SIZE || wValue != (USB_DT_SS_HUB << 8))) {
- pr_err("Wrong hub descriptor type for USB 3.0 roothub.\n");
+ dev_err(hcd_dev(hcd),
+ "Wrong hub descriptor type for USB 3.0 roothub.\n");
goto error;
}
@@ -436,7 +437,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
case GetPortStatus:
usbip_dbg_vhci_rh(" GetPortStatus port %x\n", wIndex);
if (invalid_rhport) {
- pr_err("invalid port number %d\n", wIndex);
+ dev_err(hcd_dev(hcd), "invalid port number %d\n", wIndex);
retval = -EPIPE;
goto error;
}
@@ -485,7 +486,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
USB_PORT_STAT_LOW_SPEED;
break;
default:
- pr_err("vhci_device speed not set\n");
+ dev_err(hcd_dev(hcd), "vhci_device speed not set\n");
break;
}
}
@@ -539,7 +540,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
}
if (invalid_rhport) {
- pr_err("invalid port number %d\n", wIndex);
+ dev_err(hcd_dev(hcd), "invalid port number %d\n", wIndex);
goto error;
}
@@ -548,7 +549,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
case USB_PORT_FEAT_POWER:
usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_POWER\n");
if (invalid_rhport) {
- pr_err("invalid port number %d\n", wIndex);
+ dev_err(hcd_dev(hcd), "invalid port number %d\n", wIndex);
goto error;
}
@@ -560,7 +561,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
case USB_PORT_FEAT_BH_PORT_RESET:
usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_BH_PORT_RESET\n");
if (invalid_rhport) {
- pr_err("invalid port number %d\n", wIndex);
+ dev_err(hcd_dev(hcd), "invalid port number %d\n", wIndex);
goto error;
}
@@ -574,7 +575,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
case USB_PORT_FEAT_RESET:
usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_RESET\n");
if (invalid_rhport) {
- pr_err("invalid port number %d\n", wIndex);
+ dev_err(hcd_dev(hcd), "invalid port number %d\n", wIndex);
goto error;
}
@@ -598,7 +599,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
usbip_dbg_vhci_rh(" SetPortFeature: default %d\n",
wValue);
if (invalid_rhport) {
- pr_err("invalid port number %d\n", wIndex);
+ dev_err(hcd_dev(hcd), "invalid port number %d\n", wIndex);
goto error;
}
@@ -637,7 +638,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
}
break;
default:
- pr_err("default hub control req: %04x v%04x i%04x l%d\n",
+ dev_err(hcd_dev(hcd),
+ "default hub control req: %04x v%04x i%04x l%d\n",
typeReq, wValue, wIndex, wLength);
error:
/* "protocol stall" on error */
@@ -645,7 +647,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
}
if (usbip_dbg_flag_vhci_rh) {
- pr_debug("port %d\n", rhport);
+ dev_dbg(hcd_dev(hcd), "%s port %d\n", __func__, rhport);
/* Only dump valid port status */
if (!invalid_rhport) {
dump_port_status_diff(prev_port_status[rhport],
@@ -705,7 +707,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
unsigned long flags;
if (portnum > VHCI_HC_PORTS) {
- pr_err("invalid port number %d\n", portnum);
+ dev_err(hcd_dev(hcd), "invalid port number %d\n", portnum);
return -ENODEV;
}
vdev = &vhci_hcd->vdev[portnum - 1];
@@ -936,7 +938,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
unlink->seqnum = atomic_inc_return(&vhci_hcd->seqnum);
if (unlink->seqnum == 0xffff)
- pr_info("seqnum max\n");
+ dev_info(hcd_dev(hcd), "seqnum max\n");
unlink->unlink_seqnum = priv->seqnum;
@@ -1013,10 +1015,11 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev)
static void vhci_shutdown_connection(struct usbip_device *ud)
{
struct vhci_device *vdev = container_of(ud, struct vhci_device, ud);
+ struct usb_hcd *hcd = vhci_hcd_to_hcd(vdev_to_vhci_hcd(vdev));
/* need this? see stub_dev.c */
if (ud->tcp_socket) {
- pr_debug("shutdown tcp_socket %d\n", ud->sockfd);
+ dev_dbg(hcd_dev(hcd), "shutdown tcp_socket %d\n", ud->sockfd);
kernel_sock_shutdown(ud->tcp_socket, SHUT_RDWR);
}
@@ -1029,7 +1032,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
kthread_stop_put(vdev->ud.tcp_tx);
vdev->ud.tcp_tx = NULL;
}
- pr_info("stop threads\n");
+ dev_info(hcd_dev(hcd), "stop threads\n");
/* active connection is closed */
if (vdev->ud.tcp_socket) {
@@ -1037,7 +1040,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
vdev->ud.tcp_socket = NULL;
vdev->ud.sockfd = -1;
}
- pr_info("release socket\n");
+ dev_info(hcd_dev(hcd), "release socket\n");
vhci_device_unlink_cleanup(vdev);
@@ -1063,7 +1066,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
*/
rh_port_disconnect(vdev);
- pr_info("disconnect device\n");
+ dev_info(hcd_dev(hcd), "disconnect device\n");
}
static void vhci_device_reset(struct usbip_device *ud)
@@ -1197,7 +1200,7 @@ static int vhci_start(struct usb_hcd *hcd)
id = hcd_name_to_id(hcd_name(hcd));
if (id < 0) {
- pr_err("invalid vhci name %s\n", hcd_name(hcd));
+ dev_err(hcd_dev(hcd), "invalid vhci name %s\n", hcd_name(hcd));
return -EINVAL;
}
@@ -1216,7 +1219,7 @@ static int vhci_start(struct usb_hcd *hcd)
return err;
}
- pr_info("created sysfs %s\n", hcd_name(hcd));
+ dev_info(hcd_dev(hcd), "created sysfs %s\n", hcd_name(hcd));
}
return 0;
--
2.51.0
^ permalink raw reply related [flat|nested] 18+ messages in thread