[PATCH 2/2] USB: hub: Split announce_device() to log device identity before enumeration
From: Nikhil Solanke
Date: Fri Jul 17 2026 - 15:59:19 EST
announce_device() currently logs the device VID:PID and string
descriptors only after successful enumeration. This means that if
enumeration fails, no identifying information about the device appears
in the kernel log, making it difficult to diagnose failures.
Split announce_device() into announce_device_ids(), which logs the
VID:PID and bcdDevice immediately after the device descriptor is read,
and announce_device_strings(), which logs the product, manufacturer,
and serial number strings after successful enumeration. This ensures
that a device's identity is always visible in the log regardless of
whether enumeration succeeds or fails.
Suggested-by: Michal Pecio <michal.pecio@xxxxxxxxx>
Signed-off-by: Nikhil Solanke <nikhilsolanke5@xxxxxxxxx>
---
drivers/usb/core/hub.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 5262e11c12cd..d92bf887739d 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2401,7 +2401,7 @@ static void show_string(struct usb_device *udev, char *id, char *string)
dev_info(&udev->dev, "%s: %s\n", id, string);
}
-static void announce_device(struct usb_device *udev)
+static void announce_device_ids(struct usb_device *udev)
{
u16 bcdDevice = le16_to_cpu(udev->descriptor.bcdDevice);
@@ -2410,6 +2410,10 @@ static void announce_device(struct usb_device *udev)
le16_to_cpu(udev->descriptor.idVendor),
le16_to_cpu(udev->descriptor.idProduct),
bcdDevice >> 8, bcdDevice & 0xff);
+}
+
+static void announce_device_strings(struct usb_device *udev)
+{
dev_info(&udev->dev,
"New USB device strings: Mfr=%d, Product=%d, SerialNumber=%d\n",
udev->descriptor.iManufacturer,
@@ -2420,7 +2424,8 @@ static void announce_device(struct usb_device *udev)
show_string(udev, "SerialNumber", udev->serial);
}
#else
-static inline void announce_device(struct usb_device *udev) { }
+static inline void announce_device_ids(struct usb_device *udev) { }
+static inline void announce_device_strings(struct usb_device *udev) { }
#endif
@@ -2651,6 +2656,9 @@ int usb_new_device(struct usb_device *udev)
device_init_wakeup(&udev->dev, 0);
}
+ /* Announce the device identity */
+ announce_device_ids(udev);
+
/* Tell the runtime-PM framework the device is active */
pm_runtime_set_active(&udev->dev);
pm_runtime_get_noresume(&udev->dev);
@@ -2672,8 +2680,8 @@ int usb_new_device(struct usb_device *udev)
udev->dev.devt = MKDEV(USB_DEVICE_MAJOR,
(((udev->bus->busnum-1) * 128) + (udev->devnum-1)));
- /* Tell the world! */
- announce_device(udev);
+ /* Announce the device's product, manufacturer and serial number */
+ announce_device_strings(udev);
if (udev->serial)
add_device_randomness(udev->serial, strlen(udev->serial));
--
2.55.0