]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/usb/atm/cxacru.c
Merge branch 'generic-ipi' into generic-ipi-for-linus
[linux-2.6-omap-h63xx.git] / drivers / usb / atm / cxacru.c
index a73e714288e51fa11dbfb86cc71e71039e3f4ae1..90583d6a59492b1922c4688d6379afaadea608f9 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"
 
@@ -444,7 +445,7 @@ CXACRU_ALL_FILES(INIT);
 /* the following three functions are stolen from drivers/usb/core/message.c */
 static void cxacru_blocking_completion(struct urb *urb)
 {
-       complete((struct completion *)urb->context);
+       complete(urb->context);
 }
 
 static void cxacru_timeout_kill(unsigned long data)
@@ -482,7 +483,9 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
        int rbuflen = ((rsize - 1) / stride + 1) * CMD_PACKET_SIZE;
 
        if (wbuflen > PAGE_SIZE || rbuflen > PAGE_SIZE) {
-               dbg("too big transfer requested");
+               if (printk_ratelimit())
+                       usb_err(instance->usbatm, "requested transfer size too large (%d, %d)\n",
+                               wbuflen, rbuflen);
                ret = -ENOMEM;
                goto fail;
        }
@@ -493,8 +496,9 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
        init_completion(&instance->rcv_done);
        ret = usb_submit_urb(instance->rcv_urb, GFP_KERNEL);
        if (ret < 0) {
-               dbg("submitting read urb for cm %#x failed", cm);
-               ret = ret;
+               if (printk_ratelimit())
+                       usb_err(instance->usbatm, "submit of read urb for cm %#x failed (%d)\n",
+                               cm, ret);
                goto fail;
        }
 
@@ -510,27 +514,29 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
        init_completion(&instance->snd_done);
        ret = usb_submit_urb(instance->snd_urb, GFP_KERNEL);
        if (ret < 0) {
-               dbg("submitting write urb for cm %#x failed", cm);
-               ret = ret;
+               if (printk_ratelimit())
+                       usb_err(instance->usbatm, "submit of write urb for cm %#x failed (%d)\n",
+                               cm, ret);
                goto fail;
        }
 
        ret = cxacru_start_wait_urb(instance->snd_urb, &instance->snd_done, NULL);
        if (ret < 0) {
-               dbg("sending cm %#x failed", cm);
-               ret = ret;
+               if (printk_ratelimit())
+                       usb_err(instance->usbatm, "send of cm %#x failed (%d)\n", cm, ret);
                goto fail;
        }
 
        ret = cxacru_start_wait_urb(instance->rcv_urb, &instance->rcv_done, &actlen);
        if (ret < 0) {
-               dbg("receiving cm %#x failed", cm);
-               ret = ret;
+               if (printk_ratelimit())
+                       usb_err(instance->usbatm, "receive of cm %#x failed (%d)\n", cm, ret);
                goto fail;
        }
        if (actlen % CMD_PACKET_SIZE || !actlen) {
-               dbg("response is not a positive multiple of %d: %#x",
-                               CMD_PACKET_SIZE, actlen);
+               if (printk_ratelimit())
+                       usb_err(instance->usbatm, "invalid response length to cm %#x: %d\n",
+                               cm, actlen);
                ret = -EIO;
                goto fail;
        }
@@ -538,12 +544,16 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
        /* check the return status and copy the data to the output buffer, if needed */
        for (offb = offd = 0; offd < rsize && offb < actlen; offb += CMD_PACKET_SIZE) {
                if (rbuf[offb] != cm) {
-                       dbg("wrong cm %#x in response", rbuf[offb]);
+                       if (printk_ratelimit())
+                               usb_err(instance->usbatm, "wrong cm %#x in response to cm %#x\n",
+                                       rbuf[offb], cm);
                        ret = -EIO;
                        goto fail;
                }
                if (rbuf[offb + 1] != CM_STATUS_SUCCESS) {
-                       dbg("response failed: %#x", rbuf[offb + 1]);
+                       if (printk_ratelimit())
+                               usb_err(instance->usbatm, "response to cm %#x failed: %#x\n",
+                                       cm, rbuf[offb + 1]);
                        ret = -EIO;
                        goto fail;
                }
@@ -564,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;
@@ -582,14 +592,18 @@ static int cxacru_cm_get_array(struct cxacru_data *instance, enum cxacru_cm_requ
        for (offb = 0; offb < len; ) {
                int l = le32_to_cpu(buf[offb++]);
                if (l > stride || l > (len - offb) / 2) {
-                       dbg("wrong data length %#x in response", l);
+                       if (printk_ratelimit())
+                               usb_err(instance->usbatm, "invalid data length from cm %#x: %d\n",
+                                       cm, l);
                        ret = -EIO;
                        goto cleanup;
                }
                while (l--) {
                        offd = le32_to_cpu(buf[offb++]);
                        if (offd >= size) {
-                               dbg("wrong index %#x in response", offd);
+                               if (printk_ratelimit())
+                                       usb_err(instance->usbatm, "wrong index #%x in response to cm #%x\n",
+                                               offd, cm);
                                ret = -EIO;
                                goto cleanup;
                        }
@@ -806,7 +820,7 @@ reschedule:
 }
 
 static int cxacru_fw(struct usb_device *usb_dev, enum cxacru_fw_request fw,
-                    u8 code1, u8 code2, u32 addr, u8 *data, int size)
+                    u8 code1, u8 code2, u32 addr, const u8 *data, int size)
 {
        int ret;
        u8 *buf;
@@ -824,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)
@@ -861,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");
 
@@ -942,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++) {