Commit a6d2bb9f authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

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: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 511366da
...@@ -731,30 +731,6 @@ static void usb_bus_init (struct usb_bus *bus) ...@@ -731,30 +731,6 @@ static void usb_bus_init (struct usb_bus *bus)
kref_init(&bus->kref); 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) ...@@ -1102,7 +1078,7 @@ static void urb_unlink (struct urb *urb)
* expects usb_submit_urb() to have sanity checked and conditioned all * expects usb_submit_urb() to have sanity checked and conditioned all
* inputs in the urb * 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; int status;
struct usb_hcd *hcd = urb->dev->bus->hcpriv; struct usb_hcd *hcd = urb->dev->bus->hcpriv;
...@@ -1211,7 +1187,7 @@ done: ...@@ -1211,7 +1187,7 @@ done:
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
/* called in any context */ /* 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; struct usb_hcd *hcd = (struct usb_hcd *)udev->bus->hcpriv;
if (!HC_IS_RUNNING (hcd->state)) if (!HC_IS_RUNNING (hcd->state))
...@@ -1253,7 +1229,7 @@ unlink1 (struct usb_hcd *hcd, struct urb *urb) ...@@ -1253,7 +1229,7 @@ unlink1 (struct usb_hcd *hcd, struct urb *urb)
* caller guarantees urb won't be recycled till both unlink() * caller guarantees urb won't be recycled till both unlink()
* and the urb's completion function return * 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_host_endpoint *ep;
struct usb_hcd *hcd = NULL; struct usb_hcd *hcd = NULL;
...@@ -1351,8 +1327,8 @@ done: ...@@ -1351,8 +1327,8 @@ done:
* example: a qh stored in ep->hcpriv, holding state related to endpoint * example: a qh stored in ep->hcpriv, holding state related to endpoint
* type, maxpacket size, toggle, halt status, and scheduling. * type, maxpacket size, toggle, halt status, and scheduling.
*/ */
static void void usb_hcd_endpoint_disable (struct usb_device *udev,
hcd_endpoint_disable (struct usb_device *udev, struct usb_host_endpoint *ep) struct usb_host_endpoint *ep)
{ {
struct usb_hcd *hcd; struct usb_hcd *hcd;
struct urb *urb; struct urb *urb;
...@@ -1589,20 +1565,6 @@ EXPORT_SYMBOL (usb_bus_start_enum); ...@@ -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 * usb_hcd_giveback_urb - return URB from HCD to device driver
* @hcd: host controller returning the URB * @hcd: host controller returning the URB
...@@ -1744,7 +1706,6 @@ struct usb_hcd *usb_create_hcd (const struct hc_driver *driver, ...@@ -1744,7 +1706,6 @@ struct usb_hcd *usb_create_hcd (const struct hc_driver *driver,
dev_set_drvdata(dev, hcd); dev_set_drvdata(dev, hcd);
usb_bus_init(&hcd->self); usb_bus_init(&hcd->self);
hcd->self.op = &usb_hcd_operations;
hcd->self.hcpriv = hcd; hcd->self.hcpriv = hcd;
hcd->self.release = &hcd_release; hcd->self.release = &hcd_release;
hcd->self.controller = dev; hcd->self.controller = dev;
......
...@@ -139,28 +139,6 @@ struct hcd_timeout { /* timeouts we allocate */ ...@@ -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; struct pt_regs;
...@@ -222,7 +200,13 @@ struct hc_driver { ...@@ -222,7 +200,13 @@ struct hc_driver {
/* Needed only if port-change IRQs are level-triggered */ /* 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, extern struct usb_hcd *usb_create_hcd (const struct hc_driver *driver,
struct device *dev, char *bus_name); struct device *dev, char *bus_name);
...@@ -361,8 +345,6 @@ extern long usb_calc_bus_time (int speed, int is_input, ...@@ -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, extern void usb_set_device_state(struct usb_device *udev,
enum usb_device_state new_state); enum usb_device_state new_state);
......
...@@ -984,8 +984,8 @@ void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr) ...@@ -984,8 +984,8 @@ void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr)
ep = dev->ep_in[epnum]; ep = dev->ep_in[epnum];
dev->ep_in[epnum] = NULL; dev->ep_in[epnum] = NULL;
} }
if (ep && dev->bus && dev->bus->op && dev->bus->op->disable) if (ep && dev->bus)
dev->bus->op->disable(dev, ep); usb_hcd_endpoint_disable(dev, ep);
} }
/** /**
......
...@@ -221,7 +221,6 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) ...@@ -221,7 +221,6 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
{ {
int pipe, temp, max; int pipe, temp, max;
struct usb_device *dev; struct usb_device *dev;
struct usb_operations *op;
int is_out; int is_out;
if (!urb || urb->hcpriv || !urb->complete) if (!urb || urb->hcpriv || !urb->complete)
...@@ -233,8 +232,6 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) ...@@ -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 if (dev->bus->controller->power.power_state.event != PM_EVENT_ON
|| dev->state == USB_STATE_SUSPENDED) || dev->state == USB_STATE_SUSPENDED)
return -EHOSTUNREACH; return -EHOSTUNREACH;
if (!(op = dev->bus->op) || !op->submit_urb)
return -ENODEV;
urb->status = -EINPROGRESS; urb->status = -EINPROGRESS;
urb->actual_length = 0; urb->actual_length = 0;
...@@ -376,7 +373,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) ...@@ -376,7 +373,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
urb->interval = temp; 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) ...@@ -440,9 +437,9 @@ int usb_unlink_urb(struct urb *urb)
{ {
if (!urb) if (!urb)
return -EINVAL; return -EINVAL;
if (!(urb->dev && urb->dev->bus && urb->dev->bus->op)) if (!(urb->dev && urb->dev->bus))
return -ENODEV; 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) ...@@ -468,13 +465,13 @@ int usb_unlink_urb(struct urb *urb)
void usb_kill_urb(struct urb *urb) void usb_kill_urb(struct urb *urb)
{ {
might_sleep(); might_sleep();
if (!(urb && urb->dev && urb->dev->bus && urb->dev->bus->op)) if (!(urb && urb->dev && urb->dev->bus))
return; return;
spin_lock_irq(&urb->lock); spin_lock_irq(&urb->lock);
++urb->reject; ++urb->reject;
spin_unlock_irq(&urb->lock); 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); wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0);
spin_lock_irq(&urb->lock); spin_lock_irq(&urb->lock);
......
...@@ -480,7 +480,7 @@ exit: ...@@ -480,7 +480,7 @@ exit:
*/ */
int usb_get_current_frame_number(struct usb_device *dev) 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 ( ...@@ -677,9 +677,9 @@ void *usb_buffer_alloc (
dma_addr_t *dma dma_addr_t *dma
) )
{ {
if (!dev || !dev->bus || !dev->bus->op || !dev->bus->op->buffer_alloc) if (!dev || !dev->bus)
return NULL; 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 ( ...@@ -700,11 +700,11 @@ void usb_buffer_free (
dma_addr_t dma dma_addr_t dma
) )
{ {
if (!dev || !dev->bus || !dev->bus->op || !dev->bus->op->buffer_free) if (!dev || !dev->bus)
return; return;
if (!addr) if (!addr)
return; return;
dev->bus->op->buffer_free (dev->bus, size, addr, dma); hcd_buffer_free (dev->bus, size, addr, dma);
} }
/** /**
......
...@@ -257,8 +257,6 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, ...@@ -257,8 +257,6 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size,
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
struct usb_operations;
/* USB device number allocation bitmap */ /* USB device number allocation bitmap */
struct usb_devmap { struct usb_devmap {
unsigned long devicemap[128 / (8*sizeof(unsigned long))]; unsigned long devicemap[128 / (8*sizeof(unsigned long))];
...@@ -279,7 +277,6 @@ struct usb_bus { ...@@ -279,7 +277,6 @@ struct usb_bus {
* round-robin allocation */ * round-robin allocation */
struct usb_devmap devmap; /* device address allocation map */ 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 usb_device *root_hub; /* Root hub */
struct list_head bus_list; /* list of busses */ struct list_head bus_list; /* list of busses */
void *hcpriv; /* Host Controller private data */ void *hcpriv; /* Host Controller private data */
...@@ -1051,7 +1048,6 @@ extern int usb_submit_urb(struct urb *urb, gfp_t mem_flags); ...@@ -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 int usb_unlink_urb(struct urb *urb);
extern void usb_kill_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, void *usb_buffer_alloc (struct usb_device *dev, size_t size,
gfp_t mem_flags, dma_addr_t *dma); gfp_t mem_flags, dma_addr_t *dma);
void usb_buffer_free (struct usb_device *dev, size_t size, void usb_buffer_free (struct usb_device *dev, size_t size,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment