aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2006-08-30 11:27:36 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-09-27 14:58:56 -0400
commita6d2bb9ff919b4685bd684620ec7a1ffa8bf2349 (patch)
tree5bd0cc451d3ce84765c7ec6a60d486d0155b3356 /drivers/usb
parent511366da534bad226e89d294c3b3e910a2aaba6b (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>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/core/hcd.c49
-rw-r--r--drivers/usb/core/hcd.h32
-rw-r--r--drivers/usb/core/message.c4
-rw-r--r--drivers/usb/core/urb.c13
-rw-r--r--drivers/usb/core/usb.c10
5 files changed, 24 insertions, 84 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index ea20a3a5a9b9..2102c4deec1e 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)
731 kref_init(&bus->kref); 731 kref_init(&bus->kref);
732} 732}
733 733
734/**
735 * usb_alloc_bus - creates a new USB host controller structure
736 * @op: pointer to a struct usb_operations that this bus structure should use
737 * Context: !in_interrupt()
738 *
739 * Creates a USB host controller bus structure with the specified
740 * usb_operations and initializes all the necessary internal objects.
741 *
742 * If no memory is available, NULL is returned.
743 *
744 * The caller should call usb_put_bus() when it is finished with the structure.
745 */
746struct usb_bus *usb_alloc_bus (struct usb_operations *op)
747{
748 struct usb_bus *bus;
749
750 bus = kzalloc (sizeof *bus, GFP_KERNEL);
751 if (!bus)
752 return NULL;
753 usb_bus_init (bus);
754 bus->op = op;
755 return bus;
756}
757
758/*-------------------------------------------------------------------------*/ 734/*-------------------------------------------------------------------------*/
759 735
760/** 736/**
@@ -1102,7 +1078,7 @@ static void urb_unlink (struct urb *urb)
1102 * expects usb_submit_urb() to have sanity checked and conditioned all 1078 * expects usb_submit_urb() to have sanity checked and conditioned all
1103 * inputs in the urb 1079 * inputs in the urb
1104 */ 1080 */
1105static int hcd_submit_urb (struct urb *urb, gfp_t mem_flags) 1081int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
1106{ 1082{
1107 int status; 1083 int status;
1108 struct usb_hcd *hcd = urb->dev->bus->hcpriv; 1084 struct usb_hcd *hcd = urb->dev->bus->hcpriv;
@@ -1211,7 +1187,7 @@ done:
1211/*-------------------------------------------------------------------------*/ 1187/*-------------------------------------------------------------------------*/
1212 1188
1213/* called in any context */ 1189/* called in any context */
1214static int hcd_get_frame_number (struct usb_device *udev) 1190int usb_hcd_get_frame_number (struct usb_device *udev)
1215{ 1191{
1216 struct usb_hcd *hcd = (struct usb_hcd *)udev->bus->hcpriv; 1192 struct usb_hcd *hcd = (struct usb_hcd *)udev->bus->hcpriv;
1217 if (!HC_IS_RUNNING (hcd->state)) 1193 if (!HC_IS_RUNNING (hcd->state))
@@ -1253,7 +1229,7 @@ unlink1 (struct usb_hcd *hcd, struct urb *urb)
1253 * caller guarantees urb won't be recycled till both unlink() 1229 * caller guarantees urb won't be recycled till both unlink()
1254 * and the urb's completion function return 1230 * and the urb's completion function return
1255 */ 1231 */
1256static int hcd_unlink_urb (struct urb *urb, int status) 1232int usb_hcd_unlink_urb (struct urb *urb, int status)
1257{ 1233{
1258 struct usb_host_endpoint *ep; 1234 struct usb_host_endpoint *ep;
1259 struct usb_hcd *hcd = NULL; 1235 struct usb_hcd *hcd = NULL;
@@ -1351,8 +1327,8 @@ done:
1351 * example: a qh stored in ep->hcpriv, holding state related to endpoint 1327 * example: a qh stored in ep->hcpriv, holding state related to endpoint
1352 * type, maxpacket size, toggle, halt status, and scheduling. 1328 * type, maxpacket size, toggle, halt status, and scheduling.
1353 */ 1329 */
1354static void 1330void usb_hcd_endpoint_disable (struct usb_device *udev,
1355hcd_endpoint_disable (struct usb_device *udev, struct usb_host_endpoint *ep) 1331 struct usb_host_endpoint *ep)
1356{ 1332{
1357 struct usb_hcd *hcd; 1333 struct usb_hcd *hcd;
1358 struct urb *urb; 1334 struct urb *urb;
@@ -1589,20 +1565,6 @@ EXPORT_SYMBOL (usb_bus_start_enum);
1589 1565
1590/*-------------------------------------------------------------------------*/ 1566/*-------------------------------------------------------------------------*/
1591 1567
1592/*
1593 * usb_hcd_operations - adapts usb_bus framework to HCD framework (bus glue)
1594 */
1595static struct usb_operations usb_hcd_operations = {
1596 .get_frame_number = hcd_get_frame_number,
1597 .submit_urb = hcd_submit_urb,
1598 .unlink_urb = hcd_unlink_urb,
1599 .buffer_alloc = hcd_buffer_alloc,
1600 .buffer_free = hcd_buffer_free,
1601 .disable = hcd_endpoint_disable,
1602};
1603
1604/*-------------------------------------------------------------------------*/
1605
1606/** 1568/**
1607 * usb_hcd_giveback_urb - return URB from HCD to device driver 1569 * usb_hcd_giveback_urb - return URB from HCD to device driver
1608 * @hcd: host controller returning the URB 1570 * @hcd: host controller returning the URB
@@ -1744,7 +1706,6 @@ struct usb_hcd *usb_create_hcd (const struct hc_driver *driver,
1744 dev_set_drvdata(dev, hcd); 1706 dev_set_drvdata(dev, hcd);
1745 1707
1746 usb_bus_init(&hcd->self); 1708 usb_bus_init(&hcd->self);
1747 hcd->self.op = &usb_hcd_operations;
1748 hcd->self.hcpriv = hcd; 1709 hcd->self.hcpriv = hcd;
1749 hcd->self.release = &hcd_release; 1710 hcd->self.release = &hcd_release;
1750 hcd->self.controller = dev; 1711 hcd->self.controller = dev;
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index fc71a08a1af4..83e229914797 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -139,28 +139,6 @@ struct hcd_timeout { /* timeouts we allocate */
139 139
140/*-------------------------------------------------------------------------*/ 140/*-------------------------------------------------------------------------*/
141 141
142/*
143 * FIXME usb_operations should vanish or become hc_driver,
144 * when usb_bus and usb_hcd become the same thing.
145 */
146
147struct usb_operations {
148 int (*get_frame_number) (struct usb_device *usb_dev);
149 int (*submit_urb) (struct urb *urb, gfp_t mem_flags);
150 int (*unlink_urb) (struct urb *urb, int status);
151
152 /* allocate dma-consistent buffer for URB_DMA_NOMAPPING */
153 void *(*buffer_alloc)(struct usb_bus *bus, size_t size,
154 gfp_t mem_flags,
155 dma_addr_t *dma);
156 void (*buffer_free)(struct usb_bus *bus, size_t size,
157 void *addr, dma_addr_t dma);
158
159 void (*disable)(struct usb_device *udev,
160 struct usb_host_endpoint *ep);
161};
162
163/* each driver provides one of these, and hardware init support */
164 142
165struct pt_regs; 143struct pt_regs;
166 144
@@ -222,7 +200,13 @@ struct hc_driver {
222 /* Needed only if port-change IRQs are level-triggered */ 200 /* Needed only if port-change IRQs are level-triggered */
223}; 201};
224 202
225extern void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb, struct pt_regs *regs); 203extern int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags);
204extern int usb_hcd_unlink_urb (struct urb *urb, int status);
205extern void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb,
206 struct pt_regs *regs);
207extern void usb_hcd_endpoint_disable (struct usb_device *udev,
208 struct usb_host_endpoint *ep);
209extern int usb_hcd_get_frame_number (struct usb_device *udev);
226 210
227extern struct usb_hcd *usb_create_hcd (const struct hc_driver *driver, 211extern struct usb_hcd *usb_create_hcd (const struct hc_driver *driver,
228 struct device *dev, char *bus_name); 212 struct device *dev, char *bus_name);
@@ -361,8 +345,6 @@ extern long usb_calc_bus_time (int speed, int is_input,
361 345
362/*-------------------------------------------------------------------------*/ 346/*-------------------------------------------------------------------------*/
363 347
364extern struct usb_bus *usb_alloc_bus (struct usb_operations *);
365
366extern void usb_set_device_state(struct usb_device *udev, 348extern void usb_set_device_state(struct usb_device *udev,
367 enum usb_device_state new_state); 349 enum usb_device_state new_state);
368 350
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 333b22c68aa4..1580c81a0db7 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)
984 ep = dev->ep_in[epnum]; 984 ep = dev->ep_in[epnum];
985 dev->ep_in[epnum] = NULL; 985 dev->ep_in[epnum] = NULL;
986 } 986 }
987 if (ep && dev->bus && dev->bus->op && dev->bus->op->disable) 987 if (ep && dev->bus)
988 dev->bus->op->disable(dev, ep); 988 usb_hcd_endpoint_disable(dev, ep);
989} 989}
990 990
991/** 991/**
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 9864988377c7..576919927f53 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)
221{ 221{
222 int pipe, temp, max; 222 int pipe, temp, max;
223 struct usb_device *dev; 223 struct usb_device *dev;
224 struct usb_operations *op;
225 int is_out; 224 int is_out;
226 225
227 if (!urb || urb->hcpriv || !urb->complete) 226 if (!urb || urb->hcpriv || !urb->complete)
@@ -233,8 +232,6 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
233 if (dev->bus->controller->power.power_state.event != PM_EVENT_ON 232 if (dev->bus->controller->power.power_state.event != PM_EVENT_ON
234 || dev->state == USB_STATE_SUSPENDED) 233 || dev->state == USB_STATE_SUSPENDED)
235 return -EHOSTUNREACH; 234 return -EHOSTUNREACH;
236 if (!(op = dev->bus->op) || !op->submit_urb)
237 return -ENODEV;
238 235
239 urb->status = -EINPROGRESS; 236 urb->status = -EINPROGRESS;
240 urb->actual_length = 0; 237 urb->actual_length = 0;
@@ -376,7 +373,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
376 urb->interval = temp; 373 urb->interval = temp;
377 } 374 }
378 375
379 return op->submit_urb (urb, mem_flags); 376 return usb_hcd_submit_urb (urb, mem_flags);
380} 377}
381 378
382/*-------------------------------------------------------------------*/ 379/*-------------------------------------------------------------------*/
@@ -440,9 +437,9 @@ int usb_unlink_urb(struct urb *urb)
440{ 437{
441 if (!urb) 438 if (!urb)
442 return -EINVAL; 439 return -EINVAL;
443 if (!(urb->dev && urb->dev->bus && urb->dev->bus->op)) 440 if (!(urb->dev && urb->dev->bus))
444 return -ENODEV; 441 return -ENODEV;
445 return urb->dev->bus->op->unlink_urb(urb, -ECONNRESET); 442 return usb_hcd_unlink_urb(urb, -ECONNRESET);
446} 443}
447 444
448/** 445/**
@@ -468,13 +465,13 @@ int usb_unlink_urb(struct urb *urb)
468void usb_kill_urb(struct urb *urb) 465void usb_kill_urb(struct urb *urb)
469{ 466{
470 might_sleep(); 467 might_sleep();
471 if (!(urb && urb->dev && urb->dev->bus && urb->dev->bus->op)) 468 if (!(urb && urb->dev && urb->dev->bus))
472 return; 469 return;
473 spin_lock_irq(&urb->lock); 470 spin_lock_irq(&urb->lock);
474 ++urb->reject; 471 ++urb->reject;
475 spin_unlock_irq(&urb->lock); 472 spin_unlock_irq(&urb->lock);
476 473
477 urb->dev->bus->op->unlink_urb(urb, -ENOENT); 474 usb_hcd_unlink_urb(urb, -ENOENT);
478 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); 475 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0);
479 476
480 spin_lock_irq(&urb->lock); 477 spin_lock_irq(&urb->lock);
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 4eb98eb3804f..7ab9d29215f8 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -480,7 +480,7 @@ exit:
480 */ 480 */
481int usb_get_current_frame_number(struct usb_device *dev) 481int usb_get_current_frame_number(struct usb_device *dev)
482{ 482{
483 return dev->bus->op->get_frame_number (dev); 483 return usb_hcd_get_frame_number (dev);
484} 484}
485 485
486/** 486/**
@@ -677,9 +677,9 @@ void *usb_buffer_alloc (
677 dma_addr_t *dma 677 dma_addr_t *dma
678) 678)
679{ 679{
680 if (!dev || !dev->bus || !dev->bus->op || !dev->bus->op->buffer_alloc) 680 if (!dev || !dev->bus)
681 return NULL; 681 return NULL;
682 return dev->bus->op->buffer_alloc (dev->bus, size, mem_flags, dma); 682 return hcd_buffer_alloc (dev->bus, size, mem_flags, dma);
683} 683}
684 684
685/** 685/**
@@ -700,11 +700,11 @@ void usb_buffer_free (
700 dma_addr_t dma 700 dma_addr_t dma
701) 701)
702{ 702{
703 if (!dev || !dev->bus || !dev->bus->op || !dev->bus->op->buffer_free) 703 if (!dev || !dev->bus)
704 return; 704 return;
705 if (!addr) 705 if (!addr)
706 return; 706 return;
707 dev->bus->op->buffer_free (dev->bus, size, addr, dma); 707 hcd_buffer_free (dev->bus, size, addr, dma);
708} 708}
709 709
710/** 710/**