Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 36434
b: refs/heads/master
c: a6d2bb9
h: refs/heads/master
v: v3
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Sep 27, 2006
1 parent 4c33f06 commit 4e5f45f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 89 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 511366da534bad226e89d294c3b3e910a2aaba6b
refs/heads/master: a6d2bb9ff919b4685bd684620ec7a1ffa8bf2349
49 changes: 5 additions & 44 deletions trunk/drivers/usb/core/hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*-------------------------------------------------------------------------*/

/**
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1211,7 +1187,7 @@ static int hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
/*-------------------------------------------------------------------------*/

/* 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))
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1351,8 +1327,8 @@ static int hcd_unlink_urb (struct urb *urb, int status)
* 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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
32 changes: 7 additions & 25 deletions trunk/drivers/usb/core/hcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/usb/core/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
13 changes: 5 additions & 8 deletions trunk/drivers/usb/core/urb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}

/*-------------------------------------------------------------------*/
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions trunk/drivers/usb/core/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ struct usb_device *usb_find_device(u16 vendor_id, u16 product_id)
*/
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);
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand Down
4 changes: 0 additions & 4 deletions trunk/include/linux/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))];
Expand All @@ -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 */
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 4e5f45f

Please sign in to comment.