]> err.no Git - linux-2.6/commitdiff
drivers/usb annotations and fixes
authorAl Viro <viro@ftp.linux.org.uk>
Mon, 28 Apr 2008 06:00:16 +0000 (07:00 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 28 Apr 2008 17:03:31 +0000 (10:03 -0700)
* endianness annotations
* endianness fixes
* missing get_unaligned/put_unaligned

It's pretty much all over the place, changes to different files are independent.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Serial-parts-Acked-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
18 files changed:
drivers/usb/atm/cxacru.c
drivers/usb/atm/ueagle-atm.c
drivers/usb/gadget/amd5536udc.c
drivers/usb/gadget/dummy_hcd.c
drivers/usb/gadget/gmidi.c
drivers/usb/gadget/m66592-udc.h
drivers/usb/host/ehci-dbg.c
drivers/usb/host/ehci-hub.c
drivers/usb/host/ehci-q.c
drivers/usb/host/r8a66597-hcd.c
drivers/usb/host/sl811-hcd.c
drivers/usb/serial/aircable.c
drivers/usb/serial/cypress_m8.c
drivers/usb/serial/ftdi_sio.c
drivers/usb/serial/io_edgeport.c
drivers/usb/serial/kl5kusb105.c
drivers/usb/serial/oti6858.c
drivers/usb/serial/spcp8x5.c

index d470c72b737e5295f875ff1433cdfce8c7f5111f..5ea3093bc40f0ddea25b87252c1ef61a4f7ff878 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/device.h>
 #include <linux/firmware.h>
 #include <linux/mutex.h>
+#include <asm/unaligned.h>
 
 #include "usbatm.h"
 
@@ -573,7 +574,7 @@ static int cxacru_cm_get_array(struct cxacru_data *instance, enum cxacru_cm_requ
                               u32 *data, int size)
 {
        int ret, len;
-       u32 *buf;
+       __le32 *buf;
        int offb, offd;
        const int stride = CMD_PACKET_SIZE / (4 * 2) - 1;
        int buflen =  ((size - 1) / stride + 1 + size * 2) * 4;
@@ -837,7 +838,7 @@ static int cxacru_fw(struct usb_device *usb_dev, enum cxacru_fw_request fw,
                buf[offb++] = l;
                buf[offb++] = code1;
                buf[offb++] = code2;
-               *((u32 *) (buf + offb)) = cpu_to_le32(addr);
+               put_unaligned(cpu_to_le32(addr), (__le32 *)(buf + offb));
                offb += 4;
                addr += l;
                if(l)
@@ -874,8 +875,9 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
        int off;
        struct usbatm_data *usbatm = instance->usbatm;
        struct usb_device *usb_dev = usbatm->usb_dev;
-       u16 signature[] = { usb_dev->descriptor.idVendor, usb_dev->descriptor.idProduct };
-       u32 val;
+       __le16 signature[] = { usb_dev->descriptor.idVendor,
+                              usb_dev->descriptor.idProduct };
+       __le32 val;
 
        dbg("cxacru_upload_firmware");
 
@@ -955,7 +957,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
        /* Load config data (le32), doing one packet at a time */
        if (cf)
                for (off = 0; off < cf->size / 4; ) {
-                       u32 buf[CMD_PACKET_SIZE / 4 - 1];
+                       __le32 buf[CMD_PACKET_SIZE / 4 - 1];
                        int i, len = min_t(int, cf->size / 4 - off, CMD_PACKET_SIZE / 4 / 2 - 1);
                        buf[0] = cpu_to_le32(len);
                        for (i = 0; i < len; i++, off++) {
index abb7d7410e63c7588898300c362307341ba9c116..4220f22b66603f9f285915dc659bb73ce8ff9abb 100644 (file)
@@ -996,7 +996,7 @@ static void __uea_load_page_e4(struct uea_softc *sc, u8 pageno, int boot)
                blockoffset = sc->dsp_firm->data + le32_to_cpu(blockidx->PageOffset);
 
                bi.dwSize = cpu_to_be32(blocksize);
-               bi.dwAddress = swab32(blockidx->PageAddress);
+               bi.dwAddress = cpu_to_be32(le32_to_cpu(blockidx->PageAddress));
 
                uea_dbg(INS_TO_USBDEV(sc),
                       "sending block %u for DSP page %u size %u address %x\n",
@@ -1040,7 +1040,7 @@ static void uea_load_page_e4(struct work_struct *work)
                return;
 
        p = (struct l1_code *) sc->dsp_firm->data;
-       if (pageno >= p->page_header[0].PageNumber) {
+       if (pageno >= le16_to_cpu(p->page_header[0].PageNumber)) {
                uea_err(INS_TO_USBDEV(sc), "invalid DSP page %u requested\n", pageno);
                return;
        }
@@ -1065,7 +1065,7 @@ static void uea_load_page_e4(struct work_struct *work)
        bi.bPageNumber = 0xff;
        bi.wReserved = cpu_to_be16(UEA_RESERVED);
        bi.dwSize = cpu_to_be32(E4_PAGE_BYTES(p->page_header[0].PageSize));
-       bi.dwAddress = swab32(p->page_header[0].PageAddress);
+       bi.dwAddress = cpu_to_be32(le32_to_cpu(p->page_header[0].PageAddress));
 
        /* send block info through the IDMA pipe */
        if (uea_idma_write(sc, &bi, E4_BLOCK_INFO_SIZE))
index fc6f3483be4473c25e21620a8be1a84bb5e9ea79..ce337cb5d13706a763b42193adf872efe38b309b 100644 (file)
@@ -328,6 +328,7 @@ udc_ep_enable(struct usb_ep *usbep, const struct usb_endpoint_descriptor *desc)
        u32                     tmp;
        unsigned long           iflags;
        u8 udc_csr_epix;
+       unsigned                maxpacket;
 
        if (!usbep
                        || usbep->name == ep0_string
@@ -354,9 +355,10 @@ udc_ep_enable(struct usb_ep *usbep, const struct usb_endpoint_descriptor *desc)
        writel(tmp, &dev->ep[ep->num].regs->ctl);
 
        /* set max packet size */
+       maxpacket = le16_to_cpu(desc->wMaxPacketSize);
        tmp = readl(&dev->ep[ep->num].regs->bufout_maxpkt);
-       tmp = AMD_ADDBITS(tmp, desc->wMaxPacketSize, UDC_EP_MAX_PKT_SIZE);
-       ep->ep.maxpacket = desc->wMaxPacketSize;
+       tmp = AMD_ADDBITS(tmp, maxpacket, UDC_EP_MAX_PKT_SIZE);
+       ep->ep.maxpacket = maxpacket;
        writel(tmp, &dev->ep[ep->num].regs->bufout_maxpkt);
 
        /* IN ep */
@@ -370,8 +372,8 @@ udc_ep_enable(struct usb_ep *usbep, const struct usb_endpoint_descriptor *desc)
                /* double buffering: fifo size = 2 x max packet size */
                tmp = AMD_ADDBITS(
                                tmp,
-                               desc->wMaxPacketSize * UDC_EPIN_BUFF_SIZE_MULT
-                                               / UDC_DWORD_BYTES,
+                               maxpacket * UDC_EPIN_BUFF_SIZE_MULT
+                                         / UDC_DWORD_BYTES,
                                UDC_EPIN_BUFF_SIZE);
                writel(tmp, &dev->ep[ep->num].regs->bufin_framenum);
 
@@ -390,7 +392,7 @@ udc_ep_enable(struct usb_ep *usbep, const struct usb_endpoint_descriptor *desc)
 
                /* set max packet size UDC CSR  */
                tmp = readl(&dev->csr->ne[ep->num - UDC_CSR_EP_OUT_IX_OFS]);
-               tmp = AMD_ADDBITS(tmp, desc->wMaxPacketSize,
+               tmp = AMD_ADDBITS(tmp, maxpacket,
                                        UDC_CSR_NE_MAX_PKT);
                writel(tmp, &dev->csr->ne[ep->num - UDC_CSR_EP_OUT_IX_OFS]);
 
@@ -407,7 +409,7 @@ udc_ep_enable(struct usb_ep *usbep, const struct usb_endpoint_descriptor *desc)
        /* set ep values */
        tmp = readl(&dev->csr->ne[udc_csr_epix]);
        /* max packet */
-       tmp = AMD_ADDBITS(tmp, desc->wMaxPacketSize, UDC_CSR_NE_MAX_PKT);
+       tmp = AMD_ADDBITS(tmp, maxpacket, UDC_CSR_NE_MAX_PKT);
        /* ep number */
        tmp = AMD_ADDBITS(tmp, desc->bEndpointAddress, UDC_CSR_NE_NUM);
        /* ep direction */
@@ -2832,7 +2834,7 @@ __acquires(dev->lock)
                /* make usb request for gadget driver */
                memset(&setup_data, 0 , sizeof(union udc_setup_data));
                setup_data.request.bRequest = USB_REQ_SET_CONFIGURATION;
-               setup_data.request.wValue = dev->cur_config;
+               setup_data.request.wValue = cpu_to_le16(dev->cur_config);
 
                /* programm the NE registers */
                for (i = 0; i < UDC_EP_NUM; i++) {
@@ -2881,8 +2883,8 @@ __acquires(dev->lock)
                memset(&setup_data, 0 , sizeof(union udc_setup_data));
                setup_data.request.bRequest = USB_REQ_SET_INTERFACE;
                setup_data.request.bRequestType = USB_RECIP_INTERFACE;
-               setup_data.request.wValue = dev->cur_alt;
-               setup_data.request.wIndex = dev->cur_intf;
+               setup_data.request.wValue = cpu_to_le16(dev->cur_alt);
+               setup_data.request.wIndex = cpu_to_le16(dev->cur_intf);
 
                DBG(dev, "SET_INTERFACE interrupt: alt=%d intf=%d\n",
                                dev->cur_alt, dev->cur_intf);
index 66293105d136646d3e739ef330cde96ff112cec3..42036192a03c4cc4abb61078b591dfcac1da1a70 100644 (file)
@@ -1555,8 +1555,7 @@ hub_descriptor (struct usb_hub_descriptor *desc)
        memset (desc, 0, sizeof *desc);
        desc->bDescriptorType = 0x29;
        desc->bDescLength = 9;
-       desc->wHubCharacteristics = (__force __u16)
-                       (__constant_cpu_to_le16 (0x0001));
+       desc->wHubCharacteristics = cpu_to_le16(0x0001);
        desc->bNbrPorts = 1;
        desc->bitmap [0] = 0xff;
        desc->bitmap [1] = 0xff;
index ff3a8513e64dbbcdc8d15f5d944693317acdb459..7f4d4828e3aabaca7db67bd512017f094b419992 100644 (file)
@@ -229,7 +229,7 @@ static const struct usb_ac_header_descriptor_1 ac_header_desc = {
        .bDescriptorType =      USB_DT_CS_INTERFACE,
        .bDescriptorSubtype =   USB_MS_HEADER,
        .bcdADC =               __constant_cpu_to_le16(0x0100),
-       .wTotalLength =         USB_DT_AC_HEADER_SIZE(1),
+       .wTotalLength =         __constant_cpu_to_le16(USB_DT_AC_HEADER_SIZE(1)),
        .bInCollection =        1,
        .baInterfaceNr = {
                [0] =           GMIDI_MS_INTERFACE,
@@ -253,9 +253,9 @@ static const struct usb_ms_header_descriptor ms_header_desc = {
        .bDescriptorType =      USB_DT_CS_INTERFACE,
        .bDescriptorSubtype =   USB_MS_HEADER,
        .bcdMSC =               __constant_cpu_to_le16(0x0100),
-       .wTotalLength =         USB_DT_MS_HEADER_SIZE
+       .wTotalLength =         __constant_cpu_to_le16(USB_DT_MS_HEADER_SIZE
                                + 2*USB_DT_MIDI_IN_SIZE
-                               + 2*USB_DT_MIDI_OUT_SIZE(1),
+                               + 2*USB_DT_MIDI_OUT_SIZE(1)),
 };
 
 #define JACK_IN_EMB    1
index be0a4c1f80a2d66fa8c26ed66f9aacc81093e811..f118f00f14662e4b884671cb4f4084be4e56cc48 100644 (file)
@@ -485,7 +485,7 @@ struct m66592 {
        struct m66592_ep        *epaddr2ep[16];
 
        struct usb_request      *ep0_req;       /* for internal request */
-       u16                     ep0_data;       /* for internal request */
+       __le16                  ep0_data;       /* for internal request */
        u16                     old_vbus;
 
        struct timer_list       timer;
index 4af90df8e7dec7e2aa3ea96a88b8de05de1a9f12..0f82fdcaef096b65e384ab07312e7e001d211a56 100644 (file)
@@ -398,7 +398,7 @@ static void qh_lines (
        unsigned                size = *sizep;
        char                    *next = *nextp;
        char                    mark;
-       u32                     list_end = EHCI_LIST_END(ehci);
+       __le32                  list_end = EHCI_LIST_END(ehci);
 
        if (qh->hw_qtd_next == list_end)        /* NEC does this */
                mark = '@';
index efffef64f59daf68ecc80d571921cbb10f8a566e..f13d1029aeb2000fc814b4bc3e3c1db49ee9259f 100644 (file)
@@ -530,7 +530,7 @@ ehci_hub_descriptor (
        if (HCS_INDICATOR (ehci->hcs_params))
                temp |= 0x0080;         /* per-port indicators (LEDs) */
 #endif
-       desc->wHubCharacteristics = (__force __u16)cpu_to_le16 (temp);
+       desc->wHubCharacteristics = cpu_to_le16(temp);
 }
 
 /*-------------------------------------------------------------------------*/
index 5ae689139dd08f8a92bd21e65439a9943cc540f6..b85b54160cdaeade20792ad9878d9751606f3b50 100644 (file)
@@ -285,7 +285,7 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
        int                     stopped;
        unsigned                count = 0;
        u8                      state;
-       u32                     halt = HALT_BIT(ehci);
+       __le32                  halt = HALT_BIT(ehci);
 
        if (unlikely (list_empty (&qh->qtd_list)))
                return count;
@@ -883,7 +883,7 @@ static struct ehci_qh *qh_append_tds (
 )
 {
        struct ehci_qh          *qh = NULL;
-       u32                     qh_addr_mask = cpu_to_hc32(ehci, 0x7f);
+       __hc32                  qh_addr_mask = cpu_to_hc32(ehci, 0x7f);
 
        qh = (struct ehci_qh *) *ptr;
        if (unlikely (qh == NULL)) {
index f4fa93dabdde99d77d3e632876b4d22ba5c80a83..16667342b3c324f694300c54d3d3532674c417c5 100644 (file)
@@ -993,7 +993,7 @@ static void prepare_setup_packet(struct r8a66597 *r8a66597,
                                 struct r8a66597_td *td)
 {
        int i;
-       u16 *p = (u16 *)td->urb->setup_packet;
+       __le16 *p = (__le16 *)td->urb->setup_packet;
        unsigned long setup_addr = USBREQ;
 
        r8a66597_write(r8a66597, make_devsel(td->address) | td->maxpacket,
@@ -1001,7 +1001,7 @@ static void prepare_setup_packet(struct r8a66597 *r8a66597,
        r8a66597_write(r8a66597, ~(SIGN | SACK), INTSTS1);
 
        for (i = 0; i < 4; i++) {
-               r8a66597_write(r8a66597, cpu_to_le16(p[i]), setup_addr);
+               r8a66597_write(r8a66597, le16_to_cpu(p[i]), setup_addr);
                setup_addr += 2;
        }
        r8a66597_write(r8a66597, SUREQ, DCPCTR);
@@ -2131,7 +2131,7 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
        case GetPortStatus:
                if (wIndex > R8A66597_MAX_ROOT_HUB)
                        goto error;
-               *(u32 *)buf = cpu_to_le32(rh->port);
+               *(__le32 *)buf = cpu_to_le32(rh->port);
                break;
        case SetPortFeature:
                if (wIndex > R8A66597_MAX_ROOT_HUB)
index 274276cf8621664394bd7e9597d5c9c014695b18..3fd7a0c120787789dd385b10a9db004c08af2ab6 100644 (file)
@@ -1100,7 +1100,7 @@ sl811h_hub_descriptor (
        /* no overcurrent errors detection/handling */
        temp |= 0x0010;
 
-       desc->wHubCharacteristics = (__force __u16)cpu_to_le16(temp);
+       desc->wHubCharacteristics = cpu_to_le16(temp);
 
        /* two bitmaps:  ports removable, and legacy PortPwrCtrlMask */
        desc->bitmap[0] = 0 << 1;
index a238817762adad0c448903e90f7267233739015c..9b1bb347dc2d7e0b1865c4f36191118b207e5dde 100644 (file)
@@ -209,7 +209,7 @@ static void aircable_send(struct usb_serial_port *port)
        int count, result;
        struct aircable_private *priv = usb_get_serial_port_data(port);
        unsigned char* buf;
-       u16 *dbuf;
+       __le16 *dbuf;
        dbg("%s - port %d", __func__, port->number);
        if (port->write_urb_busy)
                return;
@@ -227,7 +227,7 @@ static void aircable_send(struct usb_serial_port *port)
 
        buf[0] = TX_HEADER_0;
        buf[1] = TX_HEADER_1;
-       dbuf = (u16 *)&buf[2];
+       dbuf = (__le16 *)&buf[2];
        *dbuf = cpu_to_le16((u16)count);
        serial_buf_get(priv->tx_buf,buf + HCI_HEADER_LENGTH, MAX_HCI_FRAMESIZE);
 
index 32121794808dd5f964ca61143503bc92b6b5b016..0230d3c0888af92e816d2d432f60a7171c4f547d 100644 (file)
@@ -541,7 +541,7 @@ static int cypress_earthmate_startup (struct usb_serial *serial)
        /* All Earthmate devices use the separated-count packet
           format!  Idiotic. */
        priv->pkt_fmt = packet_format_1;
-       if (serial->dev->descriptor.idProduct != PRODUCT_ID_EARTHMATEUSB) {
+       if (serial->dev->descriptor.idProduct != cpu_to_le16(PRODUCT_ID_EARTHMATEUSB)) {
                /* The old original USB Earthmate seemed able to
                   handle GET_CONFIG requests; everything they've
                   produced since that time crashes if this command is
index 23f51a41093ec7e6215aae4228badd3bfa3f7d48..c7329f43d9c9dc885fd65cb21ed80b29b4938162 100644 (file)
@@ -1104,7 +1104,7 @@ static int ftdi_mtxorb_hack_setup(struct usb_serial *serial)
        struct usb_endpoint_descriptor *ep_desc = &ep->desc;
 
        if (ep->enabled && ep_desc->wMaxPacketSize == 0) {
-               ep_desc->wMaxPacketSize = 0x40;
+               ep_desc->wMaxPacketSize = cpu_to_le16(0x40);
                info("Fixing invalid wMaxPacketSize on read pipe");
        }
 
index ce2e487f324042df2bc36904c6a48ffa55c8d4bb..06b52f4098f11e407325ee3b8288002c7cacaef4 100644 (file)
@@ -2993,7 +2993,7 @@ static int edge_startup (struct usb_serial *serial)
                                usb_fill_bulk_urb(edge_serial->read_urb, dev,
                                                  usb_rcvbulkpipe(dev, endpoint->bEndpointAddress),
                                                  edge_serial->bulk_in_buffer,
-                                                 endpoint->wMaxPacketSize,
+                                                 le16_to_cpu(endpoint->wMaxPacketSize),
                                                  edge_bulk_in_callback,
                                                  edge_serial);
                                bulk_in_found = true;
index b395ac7598883a985e94cf485b22d27cf2fac97e..f328948d74e3dfc9cf21439333ef48140eff1af9 100644 (file)
@@ -54,6 +54,7 @@
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <asm/uaccess.h>
+#include <asm/unaligned.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 #include "kl5kusb105.h"
@@ -235,7 +236,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
        if (rc < 0)
                err("Reading line status failed (error = %d)", rc);
        else {
-               status = le16_to_cpu(*(u16 *)status_buf);
+               status = le16_to_cpu(get_unaligned((__le16 *)status_buf));
 
                info("%s - read status %x %x", __func__,
                     status_buf[0], status_buf[1]);
index d92bb6501c8443d2963054c1472dee893c4565db..a9625c180dc3502206d2d967224a1d6ea31d2bf5 100644 (file)
@@ -98,7 +98,7 @@ struct oti6858_buf {
 
 /* format of the control packet */
 struct oti6858_control_pkt {
-       u16     divisor;        /* baud rate = 96000000 / (16 * divisor), LE */
+       __le16  divisor;        /* baud rate = 96000000 / (16 * divisor), LE */
 #define OTI6858_MAX_BAUD_RATE  3000000
        u8      frame_fmt;
 #define FMT_STOP_BITS_MASK     0xc0
@@ -211,7 +211,7 @@ struct oti6858_private {
        struct delayed_work delayed_write_work;
 
        struct {
-               u16 divisor;
+               __le16 divisor;
                u8 frame_fmt;
                u8 control;
        } pending_setup;
@@ -450,7 +450,7 @@ static void oti6858_set_termios(struct usb_serial_port *port,
        unsigned long flags;
        unsigned int cflag;
        u8 frame_fmt, control;
-       u16 divisor;
+       __le16 divisor;
        int br;
 
        dbg("%s(port = %d)", __func__, port->number);
@@ -505,11 +505,12 @@ static void oti6858_set_termios(struct usb_serial_port *port,
                divisor = 0;
        } else {
                int real_br;
+               int new_divisor;
                br = min(br, OTI6858_MAX_BAUD_RATE);
 
-               divisor = (96000000 + 8 * br) / (16 * br);
-               real_br = 96000000 / (16 * divisor);
-               divisor = cpu_to_le16(divisor);
+               new_divisor = (96000000 + 8 * br) / (16 * br);
+               real_br = 96000000 / (16 * new_divisor);
+               divisor = cpu_to_le16(new_divisor);
                tty_encode_baud_rate(port->tty, real_br, real_br);
        }
 
index 2282d620186e2122fadbb0bf1c9bbed1a52ac6f7..55b2570b8b8b568ad0e694ed575d8153ed4333f6 100644 (file)
@@ -310,17 +310,18 @@ static int spcp8x5_startup(struct usb_serial *serial)
        struct spcp8x5_private *priv;
        int i;
        enum spcp8x5_type type = SPCP825_007_TYPE;
+       u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
 
-       if (serial->dev->descriptor.idProduct == 0x0201)
+       if (product == 0x0201)
                type = SPCP825_007_TYPE;
-       else if (serial->dev->descriptor.idProduct == 0x0231)
+       else if (product == 0x0231)
                type = SPCP835_TYPE;
-       else if (serial->dev->descriptor.idProduct == 0x0235)
+       else if (product == 0x0235)
                type = SPCP825_008_TYPE;
-       else if (serial->dev->descriptor.idProduct == 0x0204)
+       else if (product == 0x0204)
                type = SPCP825_INTERMATIC_TYPE;
-       else if (serial->dev->descriptor.idProduct == 0x0471 &&
-                serial->dev->descriptor.idVendor == 0x081e)
+       else if (product == 0x0471 &&
+                serial->dev->descriptor.idVendor == cpu_to_le16(0x081e))
                type = SPCP825_PHILIP_TYPE;
        dev_dbg(&serial->dev->dev, "device type = %d\n", (int)type);