patch-2.3.38 linux/drivers/usb/hub.c
Next file: linux/drivers/usb/joydev.c
Previous file: linux/drivers/usb/hid.c
Back to the patch index
Back to the overall index
- Lines: 273
- Date:
Fri Jan 7 11:40:24 2000
- Orig file:
v2.3.37/linux/drivers/usb/hub.c
- Orig date:
Wed Dec 29 13:13:19 1999
diff -u --recursive --new-file v2.3.37/linux/drivers/usb/hub.c linux/drivers/usb/hub.c
@@ -13,11 +13,12 @@
#include <linux/list.h>
#include <linux/malloc.h>
#include <linux/smp_lock.h>
-//#include <linux/spinlock.h>
#include <asm/uaccess.h>
#include <asm/byteorder.h>
+#define DEBUG
+
#include "usb.h"
#include "hub.h"
@@ -47,11 +48,13 @@
USB_DT_HUB << 8, 0, data, size, HZ);
}
+#if 0
static int usb_clear_hub_feature(struct usb_device *dev, int feature)
{
return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
USB_REQ_CLEAR_FEATURE, USB_RT_HUB, feature, 0 , NULL, 0, HZ);
}
+#endif
static int usb_clear_port_feature(struct usb_device *dev, int port, int feature)
{
@@ -137,48 +140,44 @@
descriptor = (struct usb_hub_descriptor *)bitmap;
hub->nports = dev->maxchild = descriptor->bNbrPorts;
- printk(KERN_INFO "hub: %d port%s detected\n", hub->nports,
- (hub->nports == 1) ? "" : "s");
+ info("%d port%s detected", hub->nports, (hub->nports == 1) ? "" : "s");
switch (descriptor->wHubCharacteristics & HUB_CHAR_LPSM) {
case 0x00:
- printk(KERN_INFO "hub: ganged power switching\n");
+ dbg("ganged power switching");
break;
case 0x01:
- printk(KERN_INFO "hub: individual port power switching\n");
+ dbg("individual port power switching");
break;
case 0x02:
case 0x03:
- printk(KERN_INFO "hub: unknown reserved power switching mode\n");
+ dbg("unknown reserved power switching mode");
break;
}
if (descriptor->wHubCharacteristics & HUB_CHAR_COMPOUND)
- printk(KERN_INFO "hub: part of a compound device\n");
+ dbg("part of a compound device");
else
- printk(KERN_INFO "hub: standalone hub\n");
+ dbg("standalone hub");
switch (descriptor->wHubCharacteristics & HUB_CHAR_OCPM) {
case 0x00:
- printk(KERN_INFO "hub: global over-current protection\n");
+ dbg("global over-current protection");
break;
case 0x08:
- printk(KERN_INFO "hub: individual port over-current protection\n");
+ dbg("individual port over-current protection");
break;
case 0x10:
case 0x18:
- printk(KERN_INFO "hub: no over-current protection\n");
+ dbg("no over-current protection");
break;
}
- printk(KERN_INFO "hub: power on to power good time: %dms\n",
- descriptor->bPwrOn2PwrGood * 2);
-
- printk(KERN_INFO "hub: hub controller current requirement: %dmA\n",
- descriptor->bHubContrCurrent);
+ dbg("power on to power good time: %dms", descriptor->bPwrOn2PwrGood * 2);
+ dbg("hub controller current requirement: %dmA", descriptor->bHubContrCurrent);
for (i = 0; i < dev->maxchild; i++)
- printk(KERN_INFO "hub: port %d is%s removable\n", i + 1,
+ dbg("port %d is%s removable", i + 1,
bitmap[7 + ((i + 1)/8)] & (1 << ((i + 1) % 8))
? " not" : "");
@@ -188,14 +187,14 @@
return -1;
hubsts = (struct usb_hub_status *)buffer;
- printk(KERN_INFO "hub: local power source is %s\n",
+ dbg("local power source is %s",
(le16_to_cpu(hubsts->wHubStatus) & HUB_STATUS_LOCAL_POWER) ? "lost (inactive)" : "good");
- printk(KERN_INFO "hub: %sover-current condition exists\n",
+ dbg("%sover-current condition exists",
(le16_to_cpu(hubsts->wHubStatus) & HUB_STATUS_OVERCURRENT) ? "" : "no ");
/* Enable power to the ports */
- printk(KERN_INFO "hub: enabling power on all ports\n");
+ dbg("enabling power on all ports");
for (i = 0; i < hub->nports; i++)
usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_POWER);
return 0;
@@ -236,10 +235,10 @@
return NULL;
/* We found a hub */
- printk(KERN_INFO "USB hub found\n");
+ info("USB hub found");
if ((hub = kmalloc(sizeof(*hub), GFP_KERNEL)) == NULL) {
- printk(KERN_ERR "couldn't kmalloc hub struct\n");
+ err("couldn't kmalloc hub struct");
return NULL;
}
@@ -260,7 +259,7 @@
hub_irq, endpoint->bInterval,
hub, &hub->irq_handle);
if (ret) {
- printk (KERN_WARNING "hub: usb_request_irq failed (%d)\n", ret);
+ err("usb_request_irq failed (%d)", ret);
/* free hub, but first clean up its list. */
spin_lock_irqsave(&hub_event_lock, flags);
@@ -317,14 +316,14 @@
wait_ms(100);
/* Check status */
if (usb_get_port_status(hub, port + 1, &portsts)<0) {
- printk(KERN_ERR "get_port_status failed\n");
+ err("get_port_status failed");
return;
}
portstatus = le16_to_cpu(portsts.wPortStatus);
portchange = le16_to_cpu(portsts.wPortChange);
- printk("hub.c: portstatus %x, change %x, %s\n",portstatus,portchange,
- (portstatus&(1<<USB_PORT_FEAT_LOWSPEED)?"Low Speed":"High Speed"));
+ dbg("portstatus %x, change %x, %s", portstatus, portchange,
+ portstatus&(1<<USB_PORT_FEAT_LOWSPEED) ? "Low Speed" : "High Speed");
/* If it's not in CONNECT and ENABLE state, we're done */
if ((!(portstatus & USB_PORT_STAT_CONNECTION)) &&
(!(portstatus & USB_PORT_STAT_ENABLE))) {
@@ -345,13 +344,13 @@
wait_ms(200);
if (usb_get_port_status(hub, port + 1, &portsts)<0) {
- printk(KERN_ERR "get_port_status failed\n");
+ err("get_port_status failed");
return;
}
portstatus = le16_to_cpu(portsts.wPortStatus);
portchange = le16_to_cpu(portsts.wPortChange);
- printk("hub.c: portstatus %x, change %x, %s\n",portstatus,portchange,
- (portstatus&(1<<USB_PORT_FEAT_LOWSPEED)?"Low Speed":"High Speed"));
+ dbg("portstatus %x, change %x, %s", portstatus ,portchange,
+ portstatus&(1<<USB_PORT_FEAT_LOWSPEED) ? "Low Speed" : "High Speed");
if ((portstatus&(1<<USB_PORT_FEAT_ENABLE)))
break;
@@ -360,14 +359,14 @@
}
if (tries==MAX_TRIES) {
- printk("hub.c: Can not enable port %i after %i retries, disabling port\n",port+1,MAX_TRIES);
+ err("can not enable port %i after %i retries, disabling port", port+1, MAX_TRIES);
return;
}
/* Allocate a new device struct for it */
usb = usb_alloc_dev(hub, hub->bus);
if (!usb) {
- printk(KERN_ERR "couldn't allocate usb_device\n");
+ err("couldn't allocate usb_device");
return;
}
@@ -381,8 +380,7 @@
/* Run it through the hoops (find a driver, etc) */
if (usb_new_device(usb)) {
/* Woops, disable the port */
- printk(KERN_DEBUG "hub: disabling port %d\n",
- port + 1);
+ dbg("hub: disabling port %d", port + 1);
usb_clear_port_feature(hub, port + 1, USB_PORT_FEAT_ENABLE);
}
}
@@ -423,7 +421,7 @@
unsigned short portstatus, portchange;
if (usb_get_port_status(dev, i + 1, &portsts) < 0) {
- printk(KERN_ERR "get_port_status failed\n");
+ err("get_port_status failed");
continue;
}
@@ -431,35 +429,27 @@
portchange = le16_to_cpu(portsts.wPortChange);
if (portchange & USB_PORT_STAT_C_CONNECTION) {
- printk(KERN_INFO "hub: port %d connection change\n",
- i + 1);
+ dbg("port %d connection change", i + 1);
- usb_clear_port_feature(dev, i + 1,
- USB_PORT_FEAT_C_CONNECTION);
+ usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_C_CONNECTION);
usb_hub_port_connect_change(dev, i);
}
if (portchange & USB_PORT_STAT_C_ENABLE) {
- printk(KERN_INFO "hub: port %d enable change\n",
- i + 1);
- usb_clear_port_feature(dev, i + 1,
- USB_PORT_FEAT_C_ENABLE);
+ dbg("port %d enable change", i + 1);
+ usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_C_ENABLE);
}
if (portchange & USB_PORT_STAT_C_SUSPEND)
- printk(KERN_INFO "hub: port %d suspend change\n",
- i + 1);
+ dbg("port %d suspend change", i + 1);
if (portchange & USB_PORT_STAT_C_OVERCURRENT)
- printk(KERN_INFO "hub: port %d over-current change\n",
- i + 1);
+ dbg("port %d over-current change", i + 1);
if (portchange & USB_PORT_STAT_C_RESET) {
- printk(KERN_INFO "hub: port %d reset change\n",
- i + 1);
- usb_clear_port_feature(dev, i + 1,
- USB_PORT_FEAT_C_RESET);
+ dbg("port %d reset change", i + 1);
+ usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_C_RESET);
}
} /* end for i */
} /* end while (1) */
@@ -482,9 +472,7 @@
* This thread doesn't need any user-level access,
* so get rid of all our resources
*/
- exit_mm(current);
- exit_files(current);
- exit_fs(current);
+ daemonize();
/* Setup a nice name */
strcpy(current->comm, "khubd");
@@ -499,7 +487,7 @@
MOD_DEC_USE_COUNT;
*/
- printk("usb_hub_thread exiting\n");
+ dbg("usb_hub_thread exiting");
khubd_running = 0;
return 0;
@@ -552,7 +540,7 @@
}
if (!count)
- printk(KERN_ERR "hub: giving up on killing khubd\n");
+ err("giving up on killing khubd");
}
/*
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)