Skip to contentSkip to conversation

USB: hub:no need to obtain usb device

PATCH In review Lizhe 3 participants 3 messages Jun 25, 2024 USB

lore
Share & tools
lore

Lizhe

author
#0 lore raw

PATCH 1/1 USB: hub:no need to obtain usb device

the usb device connected to the port has obtained. there is no need to obtain it again.

---
 drivers/usb/core/hub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/core/hub.c +1 -1
index 4b93c0bd1d4b..f37b991fa86a 100644
@@ -5358,7 +5358,7 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
 	if (udev) {
 		if (hcd->usb_phy && !hdev->parent)
 			usb_phy_notify_disconnect(hcd->usb_phy, udev->speed);
-		usb_disconnect(&port_dev->child);
+		usb_disconnect(&udev);
 	}
 
 	/* We can forget about a "removed" device when there's a physical
Signature · 1 line
2.17.1
#1 lore raw
Quoted 13 lines · Lizhe

the usb device connected to the port has obtained. there is no need to obtain it again.

---
 drivers/usb/core/hub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/core/hub.c +0 -0
index 4b93c0bd1d4b..f37b991fa86a 100644

drivers/usb/core/hub.c static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus, · line 5362

Quoted 6 lines
drivers/usb/core/hub.c +1 -1
@@ -5358,7 +5358,7 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
 	if (udev) {
 		if (hcd->usb_phy && !hdev->parent)
 			usb_phy_notify_disconnect(hcd->usb_phy, udev->speed);
-		usb_disconnect(&port_dev->child);
+		usb_disconnect(&udev);
 	}

This is wrong. We need to pass the address of port_dev->child, not the address of udev. This is so that usb_disconnect() can set port_dev->child to NULL. Setting udev to NULL instead won't work right.

Alan Stern

maintainer
#2 lore raw
In reply to Lizhe
Quoted 13 lines · Lizhe

the usb device connected to the port has obtained. there is no need to obtain it again.

---
 drivers/usb/core/hub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/core/hub.c +0 -0
index 4b93c0bd1d4b..f37b991fa86a 100644

drivers/usb/core/hub.c static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus, · line 5361

Quoted 5 lines
drivers/usb/core/hub.c +1 -1
@@ -5358,7 +5358,7 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
 	if (udev) {
 		if (hcd->usb_phy && !hdev->parent)
 			usb_phy_notify_disconnect(hcd->usb_phy, udev->speed);
-		usb_disconnect(&port_dev->child);
+		usb_disconnect(&udev);

How was this tested?