summaryrefslogtreecommitdiffstats
path: root/usr.sbin/usbd
diff options
context:
space:
mode:
authorjoe <joe@FreeBSD.org>2002-01-28 01:03:19 +0000
committerjoe <joe@FreeBSD.org>2002-01-28 01:03:19 +0000
commit3311f87be611f7f1570cc4b728eeadceb9169eec (patch)
treec7820152b3d171d7820a328b8adc34c87a71de86 /usr.sbin/usbd
parentdf86bfa3eb425548b26d69e069bc8e2d80e9e5c9 (diff)
downloadFreeBSD-src-3311f87be611f7f1570cc4b728eeadceb9169eec.zip
FreeBSD-src-3311f87be611f7f1570cc4b728eeadceb9169eec.tar.gz
Merge from NetBSD.
uhub.c: revision 1.37 usb.4: revision 1.30 usb.c: revision 1.38 usb.h: revision 1.40 usb_port.h: revision 1.21 usb_subr.c: revision 1.65 usbdi.h: revision 1.40 Split the attach/detach events up into device, driver and controller attach and detach events. The commit message from NetBSD was: date: 2000/02/02 07:34:00; author: augustss; state: Exp; Change the USB event mechanism to include more information about devices and drivers. Partly from FreeBSD. Also rework usbd to take these new event types into account.
Diffstat (limited to 'usr.sbin/usbd')
-rw-r--r--usr.sbin/usbd/usbd.c77
1 files changed, 56 insertions, 21 deletions
diff --git a/usr.sbin/usbd/usbd.c b/usr.sbin/usbd/usbd.c
index 967a80b..ff5387d 100644
--- a/usr.sbin/usbd/usbd.c
+++ b/usr.sbin/usbd/usbd.c
@@ -109,8 +109,12 @@ typedef struct event_name_s {
} event_name_t;
event_name_t event_names[] = {
- {USB_EVENT_CTRLR_ATTACH, "attach"},
- {USB_EVENT_CTRLR_DETACH, "detach"},
+ {USB_EVENT_CTRLR_ATTACH, "ctrlr-attach"},
+ {USB_EVENT_CTRLR_DETACH, "ctrlr-detach"},
+ {USB_EVENT_DRIVER_ATTACH, "driver-attach"},
+ {USB_EVENT_DRIVER_DETACH, "driver-detach"},
+ {USB_EVENT_DEVICE_ATTACH, "device-attach"},
+ {USB_EVENT_DEVICE_DETACH, "device-detach"},
{0, NULL} /* NULL indicates end of list, not 0 */
};
@@ -572,28 +576,42 @@ print_event(struct usb_event *event)
if (event_names[i].name == NULL)
printf("unknown event %d", event->ue_type);
- printf(" at %ld.%09ld, %s, %s:\n",
- timespec->tv_sec, timespec->tv_nsec,
- devinfo->product, devinfo->vendor);
+ if (event->ue_type == USB_EVENT_DEVICE_ATTACH ||
+ event->ue_type == USB_EVENT_DEVICE_DETACH) {
+ devinfo = &event->u.ue_device;
- printf(" vndr=0x%04x prdct=0x%04x rlse=0x%04x "
- "clss=0x%04x subclss=0x%04x prtcl=0x%04x\n",
- devinfo->vendorNo, devinfo->productNo, devinfo->releaseNo,
- devinfo->class, devinfo->subclass, devinfo->protocol);
+ printf(" at %ld.%09ld, %s, %s:\n",
+ timespec->tv_sec, timespec->tv_nsec,
+ devinfo->product, devinfo->vendor);
- if (devinfo->devnames[0][0] != '\0') {
- char c = ' ';
+ printf(" vndr=0x%04x prdct=0x%04x rlse=0x%04x "
+ "clss=0x%04x subclss=0x%04x prtcl=0x%04x\n",
+ devinfo->vendorNo, devinfo->productNo,
+ devinfo->releaseNo,
+ devinfo->class, devinfo->subclass, devinfo->protocol);
- printf(" device names:");
- for (i = 0; i < USB_MAX_DEVNAMES; i++) {
- if (devinfo->devnames[i][0] == '\0')
- break;
+ if (devinfo->devnames[0][0] != '\0') {
+ char c = ' ';
+
+ printf(" device names:");
+ for (i = 0; i < USB_MAX_DEVNAMES; i++) {
+ if (devinfo->devnames[i][0] == '\0')
+ break;
- printf("%c%s", c, devinfo->devnames[i]);
- c = ',';
+ printf("%c%s", c, devinfo->devnames[i]);
+ c = ',';
+ }
}
- printf("\n");
+ } else if (event->ue_type == USB_EVENT_CTRLR_ATTACH ||
+ event->ue_type == USB_EVENT_CTRLR_DETACH) {
+ printf(" bus=%d", &event->u.ue_ctrlr.ue_bus);
+ } else if (event->ue_type == USB_EVENT_DRIVER_ATTACH ||
+ event->ue_type == USB_EVENT_DRIVER_DETACH) {
+ printf(" cookie=%u devname=%s",
+ &event->u.ue_driver.ue_cookie.cookie,
+ &event->u.ue_driver.ue_devname);
}
+ printf("\n");
}
void
@@ -854,7 +872,15 @@ process_event_queue(int fd)
/* handle the event appropriately */
switch (event.ue_type) {
case USB_EVENT_CTRLR_ATTACH:
+ if (verbose)
+ printf("USB_EVENT_CTRLR_ATTACH\n");
+ break;
case USB_EVENT_CTRLR_DETACH:
+ if (verbose)
+ printf("USB_EVENT_CTRLR_DETACH\n");
+ break;
+ case USB_EVENT_DEVICE_ATTACH:
+ case USB_EVENT_DEVICE_DETACH:
if (find_action(&event.u.ue_device, &action_match) == 0)
/* nothing found */
break;
@@ -873,11 +899,20 @@ process_event_queue(int fd)
__progname, action_match.devname, strerror(errno));
}
- if (event.ue_type == USB_EVENT_CTRLR_ATTACH && action_match.action->attach)
+ if (USB_EVENT_IS_ATTACH(event.ue_type) &&
+ action_match.action->attach)
execute_command(action_match.action->attach);
- if (event.ue_type == USB_EVENT_CTRLR_DETACH && action_match.action->detach)
+ if (USB_EVENT_IS_DETACH(event.ue_type) &&
+ action_match.action->detach)
execute_command(action_match.action->detach);
-
+ break;
+ case USB_EVENT_DRIVER_ATTACH:
+ if (verbose)
+ printf("USB_EVENT_DRIVER_DETACH\n");
+ break;
+ case USB_EVENT_DRIVER_DETACH:
+ if (verbose)
+ printf("USB_EVENT_DRIVER_DETACH\n");
break;
default:
printf("Unknown USB event %d\n", event.ue_type);
OpenPOWER on IntegriCloud