svn commit: r213675 - in user/weongyo/usb/sys/dev/usb: . controller
Weongyo Jeong
weongyo at FreeBSD.org
Sun Oct 10 21:40:36 UTC 2010
Author: weongyo
Date: Sun Oct 10 21:40:35 2010
New Revision: 213675
URL: http://svn.freebsd.org/changeset/base/213675
Log:
Adds a global linked-list to link all `struct usb_bus' structures. This
would be used to find a USB bus pointer by name that main consumer would
be a implementation like USB transaction monitoring tools (e.g. usbmon
in linux).
Modified:
user/weongyo/usb/sys/dev/usb/controller/usb_controller.c
user/weongyo/usb/sys/dev/usb/usb_bus.h
user/weongyo/usb/sys/dev/usb/usb_controller.h
Modified: user/weongyo/usb/sys/dev/usb/controller/usb_controller.c
==============================================================================
--- user/weongyo/usb/sys/dev/usb/controller/usb_controller.c Sun Oct 10 20:54:01 2010 (r213674)
+++ user/weongyo/usb/sys/dev/usb/controller/usb_controller.c Sun Oct 10 21:40:35 2010 (r213675)
@@ -72,6 +72,8 @@ static void usb_bus_mem_free_all(struct
/* static variables */
+static TAILQ_HEAD(, usb_bus) usb_bus_head;
+
#ifdef USB_DEBUG
static int usb_ctrl_debug = 0;
@@ -540,6 +542,9 @@ usb_bus_struct_init(struct usb_bus *bus,
/* get all DMA memory */
if (usb_bus_mem_alloc_all(bus, USB_GET_DMA_TAG(dev)))
return (ENOMEM);
+
+ TAILQ_INSERT_TAIL(&usb_bus_head, bus, bus_link);
+
return (0);
}
@@ -547,6 +552,31 @@ void
usb_bus_struct_fini(struct usb_bus *bus)
{
+ TAILQ_REMOVE(&usb_bus_head, bus, bus_link);
+
usb_bus_mem_free_all(bus);
mtx_destroy(&bus->bus_mtx);
}
+
+struct usb_bus *
+usb_bus_find(const char *name)
+{
+ struct usb_bus *bus;
+ const char *nameunit;
+
+ TAILQ_FOREACH(bus, &usb_bus_head, bus_link) {
+ nameunit = device_get_nameunit(bus->bdev);
+ if (!strncmp(nameunit, name, strlen(nameunit)))
+ return (bus);
+ }
+ return (NULL);
+}
+
+static void
+usb_bus_first(void *arg)
+{
+
+ TAILQ_INIT(&usb_bus_head);
+}
+
+SYSINIT(usb_bus_first, SI_SUB_KLD, SI_ORDER_FIRST, usb_bus_first, NULL);
Modified: user/weongyo/usb/sys/dev/usb/usb_bus.h
==============================================================================
--- user/weongyo/usb/sys/dev/usb/usb_bus.h Sun Oct 10 20:54:01 2010 (r213674)
+++ user/weongyo/usb/sys/dev/usb/usb_bus.h Sun Oct 10 21:40:35 2010 (r213675)
@@ -103,6 +103,8 @@ struct usb_bus {
struct usb_temp_setup temp_setup[1];
uint8_t data[255];
} scratch[1];
+
+ TAILQ_ENTRY(usb_bus) bus_link;
};
#endif /* _USB_BUS_H_ */
Modified: user/weongyo/usb/sys/dev/usb/usb_controller.h
==============================================================================
--- user/weongyo/usb/sys/dev/usb/usb_controller.h Sun Oct 10 20:54:01 2010 (r213674)
+++ user/weongyo/usb/sys/dev/usb/usb_controller.h Sun Oct 10 21:40:35 2010 (r213675)
@@ -199,6 +199,7 @@ int usb_bus_struct_init(struct usb_bus
void (*busmem_func)(struct usb_bus *,
usb_bus_mem_callback_t *));
void usb_bus_struct_fini(struct usb_bus *bus);
+struct usb_bus *usb_bus_find(const char *name);
void usb_bus_mem_flush_all(struct usb_bus *bus);
uint16_t usb_isoc_time_expand(struct usb_bus *bus,
uint16_t isoc_time_curr);
More information about the svn-src-user
mailing list