diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2006-08-30 11:27:36 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-27 11:58:56 -0700 |
commit | a6d2bb9ff919b4685bd684620ec7a1ffa8bf2349 (patch) | |
tree | 5bd0cc451d3ce84765c7ec6a60d486d0155b3356 | |
parent | 511366da534bad226e89d294c3b3e910a2aaba6b (diff) |
USB: remove struct usb_operations
All of the currently-supported USB host controller drivers use the HCD
bus-glue framework. As part of the program for flattening out the glue
layer, this patch (as769) removes the usb_operations structure. All
function calls now go directly to the HCD routines (slightly renamed
to remain within the "usb_" namespace).
The patch also removes usb_alloc_bus(), because it's not useful in the
HCD framework and it wasn't referenced anywhere.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/core/hcd.c | 49 | ||||
-rw-r--r-- | drivers/usb/core/hcd.h | 32 | ||||
-rw-r--r-- | drivers/usb/core/message.c | 4 | ||||
-rw-r--r-- | drivers/usb/core/urb.c | 13 | ||||
-rw-r--r-- | drivers/usb/core/usb.c | 10 | ||||
-rw-r--r-- | include/linux/usb.h | 4 |
6 files changed, 24 insertions, 88 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index ea20a3a5a9b..2102c4deec1 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -731,30 +731,6 @@ static void usb_bus_init (struct usb_bus *bus) kref_init(&bus->kref); } -/** - * usb_alloc_bus - creates a new USB host controller structure - * @op: pointer to a struct usb_operations that this bus structure should use - * Context: !in_interrupt() - * - * Creates a USB host controller bus structure with the specified - * usb_operations and initializes all the necessary internal objects. - * - * If no memory is available, NULL is returned. - * - * The caller should call usb_put_bus() when it is finished with the structure. - */ -struct usb_bus *usb_alloc_bus (struct usb_operations *op) -{ - struct usb_bus *bus; - - bus = kzalloc (sizeof *bus, GFP_KERNEL); - if (!bus) - return NULL; - usb_bus_init (bus); - bus->op = op; - return bus; -} - /*-------------------------------------------------------------------------*/ /** @@ -1102,7 +1078,7 @@ static void urb_unlink (struct urb *urb) * expects usb_submit_urb() to have sanity checked and conditioned all * inputs in the urb */ -static int hcd_submit_urb (struct urb *urb, gfp_t mem_flags) +int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags) { int status; struct usb_hcd *hcd = urb->dev->bus->hcpriv; @@ -1211,7 +1187,7 @@ done: /*-------------------------------------------------------------------------*/ /* called in any context */ -static int hcd_get_frame_number (struct usb_device *udev) +int usb_hcd_get_frame_number (struct usb_device *udev) { struct usb_hcd *hcd = (struct usb_hcd *)udev->bus->hcpriv; if (!HC_IS_RUNNING (hcd->state)) @@ -1253,7 +1229,7 @@ unlink1 (struct usb_hcd *hcd, struct urb *urb) * caller guarantees urb won't be recycled till both unlink() * and the urb's completion function return */ -static int hcd_unlink_urb (struct urb *urb, int status) +int usb_hcd_unlink_urb (struct urb *urb, int status) { struct usb_host_endpoint *ep; struct usb_hcd *hcd = NULL; @@ -1351,8 +1327,8 @@ done: * example: a qh stored in ep->hcpriv, holding state related to endpoint * type, maxpacket size, toggle, halt status, and scheduling. */ -static void -hcd_endpoint_disable (struct usb_device *udev, struct usb_host_endpoint *ep) +void usb_hcd_endpoint_disable (struct usb_device *udev, + struct usb_host_endpoint *ep) { struct usb_hcd *hcd; struct urb *urb; @@ -1589,20 +1565,6 @@ EXPORT_SYMBOL (usb_bus_start_enum); /*-------------------------------------------------------------------------*/ -/* - * usb_hcd_operations - adapts usb_bus framework to HCD framework (bus glue) - */ -static struct usb_operations usb_hcd_operations = { - .get_frame_number = hcd_get_frame_number, - .submit_urb = hcd_submit_urb, - .unlink_urb = hcd_unlink_urb, - .buffer_alloc = hcd_buffer_alloc, - .buffer_free = hcd_buffer_free, - .disable = hcd_endpoint_disable, -}; - -/*-------------------------------------------------------------------------*/ - /** * usb_hcd_giveback_urb - return URB from HCD to device driver * @hcd: host controller returning the URB @@ -1744,7 +1706,6 @@ struct usb_hcd *usb_create_hcd (const struct hc_driver *driver, dev_set_drvdata(dev, hcd); usb_bus_init(&hcd->self); - hcd->self.op = &usb_hcd_operations; hcd->self.hcpriv = hcd; hcd->self.release = &hcd_release; hcd->self.controller = dev; diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index fc71a08a1af..83e22991479 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h @@ -139,28 +139,6 @@ struct hcd_timeout { /* timeouts we allocate */ /*-------------------------------------------------------------------------*/ -/* - * FIXME usb_operations should vanish or become hc_driver, - * when usb_bus and usb_hcd become the same thing. - */ - -struct usb_operations { - int (*get_frame_number) (struct usb_device *usb_dev); - int (*submit_urb) (struct urb *urb, gfp_t mem_flags); - int (*unlink_urb) (struct urb *urb, int status); - - /* allocate dma-consistent buffer for URB_DMA_NOMAPPING */ - void *(*buffer_alloc)(struct usb_bus *bus, size_t size, - gfp_t mem_flags, - dma_addr_t *dma); - void (*buffer_free)(struct usb_bus *bus, size_t size, - void *addr, dma_addr_t dma); - - void (*disable)(struct usb_device *udev, - struct usb_host_endpoint *ep); -}; - -/* each driver provides one of these, and hardware init support */ struct pt_regs; @@ -222,7 +200,13 @@ struct hc_driver { /* Needed only if port-change IRQs are level-triggered */ }; -extern void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb, struct pt_regs *regs); +extern int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags); +extern int usb_hcd_unlink_urb (struct urb *urb, int status); +extern void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb, + struct pt_regs *regs); +extern void usb_hcd_endpoint_disable (struct usb_device *udev, + struct usb_host_endpoint *ep); +extern int usb_hcd_get_frame_number (struct usb_device *udev); extern struct usb_hcd *usb_create_hcd (const struct hc_driver *driver, struct device *dev, char *bus_name); @@ -361,8 +345,6 @@ extern long usb_calc_bus_time (int speed, int is_input, /*-------------------------------------------------------------------------*/ -extern struct usb_bus *usb_alloc_bus (struct usb_operations *); - extern void usb_set_device_state(struct usb_device *udev, enum usb_device_state new_state); diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 333b22c68aa..1580c81a0db 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -984,8 +984,8 @@ void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr) ep = dev->ep_in[epnum]; dev->ep_in[epnum] = NULL; } - if (ep && dev->bus && dev->bus->op && dev->bus->op->disable) - dev->bus->op->disable(dev, ep); + if (ep && dev->bus) + usb_hcd_endpoint_disable(dev, ep); } /** diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index 9864988377c..576919927f5 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c @@ -221,7 +221,6 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) { int pipe, temp, max; struct usb_device *dev; - struct usb_operations *op; int is_out; if (!urb || urb->hcpriv || !urb->complete) @@ -233,8 +232,6 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) if (dev->bus->controller->power.power_state.event != PM_EVENT_ON || dev->state == USB_STATE_SUSPENDED) return -EHOSTUNREACH; - if (!(op = dev->bus->op) || !op->submit_urb) - return -ENODEV; urb->status = -EINPROGRESS; urb->actual_length = 0; @@ -376,7 +373,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) urb->interval = temp; } - return op->submit_urb (urb, mem_flags); + return usb_hcd_submit_urb (urb, mem_flags); } /*-------------------------------------------------------------------*/ @@ -440,9 +437,9 @@ int usb_unlink_urb(struct urb *urb) { if (!urb) return -EINVAL; - if (!(urb->dev && urb->dev->bus && urb->dev->bus->op)) + if (!(urb->dev && urb->dev->bus)) return -ENODEV; - return urb->dev->bus->op->unlink_urb(urb, -ECONNRESET); + return usb_hcd_unlink_urb(urb, -ECONNRESET); } /** @@ -468,13 +465,13 @@ int usb_unlink_urb(struct urb *urb) void usb_kill_urb(struct urb *urb) { might_sleep(); - if (!(urb && urb->dev && urb->dev->bus && urb->dev->bus->op)) + if (!(urb && urb->dev && urb->dev->bus)) return; spin_lock_irq(&urb->lock); ++urb->reject; spin_unlock_irq(&urb->lock); - urb->dev->bus->op->unlink_urb(urb, -ENOENT); + usb_hcd_unlink_urb(urb, -ENOENT); wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); spin_lock_irq(&urb->lock); diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 4eb98eb3804..7ab9d29215f 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -480,7 +480,7 @@ exit: */ int usb_get_current_frame_number(struct usb_device *dev) { - return dev->bus->op->get_frame_number (dev); + return usb_hcd_get_frame_number (dev); } /** @@ -677,9 +677,9 @@ void *usb_buffer_alloc ( dma_addr_t *dma ) { - if (!dev || !dev->bus || !dev->bus->op || !dev->bus->op->buffer_alloc) + if (!dev || !dev->bus) return NULL; - return dev->bus->op->buffer_alloc (dev->bus, size, mem_flags, dma); + return hcd_buffer_alloc (dev->bus, size, mem_flags, dma); } /** @@ -700,11 +700,11 @@ void usb_buffer_free ( dma_addr_t dma ) { - if (!dev || !dev->bus || !dev->bus->op || !dev->bus->op->buffer_free) + if (!dev || !dev->bus) return; if (!addr) return; - dev->bus->op->buffer_free (dev->bus, size, addr, dma); + hcd_buffer_free (dev->bus, size, addr, dma); } /** diff --git a/include/linux/usb.h b/include/linux/usb.h index f104efa04d7..4709033f8fa 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -257,8 +257,6 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, /* ----------------------------------------------------------------------- */ -struct usb_operations; - /* USB device number allocation bitmap */ struct usb_devmap { unsigned long devicemap[128 / (8*sizeof(unsigned long))]; @@ -279,7 +277,6 @@ struct usb_bus { * round-robin allocation */ struct usb_devmap devmap; /* device address allocation map */ - struct usb_operations *op; /* Operations (specific to the HC) */ struct usb_device *root_hub; /* Root hub */ struct list_head bus_list; /* list of busses */ void *hcpriv; /* Host Controller private data */ @@ -1051,7 +1048,6 @@ extern int usb_submit_urb(struct urb *urb, gfp_t mem_flags); extern int usb_unlink_urb(struct urb *urb); extern void usb_kill_urb(struct urb *urb); -#define HAVE_USB_BUFFERS void *usb_buffer_alloc (struct usb_device *dev, size_t size, gfp_t mem_flags, dma_addr_t *dma); void usb_buffer_free (struct usb_device *dev, size_t size, |