Commit ff256570 authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

[PATCH] USB: fix osdl bugid 481 (USB boot messages)

Some boot-time messages were obnoxiously long because
they used "old-style" diagnostics.


OSDL bugid 481

Get rid of most remaining "old style" diagnostics from usbcore.
Most messages use driver model style diagnostics.  Messages that
don't have an associated device use the standard kernel printk
wrappers and label themselves as from "usbcore".  (Except that
there's no such wrapper for KERN_ERR.)

This doesn't touch usbfs, "config.c" (Alan's patches do this), or
usb_reset_device() (needs a more substantial overhaul).  Or any
other USB drivers (notably HID).
parent c3d3c472
...@@ -80,7 +80,8 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) ...@@ -80,7 +80,8 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id)
return -ENODEV; return -ENODEV;
if (!dev->irq) { if (!dev->irq) {
err ("Found HC with no IRQ. Check BIOS/PCI %s setup!", dev_err (&dev->dev,
"Found HC with no IRQ. Check BIOS/PCI %s setup!\n",
pci_name(dev)); pci_name(dev));
return -ENODEV; return -ENODEV;
} }
...@@ -90,16 +91,17 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) ...@@ -90,16 +91,17 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id)
resource = pci_resource_start (dev, 0); resource = pci_resource_start (dev, 0);
len = pci_resource_len (dev, 0); len = pci_resource_len (dev, 0);
if (!request_mem_region (resource, len, driver->description)) { if (!request_mem_region (resource, len, driver->description)) {
dbg ("controller already in use"); dev_dbg (&dev->dev, "controller already in use\n");
return -EBUSY; return -EBUSY;
} }
base = ioremap_nocache (resource, len); base = ioremap_nocache (resource, len);
if (base == NULL) { if (base == NULL) {
dbg ("error mapping memory"); dev_dbg (&dev->dev, "error mapping memory\n");
retval = -EFAULT; retval = -EFAULT;
clean_1: clean_1:
release_mem_region (resource, len); release_mem_region (resource, len);
err ("init %s fail, %d", pci_name(dev), retval); dev_err (&dev->dev, "init %s fail, %d\n",
pci_name(dev), retval);
return retval; return retval;
} }
...@@ -116,7 +118,7 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) ...@@ -116,7 +118,7 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id)
break; break;
} }
if (region == PCI_ROM_RESOURCE) { if (region == PCI_ROM_RESOURCE) {
dbg ("no i/o regions available"); dev_dbg (&dev->dev, "no i/o regions available\n");
return -EBUSY; return -EBUSY;
} }
base = (void *) resource; base = (void *) resource;
...@@ -127,7 +129,7 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) ...@@ -127,7 +129,7 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id)
hcd = driver->hcd_alloc (); hcd = driver->hcd_alloc ();
if (hcd == NULL){ if (hcd == NULL){
dbg ("hcd alloc fail"); dev_dbg (&dev->dev, "hcd alloc fail\n");
retval = -ENOMEM; retval = -ENOMEM;
clean_2: clean_2:
if (driver->flags & HCD_MEMORY) { if (driver->flags & HCD_MEMORY) {
...@@ -135,7 +137,8 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) ...@@ -135,7 +137,8 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id)
goto clean_1; goto clean_1;
} else { } else {
release_region (resource, len); release_region (resource, len);
err ("init %s fail, %d", pci_name(dev), retval); dev_err (&dev->dev, "init %s fail, %d\n",
pci_name(dev), retval);
return retval; return retval;
} }
} }
......
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include <linux/usb.h> #include <linux/usb.h>
#include "usb.h"
#include "hcd.h" #include "hcd.h"
...@@ -678,8 +680,10 @@ int usb_register_bus(struct usb_bus *bus) ...@@ -678,8 +680,10 @@ int usb_register_bus(struct usb_bus *bus)
if (busnum < USB_MAXBUS) { if (busnum < USB_MAXBUS) {
set_bit (busnum, busmap.busmap); set_bit (busnum, busmap.busmap);
bus->busnum = busnum; bus->busnum = busnum;
} else } else {
warn ("too many buses"); printk (KERN_ERR "%s: too many buses\n", usbcore_name);
return -E2BIG;
}
snprintf(bus->class_dev.class_id, BUS_ID_SIZE, "usb%d", busnum); snprintf(bus->class_dev.class_id, BUS_ID_SIZE, "usb%d", busnum);
bus->class_dev.class = &usb_host_class; bus->class_dev.class = &usb_host_class;
...@@ -804,7 +808,7 @@ long usb_calc_bus_time (int speed, int is_input, int isoc, int bytecount) ...@@ -804,7 +808,7 @@ long usb_calc_bus_time (int speed, int is_input, int isoc, int bytecount)
tmp = HS_USECS_ISO (bytecount); tmp = HS_USECS_ISO (bytecount);
return tmp; return tmp;
default: default:
dbg ("bogus device speed!"); pr_debug ("%s: bogus device speed!\n", usbcore_name);
return -1; return -1;
} }
} }
......
...@@ -212,8 +212,7 @@ static void hub_tt_kevent (void *arg) ...@@ -212,8 +212,7 @@ static void hub_tt_kevent (void *arg)
spin_lock_irqsave (&hub->tt.lock, flags); spin_lock_irqsave (&hub->tt.lock, flags);
if (status) if (status)
err ("usb-%s-%s clear tt %d (%04x) error %d", dev_err (&dev->dev, "clear tt %d (%04x) error %d\n",
dev->bus->bus_name, dev->devpath,
clear->tt, clear->devinfo, status); clear->tt, clear->devinfo, status);
kfree (clear); kfree (clear);
} }
...@@ -244,8 +243,7 @@ void usb_hub_tt_clear_buffer (struct usb_device *dev, int pipe) ...@@ -244,8 +243,7 @@ void usb_hub_tt_clear_buffer (struct usb_device *dev, int pipe)
* there can be many TTs per hub). even if they're uncommon. * there can be many TTs per hub). even if they're uncommon.
*/ */
if ((clear = kmalloc (sizeof *clear, SLAB_ATOMIC)) == 0) { if ((clear = kmalloc (sizeof *clear, SLAB_ATOMIC)) == 0) {
err ("can't save CLEAR_TT_BUFFER state for hub at usb-%s-%s", dev_err (&dev->dev, "can't save CLEAR_TT_BUFFER state\n");
dev->bus->bus_name, tt->hub->devpath);
/* FIXME recover somehow ... RESET_TT? */ /* FIXME recover somehow ... RESET_TT? */
return; return;
} }
...@@ -596,7 +594,7 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) ...@@ -596,7 +594,7 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
hub = kmalloc(sizeof(*hub), GFP_KERNEL); hub = kmalloc(sizeof(*hub), GFP_KERNEL);
if (!hub) { if (!hub) {
err("couldn't kmalloc hub struct"); dev_dbg (hubdev(dev), "couldn't kmalloc hub struct\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -700,7 +698,7 @@ static void hub_start_disconnect(struct usb_device *dev) ...@@ -700,7 +698,7 @@ static void hub_start_disconnect(struct usb_device *dev)
} }
} }
err("cannot disconnect hub %s", dev->devpath); dev_err(&dev->dev, "cannot disconnect hub!\n");
} }
static int hub_port_status(struct usb_device *dev, int port, static int hub_port_status(struct usb_device *dev, int port,
...@@ -1145,7 +1143,7 @@ static int hub_thread(void *__hub) ...@@ -1145,7 +1143,7 @@ static int hub_thread(void *__hub)
refrigerator(PF_IOTHREAD); refrigerator(PF_IOTHREAD);
} while (!signal_pending(current)); } while (!signal_pending(current));
dbg("hub_thread exiting"); pr_debug ("%s: khubd exiting\n", usbcore_name);
complete_and_exit(&khubd_exited, 0); complete_and_exit(&khubd_exited, 0);
} }
...@@ -1176,7 +1174,8 @@ int usb_hub_init(void) ...@@ -1176,7 +1174,8 @@ int usb_hub_init(void)
pid_t pid; pid_t pid;
if (usb_register(&hub_driver) < 0) { if (usb_register(&hub_driver) < 0) {
err("Unable to register USB hub driver"); printk(KERN_ERR "%s: can't register hub driver\n",
usbcore_name);
return -1; return -1;
} }
...@@ -1189,7 +1188,7 @@ int usb_hub_init(void) ...@@ -1189,7 +1188,7 @@ int usb_hub_init(void)
/* Fall through if kernel_thread failed */ /* Fall through if kernel_thread failed */
usb_deregister(&hub_driver); usb_deregister(&hub_driver);
err("failed to start hub_thread"); printk(KERN_ERR "%s: can't start khubd\n", usbcore_name);
return -1; return -1;
} }
......
...@@ -935,7 +935,8 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) ...@@ -935,7 +935,8 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
iface = usb_ifnum_to_if(dev, interface); iface = usb_ifnum_to_if(dev, interface);
if (!iface) { if (!iface) {
warn("selecting invalid interface %d", interface); dev_dbg(&dev->dev, "selecting invalid interface %d\n",
interface);
return -EINVAL; return -EINVAL;
} }
...@@ -953,8 +954,9 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) ...@@ -953,8 +954,9 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
* request if the interface only has one alternate setting. * request if the interface only has one alternate setting.
*/ */
if (ret == -EPIPE && iface->num_altsetting == 1) { if (ret == -EPIPE && iface->num_altsetting == 1) {
dbg("manual set_interface for dev %d, iface %d, alt %d", dev_dbg(&dev->dev,
dev->devnum, interface, alternate); "manual set_interface for iface %d, alt %d\n",
interface, alternate);
manual = 1; manual = 1;
} else if (ret < 0) } else if (ret < 0)
return ret; return ret;
...@@ -1233,18 +1235,20 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) ...@@ -1233,18 +1235,20 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
if (!dev->have_langid) { if (!dev->have_langid) {
err = usb_get_string(dev, 0, 0, tbuf, 4); err = usb_get_string(dev, 0, 0, tbuf, 4);
if (err < 0) { if (err < 0) {
err("error getting string descriptor 0 (error=%d)", err); dev_err (&dev->dev,
"string descriptor 0 read error: %d\n",
err);
goto errout; goto errout;
} else if (err < 4 || tbuf[0] < 4) { } else if (err < 4 || tbuf[0] < 4) {
err("string descriptor 0 too short"); dev_err (&dev->dev, "string descriptor 0 too short\n");
err = -EINVAL; err = -EINVAL;
goto errout; goto errout;
} else { } else {
dev->have_langid = -1; dev->have_langid = -1;
dev->string_langid = tbuf[2] | (tbuf[3]<< 8); dev->string_langid = tbuf[2] | (tbuf[3]<< 8);
/* always use the first langid listed */ /* always use the first langid listed */
dbg("USB device number %d default language ID 0x%x", dev_dbg (&dev->dev, "default language 0x%04x\n",
dev->devnum, dev->string_langid); dev->string_langid);
} }
} }
......
...@@ -58,6 +58,8 @@ extern int usb_host_init(void); ...@@ -58,6 +58,8 @@ extern int usb_host_init(void);
extern void usb_host_cleanup(void); extern void usb_host_cleanup(void);
const char *usbcore_name = "usbcore";
int nousb; /* Disable USB when built into kernel image */ int nousb; /* Disable USB when built into kernel image */
/* Not honored on modular build */ /* Not honored on modular build */
...@@ -158,11 +160,12 @@ int usb_register(struct usb_driver *new_driver) ...@@ -158,11 +160,12 @@ int usb_register(struct usb_driver *new_driver)
retval = driver_register(&new_driver->driver); retval = driver_register(&new_driver->driver);
if (!retval) { if (!retval) {
info("registered new driver %s", new_driver->name); pr_info("%s: registered new driver %s\n",
usbcore_name, new_driver->name);
usbfs_update_special(); usbfs_update_special();
} else { } else {
err("problem %d when registering driver %s", printk(KERN_ERR "%s: error %d registering driver %s\n",
retval, new_driver->name); usbcore_name, retval, new_driver->name);
} }
return retval; return retval;
...@@ -181,7 +184,7 @@ int usb_register(struct usb_driver *new_driver) ...@@ -181,7 +184,7 @@ int usb_register(struct usb_driver *new_driver)
*/ */
void usb_deregister(struct usb_driver *driver) void usb_deregister(struct usb_driver *driver)
{ {
info("deregistering driver %s", driver->name); pr_info("%s: deregistering driver %s\n", usbcore_name, driver->name);
driver_unregister (&driver->driver); driver_unregister (&driver->driver);
...@@ -587,11 +590,12 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp, ...@@ -587,11 +590,12 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp,
int i = 0; int i = 0;
int length = 0; int length = 0;
dbg ("%s", __FUNCTION__);
if (!dev) if (!dev)
return -ENODEV; return -ENODEV;
/* driver is often null here; dev_dbg() would oops */
pr_debug ("usb %s: hotplug\n", dev->bus_id);
/* Must check driver_data here, as on remove driver is always NULL */ /* Must check driver_data here, as on remove driver is always NULL */
if ((dev->driver == &usb_generic_driver) || if ((dev->driver == &usb_generic_driver) ||
(dev->driver_data == &usb_generic_driver_data)) (dev->driver_data == &usb_generic_driver_data))
...@@ -601,11 +605,11 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp, ...@@ -601,11 +605,11 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp,
usb_dev = interface_to_usbdev (intf); usb_dev = interface_to_usbdev (intf);
if (usb_dev->devnum < 0) { if (usb_dev->devnum < 0) {
dbg ("device already deleted ??"); pr_debug ("usb %s: already deleted?\n", dev->bus_id);
return -ENODEV; return -ENODEV;
} }
if (!usb_dev->bus) { if (!usb_dev->bus) {
dbg ("bus already removed?"); pr_debug ("usb %s: bus removed?\n", dev->bus_id);
return -ENODEV; return -ENODEV;
} }
...@@ -827,14 +831,14 @@ static struct usb_device *match_device(struct usb_device *dev, ...@@ -827,14 +831,14 @@ static struct usb_device *match_device(struct usb_device *dev,
struct usb_device *ret_dev = NULL; struct usb_device *ret_dev = NULL;
int child; int child;
dbg("looking at vendor %d, product %d", dev_dbg(&dev->dev, "check for vendor %04x, product %04x ...\n",
dev->descriptor.idVendor, dev->descriptor.idVendor,
dev->descriptor.idProduct); dev->descriptor.idProduct);
/* see if this device matches */ /* see if this device matches */
if ((dev->descriptor.idVendor == vendor_id) && if ((dev->descriptor.idVendor == vendor_id) &&
(dev->descriptor.idProduct == product_id)) { (dev->descriptor.idProduct == product_id)) {
dbg ("found the device!"); dev_dbg (&dev->dev, "matched this device!\n");
ret_dev = usb_get_dev(dev); ret_dev = usb_get_dev(dev);
goto exit; goto exit;
} }
...@@ -909,7 +913,8 @@ int usb_get_current_frame_number(struct usb_device *dev) ...@@ -909,7 +913,8 @@ int usb_get_current_frame_number(struct usb_device *dev)
* extra field of the interface and endpoint descriptor structs. * extra field of the interface and endpoint descriptor structs.
*/ */
int __usb_get_extra_descriptor(char *buffer, unsigned size, unsigned char type, void **ptr) int __usb_get_extra_descriptor(char *buffer, unsigned size,
unsigned char type, void **ptr)
{ {
struct usb_descriptor_header *header; struct usb_descriptor_header *header;
...@@ -917,7 +922,11 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, unsigned char type, ...@@ -917,7 +922,11 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, unsigned char type,
header = (struct usb_descriptor_header *)buffer; header = (struct usb_descriptor_header *)buffer;
if (header->bLength < 2) { if (header->bLength < 2) {
err("invalid descriptor length of %d", header->bLength); printk(KERN_ERR
"%s: bogus descriptor, type %d length %d\n",
usbcore_name,
header->bDescriptorType,
header->bLength);
return -1; return -1;
} }
...@@ -1568,7 +1577,7 @@ int usb_disabled(void) ...@@ -1568,7 +1577,7 @@ int usb_disabled(void)
static int __init usb_init(void) static int __init usb_init(void)
{ {
if (nousb) { if (nousb) {
info("USB support disabled\n"); pr_info ("%s: USB support disabled\n", usbcore_name);
return 0; return 0;
} }
......
...@@ -17,3 +17,6 @@ extern void usb_enable_interface (struct usb_device *dev, ...@@ -17,3 +17,6 @@ extern void usb_enable_interface (struct usb_device *dev,
extern int usb_get_device_descriptor(struct usb_device *dev, extern int usb_get_device_descriptor(struct usb_device *dev,
unsigned int size); unsigned int size);
/* for labeling diagnostics */
extern const char *usbcore_name;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment