aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2007-11-27 01:11:55 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-02-01 17:34:52 -0500
commitf2a383e4de50ad9c03676e57703a97d081798e55 (patch)
treec755110f43b899ba02a554004de87863b1277fab /drivers/usb/core
parent5933101718ea3d283983a923c5524c88138e5564 (diff)
USB: always announce a device has been added to the system
Distros (like SuSE) want to know this information, to make it easier to handle support issues. Might as well let everyone benefit from this. This is also enabled whenever CONFIG_USB_DEBUG is enabled, to help with debugging. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/Kconfig15
-rw-r--r--drivers/usb/core/hub.c36
2 files changed, 39 insertions, 12 deletions
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index 97b09f282705..5c33cdb9cac7 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -9,6 +9,21 @@ config USB_DEBUG
9 of debug messages to the system log. Select this if you are having a 9 of debug messages to the system log. Select this if you are having a
10 problem with USB support and want to see more of what is going on. 10 problem with USB support and want to see more of what is going on.
11 11
12config USB_ANNOUNCE_NEW_DEVICES
13 bool "USB announce new devices"
14 depends on USB
15 default N
16 help
17 Say Y here if you want the USB core to always announce the
18 idVendor, idProduct, Manufacturer, Product, and SerialNumber
19 strings for every new USB device to the syslog. This option is
20 usually used by distro vendors to help with debugging and to
21 let users know what specific device was added to the machine
22 in what location.
23
24 If you do not want this kind of information sent to the system
25 log, or have any doubts about this, say N here.
26
12comment "Miscellaneous USB options" 27comment "Miscellaneous USB options"
13 depends on USB 28 depends on USB
14 29
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 24c411697d1e..f7c2219c800f 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -37,6 +37,13 @@
37#define USB_PERSIST 0 37#define USB_PERSIST 0
38#endif 38#endif
39 39
40/* if we are in debug mode, always announce new devices */
41#ifdef DEBUG
42#ifndef CONFIG_USB_ANNOUNCE_NEW_DEVICES
43#define CONFIG_USB_ANNOUNCE_NEW_DEVICES
44#endif
45#endif
46
40struct usb_hub { 47struct usb_hub {
41 struct device *intfdev; /* the "interface" device */ 48 struct device *intfdev; /* the "interface" device */
42 struct usb_device *hdev; 49 struct usb_device *hdev;
@@ -1207,7 +1214,7 @@ void usb_disconnect(struct usb_device **pdev)
1207 put_device(&udev->dev); 1214 put_device(&udev->dev);
1208} 1215}
1209 1216
1210#ifdef DEBUG 1217#ifdef CONFIG_USB_ANNOUNCE_NEW_DEVICES
1211static void show_string(struct usb_device *udev, char *id, char *string) 1218static void show_string(struct usb_device *udev, char *id, char *string)
1212{ 1219{
1213 if (!string) 1220 if (!string)
@@ -1215,12 +1222,24 @@ static void show_string(struct usb_device *udev, char *id, char *string)
1215 dev_printk(KERN_INFO, &udev->dev, "%s: %s\n", id, string); 1222 dev_printk(KERN_INFO, &udev->dev, "%s: %s\n", id, string);
1216} 1223}
1217 1224
1225static void announce_device(struct usb_device *udev)
1226{
1227 dev_info(&udev->dev, "New USB device found, idVendor=%04x, idProduct=%04x\n",
1228 le16_to_cpu(udev->descriptor.idVendor),
1229 le16_to_cpu(udev->descriptor.idProduct));
1230 dev_info(&udev->dev, "New USB device strings: Mfr=%d, Product=%d, "
1231 "SerialNumber=%d\n",
1232 udev->descriptor.iManufacturer,
1233 udev->descriptor.iProduct,
1234 udev->descriptor.iSerialNumber);
1235 show_string(udev, "Product", udev->product);
1236 show_string(udev, "Manufacturer", udev->manufacturer);
1237 show_string(udev, "SerialNumber", udev->serial);
1238}
1218#else 1239#else
1219static inline void show_string(struct usb_device *udev, char *id, char *string) 1240static inline void announce_device(struct usb_device *udev) { }
1220{}
1221#endif 1241#endif
1222 1242
1223
1224#ifdef CONFIG_USB_OTG 1243#ifdef CONFIG_USB_OTG
1225#include "otg_whitelist.h" 1244#include "otg_whitelist.h"
1226#endif 1245#endif
@@ -1390,14 +1409,7 @@ int usb_new_device(struct usb_device *udev)
1390 } 1409 }
1391 1410
1392 /* Tell the world! */ 1411 /* Tell the world! */
1393 dev_dbg(&udev->dev, "new device strings: Mfr=%d, Product=%d, " 1412 announce_device(udev);
1394 "SerialNumber=%d\n",
1395 udev->descriptor.iManufacturer,
1396 udev->descriptor.iProduct,
1397 udev->descriptor.iSerialNumber);
1398 show_string(udev, "Product", udev->product);
1399 show_string(udev, "Manufacturer", udev->manufacturer);
1400 show_string(udev, "SerialNumber", udev->serial);
1401 return err; 1413 return err;
1402 1414
1403fail: 1415fail: