Commit c13db862 authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

[PATCH] USB: ohci, remove pre-byteswapped constants

This is the first of several patches from Dale Farnsworth,
laying groundwork for a patch that supports OHCI on more
chips (IBM STB04xxx and FreeScale MPC52xx).


Replace pre-byteswapped constants for in-memory data structures in ohci.h
with cpu-native constants, to help support "big-endian OHCI" hardware.
Signed-off-by: default avatarDale Farnsworth <dale@farnsworth.org>
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 9b94c90d
......@@ -336,7 +336,7 @@ static void __attribute__((unused))
ohci_dump_ed (const struct ohci_hcd *ohci, const char *label,
const struct ed *ed, int verbose)
{
__le32 tmp = ed->hwINFO;
u32 tmp = le32_to_cpu (ed->hwINFO);
char *type = "";
ohci_dbg (ohci, "%s, ed %p state 0x%x type %s; next ed %08x\n",
......@@ -349,19 +349,20 @@ ohci_dump_ed (const struct ohci_hcd *ohci, const char *label,
/* else from TDs ... control */
}
ohci_dbg (ohci,
" info %08x MAX=%d%s%s%s%s EP=%d%s DEV=%d\n", le32_to_cpu (tmp),
0x03ff & (le32_to_cpu (tmp) >> 16),
" info %08x MAX=%d%s%s%s%s EP=%d%s DEV=%d\n", tmp,
0x03ff & (tmp >> 16),
(tmp & ED_DEQUEUE) ? " DQ" : "",
(tmp & ED_ISO) ? " ISO" : "",
(tmp & ED_SKIP) ? " SKIP" : "",
(tmp & ED_LOWSPEED) ? " LOW" : "",
0x000f & (le32_to_cpu (tmp) >> 7),
0x000f & (tmp >> 7),
type,
0x007f & le32_to_cpu (tmp));
0x007f & tmp);
tmp = le32_to_cpup (&ed->hwHeadP);
ohci_dbg (ohci, " tds: head %08x %s%s tail %08x%s\n",
le32_to_cpup (&ed->hwHeadP),
(ed->hwHeadP & ED_C) ? data1 : data0,
(ed->hwHeadP & ED_H) ? " HALT" : "",
tmp,
(tmp & ED_C) ? data1 : data0,
(tmp & ED_H) ? " HALT" : "",
le32_to_cpup (&ed->hwTailP),
verbose ? "" : " (not listing)");
if (verbose) {
......@@ -408,8 +409,8 @@ show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed)
/* dump a snapshot of the bulk or control schedule */
while (ed) {
__le32 info = ed->hwINFO;
u32 scratch = le32_to_cpup (&ed->hwINFO);
u32 info = le32_to_cpu (ed->hwINFO);
u32 headp = le32_to_cpu (ed->hwHeadP);
struct list_head *entry;
struct td *td;
......@@ -417,14 +418,14 @@ show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed)
"ed/%p %cs dev%d ep%d%s max %d %08x%s%s %s",
ed,
(info & ED_LOWSPEED) ? 'l' : 'f',
scratch & 0x7f,
(scratch >> 7) & 0xf,
info & 0x7f,
(info >> 7) & 0xf,
(info & ED_IN) ? "in" : "out",
0x03ff & (scratch >> 16),
scratch,
0x03ff & (info >> 16),
info,
(info & ED_SKIP) ? " s" : "",
(ed->hwHeadP & ED_H) ? " H" : "",
(ed->hwHeadP & ED_C) ? data1 : data0);
(headp & ED_H) ? " H" : "",
(headp & ED_C) ? data1 : data0);
size -= temp;
buf += temp;
......@@ -432,21 +433,21 @@ show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed)
u32 cbp, be;
td = list_entry (entry, struct td, td_list);
scratch = le32_to_cpup (&td->hwINFO);
info = le32_to_cpup (&td->hwINFO);
cbp = le32_to_cpup (&td->hwCBP);
be = le32_to_cpup (&td->hwBE);
temp = scnprintf (buf, size,
"\n\ttd %p %s %d cc=%x urb %p (%08x)",
td,
({ char *pid;
switch (scratch & TD_DP) {
switch (info & TD_DP) {
case TD_DP_SETUP: pid = "setup"; break;
case TD_DP_IN: pid = "in"; break;
case TD_DP_OUT: pid = "out"; break;
default: pid = "(?)"; break;
} pid;}),
cbp ? (be + 1 - cbp) : 0,
TD_CC_GET (scratch), td->urb, scratch);
TD_CC_GET (info), td->urb, info);
size -= temp;
buf += temp;
}
......@@ -534,8 +535,7 @@ show_periodic (struct class_device *class_dev, char *buf)
/* show more info the first time around */
if (temp == seen_count) {
__le32 info = ed->hwINFO;
u32 scratch = le32_to_cpup (&ed->hwINFO);
u32 info = le32_to_cpu (ed->hwINFO);
struct list_head *entry;
unsigned qlen = 0;
......@@ -547,15 +547,16 @@ show_periodic (struct class_device *class_dev, char *buf)
" (%cs dev%d ep%d%s-%s qlen %u"
" max %d %08x%s%s)",
(info & ED_LOWSPEED) ? 'l' : 'f',
scratch & 0x7f,
(scratch >> 7) & 0xf,
info & 0x7f,
(info >> 7) & 0xf,
(info & ED_IN) ? "in" : "out",
(info & ED_ISO) ? "iso" : "int",
qlen,
0x03ff & (scratch >> 16),
scratch,
0x03ff & (info >> 16),
info,
(info & ED_SKIP) ? " K" : "",
(ed->hwHeadP & ED_H) ? " H" : "");
(ed->hwHeadP & cpu_to_le32(ED_H)) ?
" H" : "");
size -= temp;
next += temp;
......
......@@ -815,7 +815,7 @@ static int ohci_restart (struct ohci_hcd *ohci)
switch (ed->state) {
case ED_OPER:
ed->state = ED_UNLINK;
ed->hwINFO |= ED_DEQUEUE;
ed->hwINFO |= cpu_to_le32(ED_DEQUEUE);
ed_deschedule (ohci, ed);
ed->ed_next = ohci->ed_rm_list;
......
......@@ -115,7 +115,7 @@ td_free (struct ohci_hcd *hc, struct td *td)
prev = &(*prev)->td_hash;
if (*prev)
*prev = td->td_hash;
else if ((td->hwINFO & TD_DONE) != 0)
else if ((td->hwINFO & cpu_to_le32(TD_DONE)) != 0)
ohci_dbg (hc, "no hash for td %p\n", td);
dma_pool_free (hc->td_cache, td, td->td_dma);
}
......
......@@ -131,7 +131,7 @@ static void periodic_link (struct ohci_hcd *ohci, struct ed *ed)
unsigned i;
ohci_vdbg (ohci, "link %sed %p branch %d [%dus.], interval %d\n",
(ed->hwINFO & ED_ISO) ? "iso " : "",
(ed->hwINFO & cpu_to_le32 (ED_ISO)) ? "iso " : "",
ed, ed->branch, ed->load, ed->interval);
for (i = ed->branch; i < NUM_INTS; i += ed->interval) {
......@@ -272,7 +272,7 @@ static void periodic_unlink (struct ohci_hcd *ohci, struct ed *ed)
hcd_to_bus (&ohci->hcd)->bandwidth_allocated -= ed->load / ed->interval;
ohci_vdbg (ohci, "unlink %sed %p branch %d [%dus.], interval %d\n",
(ed->hwINFO & ED_ISO) ? "iso " : "",
(ed->hwINFO & cpu_to_le32 (ED_ISO)) ? "iso " : "",
ed, ed->branch, ed->load, ed->interval);
}
......@@ -300,7 +300,7 @@ static void periodic_unlink (struct ohci_hcd *ohci, struct ed *ed)
*/
static void ed_deschedule (struct ohci_hcd *ohci, struct ed *ed)
{
ed->hwINFO |= ED_SKIP;
ed->hwINFO |= cpu_to_le32 (ED_SKIP);
wmb ();
ed->state = ED_UNLINK;
......@@ -427,21 +427,19 @@ static struct ed *ed_get (
*/
if (ed->state == ED_IDLE) {
u32 info;
__le32 hw_info;
info = usb_pipedevice (pipe);
info |= (ep >> 1) << 7;
info |= usb_maxpacket (udev, pipe, is_out) << 16;
hw_info = cpu_to_le32 (info);
if (udev->speed == USB_SPEED_LOW)
hw_info |= ED_LOWSPEED;
info |= ED_LOWSPEED;
/* only control transfers store pids in tds */
if (type != PIPE_CONTROL) {
hw_info |= is_out ? ED_OUT : ED_IN;
info |= is_out ? ED_OUT : ED_IN;
if (type != PIPE_BULK) {
/* periodic transfers... */
if (type == PIPE_ISOCHRONOUS)
hw_info |= ED_ISO;
info |= ED_ISO;
else if (interval > 32) /* iso can be bigger */
interval = 32;
ed->interval = interval;
......@@ -452,7 +450,7 @@ static struct ed *ed_get (
/ 1000;
}
}
ed->hwINFO = hw_info;
ed->hwINFO = cpu_to_le32(info);
}
done:
......@@ -470,7 +468,7 @@ static struct ed *ed_get (
*/
static void start_ed_unlink (struct ohci_hcd *ohci, struct ed *ed)
{
ed->hwINFO |= ED_DEQUEUE;
ed->hwINFO |= cpu_to_le32 (ED_DEQUEUE);
ed_deschedule (ohci, ed);
/* rm_list is just singly linked, for simplicity */
......@@ -594,7 +592,7 @@ static void td_submit_urb (
if (!usb_gettoggle (urb->dev, usb_pipeendpoint (urb->pipe), is_out)) {
usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe),
is_out, 1);
urb_priv->ed->hwHeadP &= ~ED_C;
urb_priv->ed->hwHeadP &= ~cpu_to_le32 (ED_C);
}
urb_priv->td_cnt = 0;
......@@ -790,14 +788,14 @@ ed_halted (struct ohci_hcd *ohci, struct td *td, int cc, struct td *rev)
struct urb *urb = td->urb;
struct ed *ed = td->ed;
struct list_head *tmp = td->td_list.next;
__le32 toggle = ed->hwHeadP & ED_C;
__le32 toggle = ed->hwHeadP & cpu_to_le32 (ED_C);
/* clear ed halt; this is the td that caused it, but keep it inactive
* until its urb->complete() has a chance to clean up.
*/
ed->hwINFO |= ED_SKIP;
ed->hwINFO |= cpu_to_le32 (ED_SKIP);
wmb ();
ed->hwHeadP &= ~ED_H;
ed->hwHeadP &= ~cpu_to_le32 (ED_H);
/* put any later tds from this urb onto the donelist, after 'td',
* order won't matter here: no errors, and nothing was transferred.
......@@ -889,7 +887,8 @@ static struct td *dl_reverse_done_list (struct ohci_hcd *ohci)
* and dequeue any other TDs from this urb.
* No other TD could have caused the halt.
*/
if (cc != TD_CC_NOERROR && (td->ed->hwHeadP & ED_H))
if (cc != TD_CC_NOERROR
&& (td->ed->hwHeadP & cpu_to_le32 (ED_H)))
td_rev = ed_halted (ohci, td, cc, td_rev);
td->next_dl_td = td_rev;
......@@ -990,10 +989,10 @@ finish_unlinks (struct ohci_hcd *ohci, u16 tick, struct pt_regs *regs)
/* ED's now officially unlinked, hc doesn't see */
ed->state = ED_IDLE;
ed->hwHeadP &= ~ED_H;
ed->hwHeadP &= ~cpu_to_le32(ED_H);
ed->hwNextED = 0;
wmb ();
ed->hwINFO &= ~(ED_SKIP | ED_DEQUEUE);
ed->hwINFO &= ~cpu_to_le32 (ED_SKIP | ED_DEQUEUE);
/* but if there's work queued, reschedule */
if (!list_empty (&ed->td_list)) {
......@@ -1072,10 +1071,11 @@ dl_done_list (struct ohci_hcd *ohci, struct pt_regs *regs)
start_ed_unlink (ohci, ed);
/* ... reenabling halted EDs only after fault cleanup */
} else if ((ed->hwINFO & (ED_SKIP | ED_DEQUEUE)) == ED_SKIP) {
} else if ((ed->hwINFO & cpu_to_le32 (ED_SKIP | ED_DEQUEUE))
== cpu_to_le32 (ED_SKIP)) {
td = list_entry (ed->td_list.next, struct td, td_list);
if (!(td->hwINFO & TD_DONE)) {
ed->hwINFO &= ~ED_SKIP;
if (!(td->hwINFO & cpu_to_le32 (TD_DONE))) {
ed->hwINFO &= ~cpu_to_le32 (ED_SKIP);
/* ... hc may need waking-up */
switch (ed->type) {
case PIPE_CONTROL:
......
......@@ -18,17 +18,17 @@ struct ed {
/* first fields are hardware-specified, le32 */
__le32 hwINFO; /* endpoint config bitmap */
/* info bits defined by hcd */
#define ED_DEQUEUE __constant_cpu_to_le32(1 << 27)
#define ED_DEQUEUE (1 << 27)
/* info bits defined by the hardware */
#define ED_ISO __constant_cpu_to_le32(1 << 15)
#define ED_SKIP __constant_cpu_to_le32(1 << 14)
#define ED_LOWSPEED __constant_cpu_to_le32(1 << 13)
#define ED_OUT __constant_cpu_to_le32(0x01 << 11)
#define ED_IN __constant_cpu_to_le32(0x02 << 11)
#define ED_ISO (1 << 15)
#define ED_SKIP (1 << 14)
#define ED_LOWSPEED (1 << 13)
#define ED_OUT (0x01 << 11)
#define ED_IN (0x02 << 11)
__le32 hwTailP; /* tail of TD list */
__le32 hwHeadP; /* head of TD list (hc r/w) */
#define ED_C __constant_cpu_to_le32(0x02) /* toggle carry */
#define ED_H __constant_cpu_to_le32(0x01) /* halted */
#define ED_C (0x02) /* toggle carry */
#define ED_H (0x01) /* halted */
__le32 hwNextED; /* next ED in list */
/* rest are purely for the driver's use */
......
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