Commit 6bbdfe17 authored by Deepak Saxena's avatar Deepak Saxena

[PATCH] USB: Fix USB host code to use generic DMA API

parent aa2716ec
...@@ -2,14 +2,19 @@ ...@@ -2,14 +2,19 @@
* DMA memory management for framework level HCD code (hc_driver) * DMA memory management for framework level HCD code (hc_driver)
* *
* This implementation plugs in through generic "usb_bus" level methods, * This implementation plugs in through generic "usb_bus" level methods,
* and works with real PCI, or when "pci device == null" makes sense. * and should work with all USB controllers, regardles of bus type.
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/pci.h> #include <linux/device.h>
#include <linux/mm.h>
#include <asm/io.h>
#include <asm/scatterlist.h>
#include <linux/dma-mapping.h>
#include <linux/dmapool.h>
#ifdef CONFIG_USB_DEBUG #ifdef CONFIG_USB_DEBUG
...@@ -62,7 +67,7 @@ int hcd_buffer_create (struct usb_hcd *hcd) ...@@ -62,7 +67,7 @@ int hcd_buffer_create (struct usb_hcd *hcd)
if (!(size = pool_max [i])) if (!(size = pool_max [i]))
continue; continue;
snprintf (name, sizeof name, "buffer-%d", size); snprintf (name, sizeof name, "buffer-%d", size);
hcd->pool [i] = pci_pool_create (name, hcd->pdev, hcd->pool [i] = dma_pool_create (name, hcd->self.controller,
size, size, 0); size, size, 0);
if (!hcd->pool [i]) { if (!hcd->pool [i]) {
hcd_buffer_destroy (hcd); hcd_buffer_destroy (hcd);
...@@ -86,9 +91,9 @@ void hcd_buffer_destroy (struct usb_hcd *hcd) ...@@ -86,9 +91,9 @@ void hcd_buffer_destroy (struct usb_hcd *hcd)
int i; int i;
for (i = 0; i < HCD_BUFFER_POOLS; i++) { for (i = 0; i < HCD_BUFFER_POOLS; i++) {
struct pci_pool *pool = hcd->pool [i]; struct dma_pool *pool = hcd->pool [i];
if (pool) { if (pool) {
pci_pool_destroy (pool); dma_pool_destroy (pool);
hcd->pool [i] = 0; hcd->pool [i] = 0;
} }
} }
...@@ -112,9 +117,9 @@ void *hcd_buffer_alloc ( ...@@ -112,9 +117,9 @@ void *hcd_buffer_alloc (
for (i = 0; i < HCD_BUFFER_POOLS; i++) { for (i = 0; i < HCD_BUFFER_POOLS; i++) {
if (size <= pool_max [i]) if (size <= pool_max [i])
return pci_pool_alloc (hcd->pool [i], mem_flags, dma); return dma_pool_alloc (hcd->pool [i], mem_flags, dma);
} }
return pci_alloc_consistent (hcd->pdev, size, dma); return dma_alloc_coherent (hcd->self.controller, size, dma, 0);
} }
void hcd_buffer_free ( void hcd_buffer_free (
...@@ -131,9 +136,9 @@ void hcd_buffer_free ( ...@@ -131,9 +136,9 @@ void hcd_buffer_free (
return; return;
for (i = 0; i < HCD_BUFFER_POOLS; i++) { for (i = 0; i < HCD_BUFFER_POOLS; i++) {
if (size <= pool_max [i]) { if (size <= pool_max [i]) {
pci_pool_free (hcd->pool [i], addr, dma); dma_pool_free (hcd->pool [i], addr, dma);
return; return;
} }
} }
pci_free_consistent (hcd->pdev, size, addr, dma); dma_free_coherent (hcd->self.controller, size, addr, dma);
} }
...@@ -146,12 +146,10 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) ...@@ -146,12 +146,10 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id)
pci_set_drvdata (dev, hcd); pci_set_drvdata (dev, hcd);
hcd->driver = driver; hcd->driver = driver;
hcd->description = driver->description; hcd->description = driver->description;
hcd->pdev = dev;
hcd->self.bus_name = pci_name(dev); hcd->self.bus_name = pci_name(dev);
if (hcd->product_desc == NULL) if (hcd->product_desc == NULL)
hcd->product_desc = "USB Host Controller"; hcd->product_desc = "USB Host Controller";
hcd->self.controller = &dev->dev; hcd->self.controller = &dev->dev;
hcd->controller = hcd->self.controller;
if ((retval = hcd_buffer_create (hcd)) != 0) { if ((retval = hcd_buffer_create (hcd)) != 0) {
clean_3: clean_3:
...@@ -159,11 +157,11 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) ...@@ -159,11 +157,11 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id)
goto clean_2; goto clean_2;
} }
dev_info (hcd->controller, "%s\n", hcd->product_desc); dev_info (hcd->self.controller, "%s\n", hcd->product_desc);
/* till now HC has been in an indeterminate state ... */ /* till now HC has been in an indeterminate state ... */
if (driver->reset && (retval = driver->reset (hcd)) < 0) { if (driver->reset && (retval = driver->reset (hcd)) < 0) {
dev_err (hcd->controller, "can't reset\n"); dev_err (hcd->self.controller, "can't reset\n");
goto clean_3; goto clean_3;
} }
hcd->state = USB_STATE_HALT; hcd->state = USB_STATE_HALT;
...@@ -177,13 +175,13 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) ...@@ -177,13 +175,13 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id)
retval = request_irq (dev->irq, usb_hcd_irq, SA_SHIRQ, retval = request_irq (dev->irq, usb_hcd_irq, SA_SHIRQ,
hcd->description, hcd); hcd->description, hcd);
if (retval != 0) { if (retval != 0) {
dev_err (hcd->controller, dev_err (hcd->self.controller,
"request interrupt %s failed\n", bufp); "request interrupt %s failed\n", bufp);
goto clean_3; goto clean_3;
} }
hcd->irq = dev->irq; hcd->irq = dev->irq;
dev_info (hcd->controller, "irq %s, %s %p\n", bufp, dev_info (hcd->self.controller, "irq %s, %s %p\n", bufp,
(driver->flags & HCD_MEMORY) ? "pci mem" : "io base", (driver->flags & HCD_MEMORY) ? "pci mem" : "io base",
base); base);
...@@ -226,7 +224,7 @@ void usb_hcd_pci_remove (struct pci_dev *dev) ...@@ -226,7 +224,7 @@ void usb_hcd_pci_remove (struct pci_dev *dev)
hcd = pci_get_drvdata(dev); hcd = pci_get_drvdata(dev);
if (!hcd) if (!hcd)
return; return;
dev_info (hcd->controller, "remove, state %x\n", hcd->state); dev_info (hcd->self.controller, "remove, state %x\n", hcd->state);
if (in_interrupt ()) if (in_interrupt ())
BUG (); BUG ();
...@@ -235,7 +233,7 @@ void usb_hcd_pci_remove (struct pci_dev *dev) ...@@ -235,7 +233,7 @@ void usb_hcd_pci_remove (struct pci_dev *dev)
if (HCD_IS_RUNNING (hcd->state)) if (HCD_IS_RUNNING (hcd->state))
hcd->state = USB_STATE_QUIESCING; hcd->state = USB_STATE_QUIESCING;
dev_dbg (hcd->controller, "roothub graceful disconnect\n"); dev_dbg (hcd->self.controller, "roothub graceful disconnect\n");
usb_disconnect (&hub); usb_disconnect (&hub);
hcd->driver->stop (hcd); hcd->driver->stop (hcd);
...@@ -273,15 +271,15 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, u32 state) ...@@ -273,15 +271,15 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, u32 state)
int retval = 0; int retval = 0;
hcd = pci_get_drvdata(dev); hcd = pci_get_drvdata(dev);
dev_dbg (hcd->controller, "suspend D%d --> D%d\n", dev_dbg (hcd->self.controller, "suspend D%d --> D%d\n",
dev->current_state, state); dev->current_state, state);
switch (hcd->state) { switch (hcd->state) {
case USB_STATE_HALT: case USB_STATE_HALT:
dev_dbg (hcd->controller, "halted; hcd not suspended\n"); dev_dbg (hcd->self.controller, "halted; hcd not suspended\n");
break; break;
case USB_STATE_SUSPENDED: case USB_STATE_SUSPENDED:
dev_dbg (hcd->controller, "hcd already suspended\n"); dev_dbg (hcd->self.controller, "hcd already suspended\n");
break; break;
default: default:
/* remote wakeup needs hub->suspend() cooperation */ /* remote wakeup needs hub->suspend() cooperation */
...@@ -293,7 +291,8 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, u32 state) ...@@ -293,7 +291,8 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, u32 state)
hcd->state = USB_STATE_QUIESCING; hcd->state = USB_STATE_QUIESCING;
retval = hcd->driver->suspend (hcd, state); retval = hcd->driver->suspend (hcd, state);
if (retval) if (retval)
dev_dbg (hcd->controller, "suspend fail, retval %d\n", dev_dbg (hcd->self.controller,
"suspend fail, retval %d\n",
retval); retval);
else else
hcd->state = USB_STATE_SUSPENDED; hcd->state = USB_STATE_SUSPENDED;
...@@ -316,11 +315,12 @@ int usb_hcd_pci_resume (struct pci_dev *dev) ...@@ -316,11 +315,12 @@ int usb_hcd_pci_resume (struct pci_dev *dev)
int retval; int retval;
hcd = pci_get_drvdata(dev); hcd = pci_get_drvdata(dev);
dev_dbg (hcd->controller, "resume from state D%d\n", dev_dbg (hcd->self.controller, "resume from state D%d\n",
dev->current_state); dev->current_state);
if (hcd->state != USB_STATE_SUSPENDED) { if (hcd->state != USB_STATE_SUSPENDED) {
dev_dbg (hcd->controller, "can't resume, not suspended!\n"); dev_dbg (hcd->self.controller,
"can't resume, not suspended!\n");
return -EL3HLT; return -EL3HLT;
} }
hcd->state = USB_STATE_RESUMING; hcd->state = USB_STATE_RESUMING;
...@@ -333,7 +333,8 @@ int usb_hcd_pci_resume (struct pci_dev *dev) ...@@ -333,7 +333,8 @@ int usb_hcd_pci_resume (struct pci_dev *dev)
retval = hcd->driver->resume (hcd); retval = hcd->driver->resume (hcd);
if (!HCD_IS_RUNNING (hcd->state)) { if (!HCD_IS_RUNNING (hcd->state)) {
dev_dbg (hcd->controller, "resume fail, retval %d\n", retval); dev_dbg (hcd->self.controller,
"resume fail, retval %d\n", retval);
usb_hc_died (hcd); usb_hc_died (hcd);
} }
......
...@@ -351,7 +351,7 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) ...@@ -351,7 +351,7 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb)
/* FALLTHROUGH */ /* FALLTHROUGH */
case DeviceOutRequest | USB_REQ_CLEAR_FEATURE: case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:
case DeviceOutRequest | USB_REQ_SET_FEATURE: case DeviceOutRequest | USB_REQ_SET_FEATURE:
dev_dbg (hcd->controller, "no device features yet yet\n"); dev_dbg (hcd->self.controller, "no device features yet yet\n");
break; break;
case DeviceRequest | USB_REQ_GET_CONFIGURATION: case DeviceRequest | USB_REQ_GET_CONFIGURATION:
ubuf [0] = 1; ubuf [0] = 1;
...@@ -394,7 +394,7 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) ...@@ -394,7 +394,7 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb)
break; break;
case DeviceOutRequest | USB_REQ_SET_ADDRESS: case DeviceOutRequest | USB_REQ_SET_ADDRESS:
// wValue == urb->dev->devaddr // wValue == urb->dev->devaddr
dev_dbg (hcd->controller, "root hub device address %d\n", dev_dbg (hcd->self.controller, "root hub device address %d\n",
wValue); wValue);
break; break;
...@@ -409,7 +409,7 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) ...@@ -409,7 +409,7 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb)
/* FALLTHROUGH */ /* FALLTHROUGH */
case EndpointOutRequest | USB_REQ_CLEAR_FEATURE: case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
case EndpointOutRequest | USB_REQ_SET_FEATURE: case EndpointOutRequest | USB_REQ_SET_FEATURE:
dev_dbg (hcd->controller, "no endpoint features yet\n"); dev_dbg (hcd->self.controller, "no endpoint features yet\n");
break; break;
/* CLASS REQUESTS (and errors) */ /* CLASS REQUESTS (and errors) */
...@@ -423,12 +423,12 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) ...@@ -423,12 +423,12 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb)
error: error:
/* "protocol stall" on error */ /* "protocol stall" on error */
urb->status = -EPIPE; urb->status = -EPIPE;
dev_dbg (hcd->controller, "unsupported hub control message (maxchild %d)\n", dev_dbg (hcd->self.controller, "unsupported hub control message (maxchild %d)\n",
urb->dev->maxchild); urb->dev->maxchild);
} }
if (urb->status) { if (urb->status) {
urb->actual_length = 0; urb->actual_length = 0;
dev_dbg (hcd->controller, "CTRL: TypeReq=0x%x val=0x%x idx=0x%x len=%d ==> %d\n", dev_dbg (hcd->self.controller, "CTRL: TypeReq=0x%x val=0x%x idx=0x%x len=%d ==> %d\n",
typeReq, wValue, wIndex, wLength, urb->status); typeReq, wValue, wIndex, wLength, urb->status);
} }
if (bufp) { if (bufp) {
...@@ -464,7 +464,7 @@ static int rh_status_urb (struct usb_hcd *hcd, struct urb *urb) ...@@ -464,7 +464,7 @@ static int rh_status_urb (struct usb_hcd *hcd, struct urb *urb)
|| urb->status != -EINPROGRESS || urb->status != -EINPROGRESS
|| urb->transfer_buffer_length < len || urb->transfer_buffer_length < len
|| !HCD_IS_RUNNING (hcd->state)) { || !HCD_IS_RUNNING (hcd->state)) {
dev_dbg (hcd->controller, dev_dbg (hcd->self.controller,
"not queuing rh status urb, stat %d\n", "not queuing rh status urb, stat %d\n",
urb->status); urb->status);
return -EINVAL; return -EINVAL;
...@@ -1068,18 +1068,18 @@ static int hcd_submit_urb (struct urb *urb, int mem_flags) ...@@ -1068,18 +1068,18 @@ static int hcd_submit_urb (struct urb *urb, int mem_flags)
/* lower level hcd code should use *_dma exclusively, /* lower level hcd code should use *_dma exclusively,
* unless it uses pio or talks to another transport. * unless it uses pio or talks to another transport.
*/ */
if (hcd->controller->dma_mask) { if (hcd->self.controller->dma_mask) {
if (usb_pipecontrol (urb->pipe) if (usb_pipecontrol (urb->pipe)
&& !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP))
urb->setup_dma = dma_map_single ( urb->setup_dma = dma_map_single (
hcd->controller, hcd->self.controller,
urb->setup_packet, urb->setup_packet,
sizeof (struct usb_ctrlrequest), sizeof (struct usb_ctrlrequest),
DMA_TO_DEVICE); DMA_TO_DEVICE);
if (urb->transfer_buffer_length != 0 if (urb->transfer_buffer_length != 0
&& !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP))
urb->transfer_dma = dma_map_single ( urb->transfer_dma = dma_map_single (
hcd->controller, hcd->self.controller,
urb->transfer_buffer, urb->transfer_buffer,
urb->transfer_buffer_length, urb->transfer_buffer_length,
usb_pipein (urb->pipe) usb_pipein (urb->pipe)
...@@ -1125,7 +1125,7 @@ unlink1 (struct usb_hcd *hcd, struct urb *urb) ...@@ -1125,7 +1125,7 @@ unlink1 (struct usb_hcd *hcd, struct urb *urb)
/* failures "should" be harmless */ /* failures "should" be harmless */
value = hcd->driver->urb_dequeue (hcd, urb); value = hcd->driver->urb_dequeue (hcd, urb);
if (value != 0) if (value != 0)
dev_dbg (hcd->controller, dev_dbg (hcd->self.controller,
"dequeue %p --> %d\n", "dequeue %p --> %d\n",
urb, value); urb, value);
} }
...@@ -1232,7 +1232,7 @@ static int hcd_unlink_urb (struct urb *urb) ...@@ -1232,7 +1232,7 @@ static int hcd_unlink_urb (struct urb *urb)
* finish unlinking the initial failed usb_set_address(). * finish unlinking the initial failed usb_set_address().
*/ */
if (!hcd->saw_irq) { if (!hcd->saw_irq) {
dev_warn (hcd->controller, "Unlink after no-IRQ? " dev_warn (hcd->self.controller, "Unlink after no-IRQ? "
"Different ACPI or APIC settings may help." "Different ACPI or APIC settings may help."
"\n"); "\n");
hcd->saw_irq = 1; hcd->saw_irq = 1;
...@@ -1244,7 +1244,8 @@ static int hcd_unlink_urb (struct urb *urb) ...@@ -1244,7 +1244,8 @@ static int hcd_unlink_urb (struct urb *urb)
*/ */
if (!(urb->transfer_flags & URB_ASYNC_UNLINK)) { if (!(urb->transfer_flags & URB_ASYNC_UNLINK)) {
if (in_interrupt ()) { if (in_interrupt ()) {
dev_dbg (hcd->controller, "non-async unlink in_interrupt"); dev_dbg (hcd->self.controller,
"non-async unlink in_interrupt");
retval = -EWOULDBLOCK; retval = -EWOULDBLOCK;
goto done; goto done;
} }
...@@ -1363,7 +1364,7 @@ static void hcd_endpoint_disable (struct usb_device *udev, int endpoint) ...@@ -1363,7 +1364,7 @@ static void hcd_endpoint_disable (struct usb_device *udev, int endpoint)
if (tmp == -EINPROGRESS) { if (tmp == -EINPROGRESS) {
tmp = urb->pipe; tmp = urb->pipe;
unlink1 (hcd, urb); unlink1 (hcd, urb);
dev_dbg (hcd->controller, dev_dbg (hcd->self.controller,
"shutdown urb %p pipe %08x ep%d%s%s\n", "shutdown urb %p pipe %08x ep%d%s%s\n",
urb, tmp, usb_pipeendpoint (tmp), urb, tmp, usb_pipeendpoint (tmp),
(tmp & USB_DIR_IN) ? "in" : "out", (tmp & USB_DIR_IN) ? "in" : "out",
...@@ -1417,7 +1418,7 @@ static int hcd_free_dev (struct usb_device *udev) ...@@ -1417,7 +1418,7 @@ static int hcd_free_dev (struct usb_device *udev)
/* device driver problem with refcounts? */ /* device driver problem with refcounts? */
if (!list_empty (&dev->urb_list)) { if (!list_empty (&dev->urb_list)) {
dev_dbg (hcd->controller, "free busy dev, %s devnum %d (bug!)\n", dev_dbg (hcd->self.controller, "free busy dev, %s devnum %d (bug!)\n",
hcd->self.bus_name, udev->devnum); hcd->self.bus_name, udev->devnum);
return -EINVAL; return -EINVAL;
} }
...@@ -1474,15 +1475,16 @@ void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb, struct pt_regs ...@@ -1474,15 +1475,16 @@ void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb, struct pt_regs
// It would catch exit/unlink paths for all urbs. // It would catch exit/unlink paths for all urbs.
/* lower level hcd code should use *_dma exclusively */ /* lower level hcd code should use *_dma exclusively */
if (hcd->controller->dma_mask) { if (hcd->self.controller->dma_mask) {
if (usb_pipecontrol (urb->pipe) if (usb_pipecontrol (urb->pipe)
&& !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP))
dma_unmap_single (hcd->controller, urb->setup_dma, dma_unmap_single (hcd->self.controller, urb->setup_dma,
sizeof (struct usb_ctrlrequest), sizeof (struct usb_ctrlrequest),
DMA_TO_DEVICE); DMA_TO_DEVICE);
if (urb->transfer_buffer_length != 0 if (urb->transfer_buffer_length != 0
&& !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP))
dma_unmap_single (hcd->controller, urb->transfer_dma, dma_unmap_single (hcd->self.controller,
urb->transfer_dma,
urb->transfer_buffer_length, urb->transfer_buffer_length,
usb_pipein (urb->pipe) usb_pipein (urb->pipe)
? DMA_FROM_DEVICE ? DMA_FROM_DEVICE
...@@ -1551,7 +1553,7 @@ static void hcd_panic (void *_hcd) ...@@ -1551,7 +1553,7 @@ static void hcd_panic (void *_hcd)
*/ */
void usb_hc_died (struct usb_hcd *hcd) void usb_hc_died (struct usb_hcd *hcd)
{ {
dev_err (hcd->controller, "HC died; cleaning up\n"); dev_err (hcd->self.controller, "HC died; cleaning up\n");
/* clean up old urbs and devices; needs a task context */ /* clean up old urbs and devices; needs a task context */
INIT_WORK (&hcd->work, hcd_panic, hcd); INIT_WORK (&hcd->work, hcd_panic, hcd);
......
...@@ -76,17 +76,14 @@ struct usb_hcd { /* usb_bus.hcpriv points to this */ ...@@ -76,17 +76,14 @@ struct usb_hcd { /* usb_bus.hcpriv points to this */
unsigned saw_irq : 1; unsigned saw_irq : 1;
int irq; /* irq allocated */ int irq; /* irq allocated */
void *regs; /* device memory/io */ void *regs; /* device memory/io */
struct device *controller; /* handle to hardware */
/* a few non-PCI controllers exist, mostly for OHCI */
struct pci_dev *pdev; /* pci is typical */
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
int region; /* pci region for regs */ int region; /* pci region for regs */
u32 pci_state [16]; /* for PM state save */ u32 pci_state [16]; /* for PM state save */
#endif #endif
#define HCD_BUFFER_POOLS 4 #define HCD_BUFFER_POOLS 4
struct pci_pool *pool [HCD_BUFFER_POOLS]; struct dma_pool *pool [HCD_BUFFER_POOLS];
int state; int state;
# define __ACTIVE 0x01 # define __ACTIVE 0x01
...@@ -355,7 +352,7 @@ extern int usb_register_root_hub (struct usb_device *usb_dev, ...@@ -355,7 +352,7 @@ extern int usb_register_root_hub (struct usb_device *usb_dev,
static inline int hcd_register_root (struct usb_hcd *hcd) static inline int hcd_register_root (struct usb_hcd *hcd)
{ {
return usb_register_root_hub ( return usb_register_root_hub (
hcd_to_bus (hcd)->root_hub, hcd->controller); hcd_to_bus (hcd)->root_hub, hcd->self.controller);
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
......
...@@ -19,13 +19,13 @@ ...@@ -19,13 +19,13 @@
/* this file is part of ehci-hcd.c */ /* this file is part of ehci-hcd.c */
#define ehci_dbg(ehci, fmt, args...) \ #define ehci_dbg(ehci, fmt, args...) \
dev_dbg ((ehci)->hcd.controller , fmt , ## args ) dev_dbg ((ehci)->hcd.self.controller , fmt , ## args )
#define ehci_err(ehci, fmt, args...) \ #define ehci_err(ehci, fmt, args...) \
dev_err ((ehci)->hcd.controller , fmt , ## args ) dev_err ((ehci)->hcd.self.controller , fmt , ## args )
#define ehci_info(ehci, fmt, args...) \ #define ehci_info(ehci, fmt, args...) \
dev_info ((ehci)->hcd.controller , fmt , ## args ) dev_info ((ehci)->hcd.self.controller , fmt , ## args )
#define ehci_warn(ehci, fmt, args...) \ #define ehci_warn(ehci, fmt, args...) \
dev_warn ((ehci)->hcd.controller , fmt , ## args ) dev_warn ((ehci)->hcd.self.controller , fmt , ## args )
#ifdef EHCI_VERBOSE_DEBUG #ifdef EHCI_VERBOSE_DEBUG
# define vdbg dbg # define vdbg dbg
...@@ -625,7 +625,7 @@ show_registers (struct class_device *class_dev, char *buf) ...@@ -625,7 +625,7 @@ show_registers (struct class_device *class_dev, char *buf)
i = HC_VERSION(readl (&ehci->caps->hc_capbase)); i = HC_VERSION(readl (&ehci->caps->hc_capbase));
temp = snprintf (next, size, temp = snprintf (next, size,
"PCI device %s\nEHCI %x.%02x, hcd state %d (driver " DRIVER_VERSION ")\n", "PCI device %s\nEHCI %x.%02x, hcd state %d (driver " DRIVER_VERSION ")\n",
pci_name(hcd->pdev), pci_name(to_pci_dev(hcd->self.controller)),
i >> 8, i & 0x0ff, ehci->hcd.state); i >> 8, i & 0x0ff, ehci->hcd.state);
size -= temp; size -= temp;
next += temp; next += temp;
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/dmapool.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/ioport.h> #include <linux/ioport.h>
...@@ -67,6 +68,7 @@ ...@@ -67,6 +68,7 @@
* *
* HISTORY: * HISTORY:
* *
* 2004-02-24 Replace pci_* with generic dma_* API calls (dsaxena@plexity.net)
* 2003-12-29 Rewritten high speed iso transfer support (by Michal Sojka, * 2003-12-29 Rewritten high speed iso transfer support (by Michal Sojka,
* <sojkam@centrum.cz>, updates by DB). * <sojkam@centrum.cz>, updates by DB).
* *
...@@ -288,13 +290,13 @@ static int bios_handoff (struct ehci_hcd *ehci, int where, u32 cap) ...@@ -288,13 +290,13 @@ static int bios_handoff (struct ehci_hcd *ehci, int where, u32 cap)
/* request handoff to OS */ /* request handoff to OS */
cap &= 1 << 24; cap &= 1 << 24;
pci_write_config_dword (ehci->hcd.pdev, where, cap); pci_write_config_dword (to_pci_dev(ehci->hcd.self.controller), where, cap);
/* and wait a while for it to happen */ /* and wait a while for it to happen */
do { do {
wait_ms (10); wait_ms (10);
msec -= 10; msec -= 10;
pci_read_config_dword (ehci->hcd.pdev, where, &cap); pci_read_config_dword (to_pci_dev(ehci->hcd.self.controller), where, &cap);
} while ((cap & (1 << 16)) && msec); } while ((cap & (1 << 16)) && msec);
if (cap & (1 << 16)) { if (cap & (1 << 16)) {
ehci_err (ehci, "BIOS handoff failed (%d, %04x)\n", ehci_err (ehci, "BIOS handoff failed (%d, %04x)\n",
...@@ -339,7 +341,7 @@ static int ehci_hc_reset (struct usb_hcd *hcd) ...@@ -339,7 +341,7 @@ static int ehci_hc_reset (struct usb_hcd *hcd)
while (temp) { while (temp) {
u32 cap; u32 cap;
pci_read_config_dword (ehci->hcd.pdev, temp, &cap); pci_read_config_dword (to_pci_dev(ehci->hcd.self.controller), temp, &cap);
ehci_dbg (ehci, "capability %04x at %02x\n", cap, temp); ehci_dbg (ehci, "capability %04x at %02x\n", cap, temp);
switch (cap & 0xff) { switch (cap & 0xff) {
case 1: /* BIOS/SMM/... handoff */ case 1: /* BIOS/SMM/... handoff */
...@@ -378,7 +380,7 @@ static int ehci_start (struct usb_hcd *hcd) ...@@ -378,7 +380,7 @@ static int ehci_start (struct usb_hcd *hcd)
* periodic_size can shrink by USBCMD update if hcc_params allows. * periodic_size can shrink by USBCMD update if hcc_params allows.
*/ */
ehci->periodic_size = DEFAULT_I_TDPS; ehci->periodic_size = DEFAULT_I_TDPS;
if ((retval = ehci_mem_init (ehci, SLAB_KERNEL)) < 0) if ((retval = ehci_mem_init (ehci, GFP_KERNEL)) < 0)
return retval; return retval;
/* controllers may cache some of the periodic schedule ... */ /* controllers may cache some of the periodic schedule ... */
...@@ -433,13 +435,13 @@ static int ehci_start (struct usb_hcd *hcd) ...@@ -433,13 +435,13 @@ static int ehci_start (struct usb_hcd *hcd)
writel (0, &ehci->regs->segment); writel (0, &ehci->regs->segment);
#if 0 #if 0
// this is deeply broken on almost all architectures // this is deeply broken on almost all architectures
if (!pci_set_dma_mask (ehci->hcd.pdev, 0xffffffffffffffffULL)) if (!pci_set_dma_mask (to_pci_dev(ehci->hcd.self.controller), 0xffffffffffffffffULL))
ehci_info (ehci, "enabled 64bit PCI DMA\n"); ehci_info (ehci, "enabled 64bit PCI DMA\n");
#endif #endif
} }
/* help hc dma work well with cachelines */ /* help hc dma work well with cachelines */
pci_set_mwi (ehci->hcd.pdev); pci_set_mwi (to_pci_dev(ehci->hcd.self.controller));
/* clear interrupt enables, set irq latency */ /* clear interrupt enables, set irq latency */
temp = readl (&ehci->regs->command) & 0x0fff; temp = readl (&ehci->regs->command) & 0x0fff;
...@@ -493,7 +495,7 @@ static int ehci_start (struct usb_hcd *hcd) ...@@ -493,7 +495,7 @@ static int ehci_start (struct usb_hcd *hcd)
readl (&ehci->regs->command); /* unblock posted write */ readl (&ehci->regs->command); /* unblock posted write */
/* PCI Serial Bus Release Number is at 0x60 offset */ /* PCI Serial Bus Release Number is at 0x60 offset */
pci_read_config_byte (hcd->pdev, 0x60, &tempbyte); pci_read_config_byte(to_pci_dev(hcd->self.controller), 0x60, &tempbyte);
temp = HC_VERSION(readl (&ehci->caps->hc_capbase)); temp = HC_VERSION(readl (&ehci->caps->hc_capbase));
ehci_info (ehci, ehci_info (ehci,
"USB %x.%x enabled, EHCI %x.%02x, driver %s\n", "USB %x.%x enabled, EHCI %x.%02x, driver %s\n",
...@@ -758,7 +760,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs) ...@@ -758,7 +760,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs)
* non-error returns are a promise to giveback() the urb later * non-error returns are a promise to giveback() the urb later
* we drop ownership so next owner (or urb unlink) can get it * we drop ownership so next owner (or urb unlink) can get it
* *
* urb + dev is in hcd_dev.urb_list * urb + dev is in hcd.self.controller.urb_list
* we're queueing TDs onto software and hardware lists * we're queueing TDs onto software and hardware lists
* *
* hcd-specific init for hcpriv hasn't been done yet * hcd-specific init for hcpriv hasn't been done yet
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* There's basically three types of memory: * There's basically three types of memory:
* - data used only by the HCD ... kmalloc is fine * - data used only by the HCD ... kmalloc is fine
* - async and periodic schedules, shared by HC and HCD ... these * - async and periodic schedules, shared by HC and HCD ... these
* need to use pci_pool or pci_alloc_consistent * need to use dma_pool or dma_alloc_coherent
* - driver buffers, read/written by HC ... single shot DMA mapped * - driver buffers, read/written by HC ... single shot DMA mapped
* *
* There's also PCI "register" data, which is memory mapped. * There's also PCI "register" data, which is memory mapped.
...@@ -74,7 +74,7 @@ static struct ehci_qtd *ehci_qtd_alloc (struct ehci_hcd *ehci, int flags) ...@@ -74,7 +74,7 @@ static struct ehci_qtd *ehci_qtd_alloc (struct ehci_hcd *ehci, int flags)
struct ehci_qtd *qtd; struct ehci_qtd *qtd;
dma_addr_t dma; dma_addr_t dma;
qtd = pci_pool_alloc (ehci->qtd_pool, flags, &dma); qtd = dma_pool_alloc (ehci->qtd_pool, flags, &dma);
if (qtd != 0) { if (qtd != 0) {
ehci_qtd_init (qtd, dma); ehci_qtd_init (qtd, dma);
} }
...@@ -83,7 +83,7 @@ static struct ehci_qtd *ehci_qtd_alloc (struct ehci_hcd *ehci, int flags) ...@@ -83,7 +83,7 @@ static struct ehci_qtd *ehci_qtd_alloc (struct ehci_hcd *ehci, int flags)
static inline void ehci_qtd_free (struct ehci_hcd *ehci, struct ehci_qtd *qtd) static inline void ehci_qtd_free (struct ehci_hcd *ehci, struct ehci_qtd *qtd)
{ {
pci_pool_free (ehci->qtd_pool, qtd, qtd->qtd_dma); dma_pool_free (ehci->qtd_pool, qtd, qtd->qtd_dma);
} }
...@@ -93,7 +93,7 @@ static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, int flags) ...@@ -93,7 +93,7 @@ static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, int flags)
dma_addr_t dma; dma_addr_t dma;
qh = (struct ehci_qh *) qh = (struct ehci_qh *)
pci_pool_alloc (ehci->qh_pool, flags, &dma); dma_pool_alloc (ehci->qh_pool, flags, &dma);
if (!qh) if (!qh)
return qh; return qh;
...@@ -107,7 +107,7 @@ static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, int flags) ...@@ -107,7 +107,7 @@ static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, int flags)
qh->dummy = ehci_qtd_alloc (ehci, flags); qh->dummy = ehci_qtd_alloc (ehci, flags);
if (qh->dummy == 0) { if (qh->dummy == 0) {
ehci_dbg (ehci, "no dummy td\n"); ehci_dbg (ehci, "no dummy td\n");
pci_pool_free (ehci->qh_pool, qh, qh->qh_dma); dma_pool_free (ehci->qh_pool, qh, qh->qh_dma);
qh = 0; qh = 0;
} }
return qh; return qh;
...@@ -132,7 +132,7 @@ static void qh_put (struct ehci_hcd *ehci, struct ehci_qh *qh) ...@@ -132,7 +132,7 @@ static void qh_put (struct ehci_hcd *ehci, struct ehci_qh *qh)
if (qh->dummy) if (qh->dummy)
ehci_qtd_free (ehci, qh->dummy); ehci_qtd_free (ehci, qh->dummy);
usb_put_dev (qh->dev); usb_put_dev (qh->dev);
pci_pool_free (ehci->qh_pool, qh, qh->qh_dma); dma_pool_free (ehci->qh_pool, qh, qh->qh_dma);
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -148,26 +148,26 @@ static void ehci_mem_cleanup (struct ehci_hcd *ehci) ...@@ -148,26 +148,26 @@ static void ehci_mem_cleanup (struct ehci_hcd *ehci)
qh_put (ehci, ehci->async); qh_put (ehci, ehci->async);
ehci->async = 0; ehci->async = 0;
/* PCI consistent memory and pools */ /* DMA consistent memory and pools */
if (ehci->qtd_pool) if (ehci->qtd_pool)
pci_pool_destroy (ehci->qtd_pool); dma_pool_destroy (ehci->qtd_pool);
ehci->qtd_pool = 0; ehci->qtd_pool = 0;
if (ehci->qh_pool) { if (ehci->qh_pool) {
pci_pool_destroy (ehci->qh_pool); dma_pool_destroy (ehci->qh_pool);
ehci->qh_pool = 0; ehci->qh_pool = 0;
} }
if (ehci->itd_pool) if (ehci->itd_pool)
pci_pool_destroy (ehci->itd_pool); dma_pool_destroy (ehci->itd_pool);
ehci->itd_pool = 0; ehci->itd_pool = 0;
if (ehci->sitd_pool) if (ehci->sitd_pool)
pci_pool_destroy (ehci->sitd_pool); dma_pool_destroy (ehci->sitd_pool);
ehci->sitd_pool = 0; ehci->sitd_pool = 0;
if (ehci->periodic) if (ehci->periodic)
pci_free_consistent (ehci->hcd.pdev, dma_free_coherent (ehci->hcd.self.controller,
ehci->periodic_size * sizeof (u32), ehci->periodic_size * sizeof (u32),
ehci->periodic, ehci->periodic_dma); ehci->periodic, ehci->periodic_dma);
ehci->periodic = 0; ehci->periodic = 0;
...@@ -184,7 +184,8 @@ static int ehci_mem_init (struct ehci_hcd *ehci, int flags) ...@@ -184,7 +184,8 @@ static int ehci_mem_init (struct ehci_hcd *ehci, int flags)
int i; int i;
/* QTDs for control/bulk/intr transfers */ /* QTDs for control/bulk/intr transfers */
ehci->qtd_pool = pci_pool_create ("ehci_qtd", ehci->hcd.pdev, ehci->qtd_pool = dma_pool_create ("ehci_qtd",
ehci->hcd.self.controller,
sizeof (struct ehci_qtd), sizeof (struct ehci_qtd),
32 /* byte alignment (for hw parts) */, 32 /* byte alignment (for hw parts) */,
4096 /* can't cross 4K */); 4096 /* can't cross 4K */);
...@@ -193,7 +194,8 @@ static int ehci_mem_init (struct ehci_hcd *ehci, int flags) ...@@ -193,7 +194,8 @@ static int ehci_mem_init (struct ehci_hcd *ehci, int flags)
} }
/* QHs for control/bulk/intr transfers */ /* QHs for control/bulk/intr transfers */
ehci->qh_pool = pci_pool_create ("ehci_qh", ehci->hcd.pdev, ehci->qh_pool = dma_pool_create ("ehci_qh",
ehci->hcd.self.controller,
sizeof (struct ehci_qh), sizeof (struct ehci_qh),
32 /* byte alignment (for hw parts) */, 32 /* byte alignment (for hw parts) */,
4096 /* can't cross 4K */); 4096 /* can't cross 4K */);
...@@ -206,7 +208,8 @@ static int ehci_mem_init (struct ehci_hcd *ehci, int flags) ...@@ -206,7 +208,8 @@ static int ehci_mem_init (struct ehci_hcd *ehci, int flags)
} }
/* ITD for high speed ISO transfers */ /* ITD for high speed ISO transfers */
ehci->itd_pool = pci_pool_create ("ehci_itd", ehci->hcd.pdev, ehci->itd_pool = dma_pool_create ("ehci_itd",
ehci->hcd.self.controller,
sizeof (struct ehci_itd), sizeof (struct ehci_itd),
32 /* byte alignment (for hw parts) */, 32 /* byte alignment (for hw parts) */,
4096 /* can't cross 4K */); 4096 /* can't cross 4K */);
...@@ -215,7 +218,8 @@ static int ehci_mem_init (struct ehci_hcd *ehci, int flags) ...@@ -215,7 +218,8 @@ static int ehci_mem_init (struct ehci_hcd *ehci, int flags)
} }
/* SITD for full/low speed split ISO transfers */ /* SITD for full/low speed split ISO transfers */
ehci->sitd_pool = pci_pool_create ("ehci_sitd", ehci->hcd.pdev, ehci->sitd_pool = dma_pool_create ("ehci_sitd",
ehci->hcd.self.controller,
sizeof (struct ehci_sitd), sizeof (struct ehci_sitd),
32 /* byte alignment (for hw parts) */, 32 /* byte alignment (for hw parts) */,
4096 /* can't cross 4K */); 4096 /* can't cross 4K */);
...@@ -225,9 +229,9 @@ static int ehci_mem_init (struct ehci_hcd *ehci, int flags) ...@@ -225,9 +229,9 @@ static int ehci_mem_init (struct ehci_hcd *ehci, int flags)
/* Hardware periodic table */ /* Hardware periodic table */
ehci->periodic = (u32 *) ehci->periodic = (u32 *)
pci_alloc_consistent (ehci->hcd.pdev, dma_alloc_coherent (ehci->hcd.self.controller,
ehci->periodic_size * sizeof (u32), ehci->periodic_size * sizeof (u32),
&ehci->periodic_dma); &ehci->periodic_dma, 0);
if (ehci->periodic == 0) { if (ehci->periodic == 0) {
goto fail; goto fail;
} }
......
...@@ -776,7 +776,7 @@ static struct ehci_qh *qh_append_tds ( ...@@ -776,7 +776,7 @@ static struct ehci_qh *qh_append_tds (
qh = (struct ehci_qh *) *ptr; qh = (struct ehci_qh *) *ptr;
if (unlikely (qh == 0)) { if (unlikely (qh == 0)) {
/* can't sleep here, we have ehci->lock... */ /* can't sleep here, we have ehci->lock... */
qh = qh_make (ehci, urb, SLAB_ATOMIC); qh = qh_make (ehci, urb, GFP_ATOMIC);
*ptr = qh; *ptr = qh;
} }
if (likely (qh != 0)) { if (likely (qh != 0)) {
......
...@@ -578,7 +578,7 @@ iso_stream_put(struct ehci_hcd *ehci, struct ehci_iso_stream *stream) ...@@ -578,7 +578,7 @@ iso_stream_put(struct ehci_hcd *ehci, struct ehci_iso_stream *stream)
itd = list_entry (stream->free_itd_list.next, itd = list_entry (stream->free_itd_list.next,
struct ehci_itd, itd_list); struct ehci_itd, itd_list);
list_del (&itd->itd_list); list_del (&itd->itd_list);
pci_pool_free (ehci->itd_pool, itd, itd->itd_dma); dma_pool_free (ehci->itd_pool, itd, itd->itd_dma);
} }
is_in = (stream->bEndpointAddress & USB_DIR_IN) ? 0x10 : 0; is_in = (stream->bEndpointAddress & USB_DIR_IN) ? 0x10 : 0;
...@@ -760,7 +760,7 @@ itd_urb_transaction ( ...@@ -760,7 +760,7 @@ itd_urb_transaction (
list_del (&itd->itd_list); list_del (&itd->itd_list);
itd_dma = itd->itd_dma; itd_dma = itd->itd_dma;
} else } else
itd = pci_pool_alloc (ehci->itd_pool, mem_flags, itd = dma_pool_alloc (ehci->itd_pool, mem_flags,
&itd_dma); &itd_dma);
if (unlikely (0 == itd)) { if (unlikely (0 == itd)) {
......
...@@ -74,11 +74,11 @@ struct ehci_hcd { /* one per controller */ ...@@ -74,11 +74,11 @@ struct ehci_hcd { /* one per controller */
struct ehci_regs *regs; struct ehci_regs *regs;
u32 hcs_params; /* cached register copy */ u32 hcs_params; /* cached register copy */
/* per-HC memory pools (could be per-PCI-bus, but ...) */ /* per-HC memory pools (could be per-bus, but ...) */
struct pci_pool *qh_pool; /* qh per active urb */ struct dma_pool *qh_pool; /* qh per active urb */
struct pci_pool *qtd_pool; /* one or more per qh */ struct dma_pool *qtd_pool; /* one or more per qh */
struct pci_pool *itd_pool; /* itd per iso urb */ struct dma_pool *itd_pool; /* itd per iso urb */
struct pci_pool *sitd_pool; /* sitd per split iso urb */ struct dma_pool *sitd_pool; /* sitd per split iso urb */
struct timer_list watchdog; struct timer_list watchdog;
struct notifier_block reboot_notifier; struct notifier_block reboot_notifier;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
* *
* History: * History:
* *
* 2004/02/04 use generic dma_* functions instead of pci_* (dsaxena@plexity.net)
* 2003/02/24 show registers in sysfs (Kevin Brosius) * 2003/02/24 show registers in sysfs (Kevin Brosius)
* *
* 2002/09/03 get rid of ed hashtables, rework periodic scheduling and * 2002/09/03 get rid of ed hashtables, rework periodic scheduling and
...@@ -96,6 +97,8 @@ ...@@ -96,6 +97,8 @@
#include <linux/interrupt.h> /* for in_interrupt () */ #include <linux/interrupt.h> /* for in_interrupt () */
#include <linux/usb.h> #include <linux/usb.h>
#include "../core/hcd.h" #include "../core/hcd.h"
#include <linux/dma-mapping.h>
#include <linux/dmapool.h> /* needed by ohci-mem.c when no PCI */
#include <asm/io.h> #include <asm/io.h>
#include <asm/irq.h> #include <asm/irq.h>
...@@ -642,7 +645,8 @@ static void ohci_stop (struct usb_hcd *hcd) ...@@ -642,7 +645,8 @@ static void ohci_stop (struct usb_hcd *hcd)
remove_debug_files (ohci); remove_debug_files (ohci);
ohci_mem_cleanup (ohci); ohci_mem_cleanup (ohci);
if (ohci->hcca) { if (ohci->hcca) {
pci_free_consistent (ohci->hcd.pdev, sizeof *ohci->hcca, dma_free_coherent (ohci->hcd.self.controller,
sizeof *ohci->hcca,
ohci->hcca, ohci->hcca_dma); ohci->hcca, ohci->hcca_dma);
ohci->hcca = NULL; ohci->hcca = NULL;
ohci->hcca_dma = 0; ohci->hcca_dma = 0;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* There's basically three types of memory: * There's basically three types of memory:
* - data used only by the HCD ... kmalloc is fine * - data used only by the HCD ... kmalloc is fine
* - async and periodic schedules, shared by HC and HCD ... these * - async and periodic schedules, shared by HC and HCD ... these
* need to use pci_pool or pci_alloc_consistent * need to use dma_pool or dma_alloc_coherent
* - driver buffers, read/written by HC ... the hcd glue or the * - driver buffers, read/written by HC ... the hcd glue or the
* device driver provides us with dma addresses * device driver provides us with dma addresses
* *
...@@ -45,18 +45,18 @@ static void ohci_hcd_free (struct usb_hcd *hcd) ...@@ -45,18 +45,18 @@ static void ohci_hcd_free (struct usb_hcd *hcd)
static int ohci_mem_init (struct ohci_hcd *ohci) static int ohci_mem_init (struct ohci_hcd *ohci)
{ {
ohci->td_cache = pci_pool_create ("ohci_td", ohci->hcd.pdev, ohci->td_cache = dma_pool_create ("ohci_td", ohci->hcd.self.controller,
sizeof (struct td), sizeof (struct td),
32 /* byte alignment */, 32 /* byte alignment */,
0 /* no page-crossing issues */); 0 /* no page-crossing issues */);
if (!ohci->td_cache) if (!ohci->td_cache)
return -ENOMEM; return -ENOMEM;
ohci->ed_cache = pci_pool_create ("ohci_ed", ohci->hcd.pdev, ohci->ed_cache = dma_pool_create ("ohci_ed", ohci->hcd.self.controller,
sizeof (struct ed), sizeof (struct ed),
16 /* byte alignment */, 16 /* byte alignment */,
0 /* no page-crossing issues */); 0 /* no page-crossing issues */);
if (!ohci->ed_cache) { if (!ohci->ed_cache) {
pci_pool_destroy (ohci->td_cache); dma_pool_destroy (ohci->td_cache);
return -ENOMEM; return -ENOMEM;
} }
return 0; return 0;
...@@ -65,11 +65,11 @@ static int ohci_mem_init (struct ohci_hcd *ohci) ...@@ -65,11 +65,11 @@ static int ohci_mem_init (struct ohci_hcd *ohci)
static void ohci_mem_cleanup (struct ohci_hcd *ohci) static void ohci_mem_cleanup (struct ohci_hcd *ohci)
{ {
if (ohci->td_cache) { if (ohci->td_cache) {
pci_pool_destroy (ohci->td_cache); dma_pool_destroy (ohci->td_cache);
ohci->td_cache = 0; ohci->td_cache = 0;
} }
if (ohci->ed_cache) { if (ohci->ed_cache) {
pci_pool_destroy (ohci->ed_cache); dma_pool_destroy (ohci->ed_cache);
ohci->ed_cache = 0; ohci->ed_cache = 0;
} }
} }
...@@ -96,7 +96,7 @@ td_alloc (struct ohci_hcd *hc, int mem_flags) ...@@ -96,7 +96,7 @@ td_alloc (struct ohci_hcd *hc, int mem_flags)
dma_addr_t dma; dma_addr_t dma;
struct td *td; struct td *td;
td = pci_pool_alloc (hc->td_cache, mem_flags, &dma); td = dma_pool_alloc (hc->td_cache, mem_flags, &dma);
if (td) { if (td) {
/* in case hc fetches it, make it look dead */ /* in case hc fetches it, make it look dead */
memset (td, 0, sizeof *td); memset (td, 0, sizeof *td);
...@@ -118,7 +118,7 @@ td_free (struct ohci_hcd *hc, struct td *td) ...@@ -118,7 +118,7 @@ td_free (struct ohci_hcd *hc, struct td *td)
*prev = td->td_hash; *prev = td->td_hash;
else if ((td->hwINFO & TD_DONE) != 0) else if ((td->hwINFO & TD_DONE) != 0)
ohci_dbg (hc, "no hash for td %p\n", td); ohci_dbg (hc, "no hash for td %p\n", td);
pci_pool_free (hc->td_cache, td, td->td_dma); dma_pool_free (hc->td_cache, td, td->td_dma);
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -130,7 +130,7 @@ ed_alloc (struct ohci_hcd *hc, int mem_flags) ...@@ -130,7 +130,7 @@ ed_alloc (struct ohci_hcd *hc, int mem_flags)
dma_addr_t dma; dma_addr_t dma;
struct ed *ed; struct ed *ed;
ed = pci_pool_alloc (hc->ed_cache, mem_flags, &dma); ed = dma_pool_alloc (hc->ed_cache, mem_flags, &dma);
if (ed) { if (ed) {
memset (ed, 0, sizeof (*ed)); memset (ed, 0, sizeof (*ed));
INIT_LIST_HEAD (&ed->td_list); INIT_LIST_HEAD (&ed->td_list);
...@@ -142,6 +142,6 @@ ed_alloc (struct ohci_hcd *hc, int mem_flags) ...@@ -142,6 +142,6 @@ ed_alloc (struct ohci_hcd *hc, int mem_flags)
static void static void
ed_free (struct ohci_hcd *hc, struct ed *ed) ed_free (struct ohci_hcd *hc, struct ed *ed)
{ {
pci_pool_free (hc->ed_cache, ed, ed->dma); dma_pool_free (hc->ed_cache, ed, ed->dma);
} }
...@@ -388,9 +388,7 @@ int usb_hcd_omap_probe (const struct hc_driver *driver, ...@@ -388,9 +388,7 @@ int usb_hcd_omap_probe (const struct hc_driver *driver,
hcd->description = driver->description; hcd->description = driver->description;
hcd->irq = dev->irq[0]; hcd->irq = dev->irq[0];
hcd->regs = dev->mapbase; hcd->regs = dev->mapbase;
hcd->pdev = OMAP_FAKE_PCIDEV;
hcd->self.controller = &dev->dev; hcd->self.controller = &dev->dev;
hcd->controller = hcd->self.controller;
retval = hcd_buffer_create (hcd); retval = hcd_buffer_create (hcd);
if (retval != 0) { if (retval != 0) {
...@@ -494,12 +492,10 @@ ohci_omap_start (struct usb_hcd *hcd) ...@@ -494,12 +492,10 @@ ohci_omap_start (struct usb_hcd *hcd)
struct ohci_hcd *ohci = hcd_to_ohci (hcd); struct ohci_hcd *ohci = hcd_to_ohci (hcd);
int ret; int ret;
if (hcd->pdev) { ohci->hcca = dma_alloc_consistent (hcd->self.controller,
ohci->hcca = pci_alloc_consistent (hcd->pdev,
sizeof *ohci->hcca, &ohci->hcca_dma); sizeof *ohci->hcca, &ohci->hcca_dma);
if (!ohci->hcca) if (!ohci->hcca)
return -ENOMEM; return -ENOMEM;
}
memset (ohci->hcca, 0, sizeof (struct ohci_hcca)); memset (ohci->hcca, 0, sizeof (struct ohci_hcca));
if ((ret = ohci_mem_init (ohci)) < 0) { if ((ret = ohci_mem_init (ohci)) < 0) {
......
...@@ -45,17 +45,19 @@ ohci_pci_start (struct usb_hcd *hcd) ...@@ -45,17 +45,19 @@ ohci_pci_start (struct usb_hcd *hcd)
struct ohci_hcd *ohci = hcd_to_ohci (hcd); struct ohci_hcd *ohci = hcd_to_ohci (hcd);
int ret; int ret;
if (hcd->pdev) { ohci->hcca = dma_alloc_coherent (hcd->self.controller,
ohci->hcca = pci_alloc_consistent (hcd->pdev, sizeof *ohci->hcca, &ohci->hcca_dma, 0);
sizeof *ohci->hcca, &ohci->hcca_dma);
if (!ohci->hcca) if (!ohci->hcca)
return -ENOMEM; return -ENOMEM;
if(hcd->self.controller && hcd->self.controller->bus == &pci_bus_type) {
struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
/* AMD 756, for most chips (early revs), corrupts register /* AMD 756, for most chips (early revs), corrupts register
* values on read ... so enable the vendor workaround. * values on read ... so enable the vendor workaround.
*/ */
if (hcd->pdev->vendor == PCI_VENDOR_ID_AMD if (pdev->vendor == PCI_VENDOR_ID_AMD
&& hcd->pdev->device == 0x740c) { && pdev->device == 0x740c) {
ohci->flags = OHCI_QUIRK_AMD756; ohci->flags = OHCI_QUIRK_AMD756;
ohci_info (ohci, "AMD756 erratum 4 workaround\n"); ohci_info (ohci, "AMD756 erratum 4 workaround\n");
} }
...@@ -68,8 +70,8 @@ ohci_pci_start (struct usb_hcd *hcd) ...@@ -68,8 +70,8 @@ ohci_pci_start (struct usb_hcd *hcd)
* for this chip. Evidently control and bulk lists * for this chip. Evidently control and bulk lists
* can get confused. (B&W G3 models, and ...) * can get confused. (B&W G3 models, and ...)
*/ */
else if (hcd->pdev->vendor == PCI_VENDOR_ID_OPTI else if (pdev->vendor == PCI_VENDOR_ID_OPTI
&& hcd->pdev->device == 0xc861) { && pdev->device == 0xc861) {
ohci_info (ohci, ohci_info (ohci,
"WARNING: OPTi workarounds unavailable\n"); "WARNING: OPTi workarounds unavailable\n");
} }
...@@ -78,12 +80,11 @@ ohci_pci_start (struct usb_hcd *hcd) ...@@ -78,12 +80,11 @@ ohci_pci_start (struct usb_hcd *hcd)
* identify the USB (fn2). This quirk might apply to more or * identify the USB (fn2). This quirk might apply to more or
* even all NSC stuff. * even all NSC stuff.
*/ */
else if (hcd->pdev->vendor == PCI_VENDOR_ID_NS) { else if (pdev->vendor == PCI_VENDOR_ID_NS) {
struct pci_dev *b, *hc; struct pci_dev *b;
hc = hcd->pdev; b = pci_find_slot (pdev->bus->number,
b = pci_find_slot (hc->bus->number, PCI_DEVFN (PCI_SLOT (pdev->devfn), 1));
PCI_DEVFN (PCI_SLOT (hc->devfn), 1));
if (b && b->device == PCI_DEVICE_ID_NS_87560_LIO if (b && b->device == PCI_DEVICE_ID_NS_87560_LIO
&& b->vendor == PCI_VENDOR_ID_NS) { && b->vendor == PCI_VENDOR_ID_NS) {
ohci->flags |= OHCI_QUIRK_SUPERIO; ohci->flags |= OHCI_QUIRK_SUPERIO;
...@@ -145,7 +146,7 @@ static int ohci_pci_suspend (struct usb_hcd *hcd, u32 state) ...@@ -145,7 +146,7 @@ static int ohci_pci_suspend (struct usb_hcd *hcd, u32 state)
#ifdef CONFIG_PMAC_PBOOK #ifdef CONFIG_PMAC_PBOOK
if (_machine == _MACH_Pmac) if (_machine == _MACH_Pmac)
disable_irq (hcd->pdev->irq); disable_irq ((to_pci_dev(hcd->self.controller))->irq);
/* else, 2.4 assumes shared irqs -- don't disable */ /* else, 2.4 assumes shared irqs -- don't disable */
#endif #endif
...@@ -179,15 +180,17 @@ static int ohci_pci_suspend (struct usb_hcd *hcd, u32 state) ...@@ -179,15 +180,17 @@ static int ohci_pci_suspend (struct usb_hcd *hcd, u32 state)
* memory during sleep. We disable its bus master bit during * memory during sleep. We disable its bus master bit during
* suspend * suspend
*/ */
pci_read_config_word (hcd->pdev, PCI_COMMAND, &cmd); pci_read_config_word (to_pci_dev(hcd->self.controller), PCI_COMMAND,
&cmd);
cmd &= ~PCI_COMMAND_MASTER; cmd &= ~PCI_COMMAND_MASTER;
pci_write_config_word (hcd->pdev, PCI_COMMAND, cmd); pci_write_config_word (to_pci_dev(hcd->self.controller), PCI_COMMAND,
cmd);
#ifdef CONFIG_PMAC_PBOOK #ifdef CONFIG_PMAC_PBOOK
{ {
struct device_node *of_node; struct device_node *of_node;
/* Disable USB PAD & cell clock */ /* Disable USB PAD & cell clock */
of_node = pci_device_to_OF_node (hcd->pdev); of_node = pci_device_to_OF_node (to_pci_dev(hcd->self.controller));
if (of_node) if (of_node)
pmac_call_feature(PMAC_FTR_USB_ENABLE, of_node, 0, 0); pmac_call_feature(PMAC_FTR_USB_ENABLE, of_node, 0, 0);
} }
...@@ -207,7 +210,7 @@ static int ohci_pci_resume (struct usb_hcd *hcd) ...@@ -207,7 +210,7 @@ static int ohci_pci_resume (struct usb_hcd *hcd)
struct device_node *of_node; struct device_node *of_node;
/* Re-enable USB PAD & cell clock */ /* Re-enable USB PAD & cell clock */
of_node = pci_device_to_OF_node (hcd->pdev); of_node = pci_device_to_OF_node (to_pci_dev(hcd->self.controller));
if (of_node) if (of_node)
pmac_call_feature (PMAC_FTR_USB_ENABLE, of_node, 0, 1); pmac_call_feature (PMAC_FTR_USB_ENABLE, of_node, 0, 1);
} }
...@@ -222,7 +225,7 @@ static int ohci_pci_resume (struct usb_hcd *hcd) ...@@ -222,7 +225,7 @@ static int ohci_pci_resume (struct usb_hcd *hcd)
#endif #endif
/* Re-enable bus mastering */ /* Re-enable bus mastering */
pci_set_master (ohci->hcd.pdev); pci_set_master (to_pci_dev(ohci->hcd.self.controller));
switch (temp) { switch (temp) {
...@@ -282,7 +285,7 @@ static int ohci_pci_resume (struct usb_hcd *hcd) ...@@ -282,7 +285,7 @@ static int ohci_pci_resume (struct usb_hcd *hcd)
#ifdef CONFIG_PMAC_PBOOK #ifdef CONFIG_PMAC_PBOOK
if (_machine == _MACH_Pmac) if (_machine == _MACH_Pmac)
enable_irq (hcd->pdev->irq); enable_irq (to_pci_dev(hcd->self.controller)->irq);
#endif #endif
/* Check for a pending done list */ /* Check for a pending done list */
......
...@@ -375,7 +375,7 @@ static struct ed *ed_get ( ...@@ -375,7 +375,7 @@ static struct ed *ed_get (
if (!(ed = dev->ep [ep])) { if (!(ed = dev->ep [ep])) {
struct td *td; struct td *td;
ed = ed_alloc (ohci, SLAB_ATOMIC); ed = ed_alloc (ohci, GFP_ATOMIC);
if (!ed) { if (!ed) {
/* out of memory */ /* out of memory */
goto done; goto done;
...@@ -383,7 +383,7 @@ static struct ed *ed_get ( ...@@ -383,7 +383,7 @@ static struct ed *ed_get (
dev->ep [ep] = ed; dev->ep [ep] = ed;
/* dummy td; end of td list for ed */ /* dummy td; end of td list for ed */
td = td_alloc (ohci, SLAB_ATOMIC); td = td_alloc (ohci, GFP_ATOMIC);
if (!td) { if (!td) {
/* out of memory */ /* out of memory */
ed_free (ohci, ed); ed_free (ohci, ed);
......
...@@ -167,9 +167,7 @@ int usb_hcd_sa1111_probe (const struct hc_driver *driver, ...@@ -167,9 +167,7 @@ int usb_hcd_sa1111_probe (const struct hc_driver *driver,
hcd->description = driver->description; hcd->description = driver->description;
hcd->irq = dev->irq[1]; hcd->irq = dev->irq[1];
hcd->regs = dev->mapbase; hcd->regs = dev->mapbase;
hcd->pdev = SA1111_FAKE_PCIDEV;
hcd->self.controller = &dev->dev; hcd->self.controller = &dev->dev;
hcd->controller = hcd->self.controller;
retval = hcd_buffer_create (hcd); retval = hcd_buffer_create (hcd);
if (retval != 0) { if (retval != 0) {
...@@ -270,12 +268,10 @@ ohci_sa1111_start (struct usb_hcd *hcd) ...@@ -270,12 +268,10 @@ ohci_sa1111_start (struct usb_hcd *hcd)
struct ohci_hcd *ohci = hcd_to_ohci (hcd); struct ohci_hcd *ohci = hcd_to_ohci (hcd);
int ret; int ret;
if (hcd->pdev) { ohci->hcca = dma_alloc_coherent (hcd->self.controller,
ohci->hcca = pci_alloc_consistent (hcd->pdev, sizeof *ohci->hcca, &ohci->hcca_dma, 0);
sizeof *ohci->hcca, &ohci->hcca_dma);
if (!ohci->hcca) if (!ohci->hcca)
return -ENOMEM; return -ENOMEM;
}
memset (ohci->hcca, 0, sizeof (struct ohci_hcca)); memset (ohci->hcca, 0, sizeof (struct ohci_hcca));
if ((ret = ohci_mem_init (ohci)) < 0) { if ((ret = ohci_mem_init (ohci)) < 0) {
......
...@@ -361,8 +361,8 @@ struct ohci_hcd { ...@@ -361,8 +361,8 @@ struct ohci_hcd {
/* /*
* memory management for queue data structures * memory management for queue data structures
*/ */
struct pci_pool *td_cache; struct dma_pool *td_cache;
struct pci_pool *ed_cache; struct dma_pool *ed_cache;
struct td *td_hash [TD_HASH_SIZE]; struct td *td_hash [TD_HASH_SIZE];
/* /*
...@@ -391,13 +391,13 @@ struct ohci_hcd { ...@@ -391,13 +391,13 @@ struct ohci_hcd {
#endif /* DEBUG */ #endif /* DEBUG */
#define ohci_dbg(ohci, fmt, args...) \ #define ohci_dbg(ohci, fmt, args...) \
dev_dbg ((ohci)->hcd.controller , fmt , ## args ) dev_dbg ((ohci)->hcd.self.controller , fmt , ## args )
#define ohci_err(ohci, fmt, args...) \ #define ohci_err(ohci, fmt, args...) \
dev_err ((ohci)->hcd.controller , fmt , ## args ) dev_err ((ohci)->hcd.self.controller , fmt , ## args )
#define ohci_info(ohci, fmt, args...) \ #define ohci_info(ohci, fmt, args...) \
dev_info ((ohci)->hcd.controller , fmt , ## args ) dev_info ((ohci)->hcd.self.controller , fmt , ## args )
#define ohci_warn(ohci, fmt, args...) \ #define ohci_warn(ohci, fmt, args...) \
dev_warn ((ohci)->hcd.controller , fmt , ## args ) dev_warn ((ohci)->hcd.self.controller , fmt , ## args )
#ifdef OHCI_VERBOSE_DEBUG #ifdef OHCI_VERBOSE_DEBUG
# define ohci_vdbg ohci_dbg # define ohci_vdbg ohci_dbg
......
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/dmapool.h>
#include <linux/dma-mapping.h>
#ifdef CONFIG_USB_DEBUG #ifdef CONFIG_USB_DEBUG
#define DEBUG #define DEBUG
#else #else
...@@ -140,7 +142,7 @@ static struct uhci_td *uhci_alloc_td(struct uhci_hcd *uhci, struct usb_device *d ...@@ -140,7 +142,7 @@ static struct uhci_td *uhci_alloc_td(struct uhci_hcd *uhci, struct usb_device *d
dma_addr_t dma_handle; dma_addr_t dma_handle;
struct uhci_td *td; struct uhci_td *td;
td = pci_pool_alloc(uhci->td_pool, GFP_ATOMIC, &dma_handle); td = dma_pool_alloc(uhci->td_pool, GFP_ATOMIC, &dma_handle);
if (!td) if (!td)
return NULL; return NULL;
...@@ -292,7 +294,7 @@ static void uhci_free_td(struct uhci_hcd *uhci, struct uhci_td *td) ...@@ -292,7 +294,7 @@ static void uhci_free_td(struct uhci_hcd *uhci, struct uhci_td *td)
if (td->dev) if (td->dev)
usb_put_dev(td->dev); usb_put_dev(td->dev);
pci_pool_free(uhci->td_pool, td, td->dma_handle); dma_pool_free(uhci->td_pool, td, td->dma_handle);
} }
static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci, struct usb_device *dev) static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci, struct usb_device *dev)
...@@ -300,7 +302,7 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci, struct usb_device *d ...@@ -300,7 +302,7 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci, struct usb_device *d
dma_addr_t dma_handle; dma_addr_t dma_handle;
struct uhci_qh *qh; struct uhci_qh *qh;
qh = pci_pool_alloc(uhci->qh_pool, GFP_ATOMIC, &dma_handle); qh = dma_pool_alloc(uhci->qh_pool, GFP_ATOMIC, &dma_handle);
if (!qh) if (!qh)
return NULL; return NULL;
...@@ -330,7 +332,7 @@ static void uhci_free_qh(struct uhci_hcd *uhci, struct uhci_qh *qh) ...@@ -330,7 +332,7 @@ static void uhci_free_qh(struct uhci_hcd *uhci, struct uhci_qh *qh)
if (qh->dev) if (qh->dev)
usb_put_dev(qh->dev); usb_put_dev(qh->dev);
pci_pool_free(uhci->qh_pool, qh, qh->dma_handle); dma_pool_free(uhci->qh_pool, qh, qh->dma_handle);
} }
/* /*
...@@ -2013,7 +2015,8 @@ static int suspend_allowed(struct uhci_hcd *uhci) ...@@ -2013,7 +2015,8 @@ static int suspend_allowed(struct uhci_hcd *uhci)
unsigned int io_addr = uhci->io_addr; unsigned int io_addr = uhci->io_addr;
int i; int i;
if (!uhci->hcd.pdev || uhci->hcd.pdev->vendor != PCI_VENDOR_ID_INTEL) if (!uhci->hcd.self.controller ||
to_pci_dev(uhci->hcd.self.controller)->vendor != PCI_VENDOR_ID_INTEL)
return 1; return 1;
/* Some of Intel's USB controllers have a bug that causes false /* Some of Intel's USB controllers have a bug that causes false
...@@ -2127,17 +2130,17 @@ static void release_uhci(struct uhci_hcd *uhci) ...@@ -2127,17 +2130,17 @@ static void release_uhci(struct uhci_hcd *uhci)
} }
if (uhci->qh_pool) { if (uhci->qh_pool) {
pci_pool_destroy(uhci->qh_pool); dma_pool_destroy(uhci->qh_pool);
uhci->qh_pool = NULL; uhci->qh_pool = NULL;
} }
if (uhci->td_pool) { if (uhci->td_pool) {
pci_pool_destroy(uhci->td_pool); dma_pool_destroy(uhci->td_pool);
uhci->td_pool = NULL; uhci->td_pool = NULL;
} }
if (uhci->fl) { if (uhci->fl) {
pci_free_consistent(uhci->hcd.pdev, sizeof(*uhci->fl), uhci->fl, uhci->fl->dma_handle); dma_free_coherent(uhci->hcd.self.controller, sizeof(*uhci->fl), uhci->fl, uhci->fl->dma_handle);
uhci->fl = NULL; uhci->fl = NULL;
} }
...@@ -2162,7 +2165,7 @@ static int uhci_reset(struct usb_hcd *hcd) ...@@ -2162,7 +2165,7 @@ static int uhci_reset(struct usb_hcd *hcd)
* interrupts from any previous setup. * interrupts from any previous setup.
*/ */
reset_hc(uhci); reset_hc(uhci);
pci_write_config_word(hcd->pdev, USBLEGSUP, USBLEGSUP_DEFAULT); pci_write_config_word(to_pci_dev(hcd->self.controller), USBLEGSUP, USBLEGSUP_DEFAULT);
return 0; return 0;
} }
...@@ -2194,7 +2197,7 @@ static int uhci_start(struct usb_hcd *hcd) ...@@ -2194,7 +2197,7 @@ static int uhci_start(struct usb_hcd *hcd)
struct proc_dir_entry *ent; struct proc_dir_entry *ent;
#endif #endif
io_size = pci_resource_len(hcd->pdev, hcd->region); io_size = pci_resource_len(to_pci_dev(hcd->self.controller), hcd->region);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
ent = create_proc_entry(hcd->self.bus_name, S_IFREG|S_IRUGO|S_IWUSR, uhci_proc_root); ent = create_proc_entry(hcd->self.bus_name, S_IFREG|S_IRUGO|S_IWUSR, uhci_proc_root);
...@@ -2230,7 +2233,8 @@ static int uhci_start(struct usb_hcd *hcd) ...@@ -2230,7 +2233,8 @@ static int uhci_start(struct usb_hcd *hcd)
spin_lock_init(&uhci->frame_list_lock); spin_lock_init(&uhci->frame_list_lock);
uhci->fl = pci_alloc_consistent(hcd->pdev, sizeof(*uhci->fl), &dma_handle); uhci->fl = dma_alloc_coherent(hcd->self.controller,
sizeof(*uhci->fl), &dma_handle, 0);
if (!uhci->fl) { if (!uhci->fl) {
err("unable to allocate consistent memory for frame list"); err("unable to allocate consistent memory for frame list");
goto err_alloc_fl; goto err_alloc_fl;
...@@ -2240,17 +2244,17 @@ static int uhci_start(struct usb_hcd *hcd) ...@@ -2240,17 +2244,17 @@ static int uhci_start(struct usb_hcd *hcd)
uhci->fl->dma_handle = dma_handle; uhci->fl->dma_handle = dma_handle;
uhci->td_pool = pci_pool_create("uhci_td", hcd->pdev, uhci->td_pool = dma_pool_create("uhci_td", hcd->self.controller,
sizeof(struct uhci_td), 16, 0); sizeof(struct uhci_td), 16, 0);
if (!uhci->td_pool) { if (!uhci->td_pool) {
err("unable to create td pci_pool"); err("unable to create td dma_pool");
goto err_create_td_pool; goto err_create_td_pool;
} }
uhci->qh_pool = pci_pool_create("uhci_qh", hcd->pdev, uhci->qh_pool = dma_pool_create("uhci_qh", hcd->self.controller,
sizeof(struct uhci_qh), 16, 0); sizeof(struct uhci_qh), 16, 0);
if (!uhci->qh_pool) { if (!uhci->qh_pool) {
err("unable to create qh pci_pool"); err("unable to create qh dma_pool");
goto err_create_qh_pool; goto err_create_qh_pool;
} }
...@@ -2361,7 +2365,7 @@ static int uhci_start(struct usb_hcd *hcd) ...@@ -2361,7 +2365,7 @@ static int uhci_start(struct usb_hcd *hcd)
udev->speed = USB_SPEED_FULL; udev->speed = USB_SPEED_FULL;
if (usb_register_root_hub(udev, &hcd->pdev->dev) != 0) { if (usb_register_root_hub(udev, hcd->self.controller) != 0) {
err("unable to start root hub"); err("unable to start root hub");
retval = -ENOMEM; retval = -ENOMEM;
goto err_start_root_hub; goto err_start_root_hub;
...@@ -2392,15 +2396,16 @@ static int uhci_start(struct usb_hcd *hcd) ...@@ -2392,15 +2396,16 @@ static int uhci_start(struct usb_hcd *hcd)
hcd->self.root_hub = NULL; hcd->self.root_hub = NULL;
err_alloc_root_hub: err_alloc_root_hub:
pci_pool_destroy(uhci->qh_pool); dma_pool_destroy(uhci->qh_pool);
uhci->qh_pool = NULL; uhci->qh_pool = NULL;
err_create_qh_pool: err_create_qh_pool:
pci_pool_destroy(uhci->td_pool); dma_pool_destroy(uhci->td_pool);
uhci->td_pool = NULL; uhci->td_pool = NULL;
err_create_td_pool: err_create_td_pool:
pci_free_consistent(hcd->pdev, sizeof(*uhci->fl), uhci->fl, uhci->fl->dma_handle); dma_free_coherent(hcd->self.controller,
sizeof(*uhci->fl), uhci->fl, uhci->fl->dma_handle);
uhci->fl = NULL; uhci->fl = NULL;
err_alloc_fl: err_alloc_fl:
...@@ -2456,7 +2461,7 @@ static int uhci_resume(struct usb_hcd *hcd) ...@@ -2456,7 +2461,7 @@ static int uhci_resume(struct usb_hcd *hcd)
{ {
struct uhci_hcd *uhci = hcd_to_uhci(hcd); struct uhci_hcd *uhci = hcd_to_uhci(hcd);
pci_set_master(uhci->hcd.pdev); pci_set_master(to_pci_dev(uhci->hcd.self.controller));
if (uhci->state == UHCI_SUSPENDED) if (uhci->state == UHCI_SUSPENDED)
uhci->resume_detect = 1; uhci->resume_detect = 1;
......
...@@ -326,8 +326,8 @@ struct uhci_hcd { ...@@ -326,8 +326,8 @@ struct uhci_hcd {
/* Grabbed from PCI */ /* Grabbed from PCI */
unsigned long io_addr; unsigned long io_addr;
struct pci_pool *qh_pool; struct dma_pool *qh_pool;
struct pci_pool *td_pool; struct dma_pool *td_pool;
struct usb_bus *bus; struct usb_bus *bus;
......
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