Patch 1 of 3.

Replace little-endian-only constants in ohci.h with cpu-native
constants, so that they can be converted to little-endian or big-endian
depending on the OHCI controller being used.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>

diff -Nru a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
--- a/drivers/usb/host/ohci-dbg.c       2004-10-11 16:35:30 -07:00
+++ b/drivers/usb/host/ohci-dbg.c       2004-10-11 16:35:30 -07:00
@@ -336,7 +336,7 @@
 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 @@
        /* 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) {
@@ -415,8 +416,8 @@
 
        /* 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;
 
@@ -424,14 +425,14 @@
                        "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;
 
@@ -439,21 +440,21 @@
                        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;
                }
@@ -541,8 +542,7 @@
 
                        /* 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;
 
@@ -554,15 +554,16 @@
                                        " (%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;
 
diff -Nru a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
--- a/drivers/usb/host/ohci-hcd.c       2004-10-11 16:35:30 -07:00
+++ b/drivers/usb/host/ohci-hcd.c       2004-10-11 16:35:30 -07:00
@@ -731,7 +731,7 @@
                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;
diff -Nru a/drivers/usb/host/ohci-mem.c b/drivers/usb/host/ohci-mem.c
--- a/drivers/usb/host/ohci-mem.c       2004-10-11 16:35:30 -07:00
+++ b/drivers/usb/host/ohci-mem.c       2004-10-11 16:35:30 -07:00
@@ -120,7 +120,7 @@
                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);
 }
diff -Nru a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
--- a/drivers/usb/host/ohci-q.c 2004-10-11 16:35:30 -07:00
+++ b/drivers/usb/host/ohci-q.c 2004-10-11 16:35:30 -07:00
@@ -131,7 +131,7 @@
        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 @@
        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 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 @@
         */
        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 @@
                                                / 1000;
                        }
                }
-               ed->hwINFO = hw_info;
+               ed->hwINFO = cpu_to_le32(info);
        }
 
 done:
@@ -470,7 +468,7 @@
  */
 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 @@
        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 @@
        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 @@
                 * 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 @@
 
                /* 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,10 @@
                                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:
diff -Nru a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h
--- a/drivers/usb/host/ohci.h   2004-10-11 16:35:30 -07:00
+++ b/drivers/usb/host/ohci.h   2004-10-11 16:35:30 -07:00
@@ -15,20 +15,20 @@
  * both EHCI and UHCI call similar structures a "QH".
  */
 struct ed {
-       /* first fields are hardware-specified, le32 */
+       /* first fields are hardware-specified */
        __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 */
@@ -70,7 +70,7 @@
  * and 4.3.2 (iso)
  */
 struct td {
-       /* first fields are hardware-specified, le32 */
+       /* first fields are hardware-specified */
        __le32          hwINFO;         /* transfer info bitmask */
 
        /* hwINFO bits for both general and iso tds: */


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to