tree-wide: fix assorted typos all over the place
[linux-2.6.git] / drivers / usb / atm / ueagle-atm.c
index 389c5b1..bba4d3e 100644 (file)
@@ -64,7 +64,6 @@
 #include <linux/ctype.h>
 #include <linux/sched.h>
 #include <linux/kthread.h>
-#include <linux/version.h>
 #include <linux/mutex.h>
 #include <linux/freezer.h>
 
@@ -83,7 +82,7 @@
                if (debug >= 1) \
                        dev_dbg(&(usb_dev)->dev, \
                                "[ueagle-atm dbg] %s: " format, \
-                                       __FUNCTION__, ##args); \
+                                       __func__, ##args); \
        } while (0)
 
 #define uea_vdbg(usb_dev, format, args...)     \
        } while (0)
 
 #define uea_enters(usb_dev) \
-       uea_vdbg(usb_dev, "entering %s\n", __FUNCTION__)
+       uea_vdbg(usb_dev, "entering %s\n", __func__)
 
 #define uea_leaves(usb_dev) \
-       uea_vdbg(usb_dev, "leaving  %s\n", __FUNCTION__)
+       uea_vdbg(usb_dev, "leaving  %s\n", __func__)
 
 #define uea_err(usb_dev, format,args...) \
        dev_err(&(usb_dev)->dev ,"[UEAGLE-ATM] " format , ##args)
@@ -305,10 +304,9 @@ enum {
  */
 
 #define FW_GET_BYTE(p) *((__u8 *) (p))
-#define FW_GET_WORD(p) le16_to_cpu(get_unaligned((__le16 *) (p)))
-#define FW_GET_LONG(p) le32_to_cpu(get_unaligned((__le32 *) (p)))
 
 #define FW_DIR "ueagle-atm/"
+#define UEA_FW_NAME_MAX 30
 #define NB_MODEM 4
 
 #define BULK_TIMEOUT 300
@@ -581,7 +579,7 @@ MODULE_PARM_DESC(annex,
  * uea_send_modem_cmd - Send a command for pre-firmware devices.
  */
 static int uea_send_modem_cmd(struct usb_device *usb,
-               u16 addr, u16 size, u8 * buff)
+                             u16 addr, u16 size, const u8 *buff)
 {
        int ret = -ENOMEM;
        u8 *xfer_buff;
@@ -606,7 +604,8 @@ static int uea_send_modem_cmd(struct usb_device *usb,
 static void uea_upload_pre_firmware(const struct firmware *fw_entry, void *context)
 {
        struct usb_device *usb = context;
-       u8 *pfw, value;
+       const u8 *pfw;
+       u8 value;
        u32 crc = 0;
        int ret, size;
 
@@ -621,14 +620,14 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry, void *conte
        if (size < 4)
                goto err_fw_corrupted;
 
-       crc = FW_GET_LONG(pfw);
+       crc = get_unaligned_le32(pfw);
        pfw += 4;
        size -= 4;
        if (crc32_be(0, pfw, size) != crc)
                goto err_fw_corrupted;
 
        /*
-        * Start to upload formware : send reset
+        * Start to upload firmware : send reset
         */
        value = 1;
        ret = uea_send_modem_cmd(usb, F8051_USBCS, sizeof(value), &value);
@@ -640,7 +639,7 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry, void *conte
 
        while (size > 3) {
                u8 len = FW_GET_BYTE(pfw);
-               u16 add = FW_GET_WORD(pfw + 1);
+               u16 add = get_unaligned_le16(pfw + 1);
 
                size -= len + 3;
                if (size < 0)
@@ -722,7 +721,7 @@ static int uea_load_firmware(struct usb_device *usb, unsigned int ver)
 /*
  * Make sure that the DSP code provided is safe to use.
  */
-static int check_dsp_e1(u8 *dsp, unsigned int len)
+static int check_dsp_e1(const u8 *dsp, unsigned int len)
 {
        u8 pagecount, blockcount;
        u16 blocksize;
@@ -738,7 +737,7 @@ static int check_dsp_e1(u8 *dsp, unsigned int len)
 
        for (i = 0; i < pagecount; i++) {
 
-               pageoffset = FW_GET_LONG(dsp + p);
+               pageoffset = get_unaligned_le32(dsp + p);
                p += 4;
 
                if (pageoffset == 0)
@@ -759,7 +758,7 @@ static int check_dsp_e1(u8 *dsp, unsigned int len)
                                return 1;
 
                        pp += 2;        /* skip blockaddr */
-                       blocksize = FW_GET_WORD(dsp + pp);
+                       blocksize = get_unaligned_le16(dsp + pp);
                        pp += 2;
 
                        /* enough space for block data? */
@@ -773,7 +772,7 @@ static int check_dsp_e1(u8 *dsp, unsigned int len)
        return 0;
 }
 
-static int check_dsp_e4(u8 *dsp, int len)
+static int check_dsp_e4(const u8 *dsp, int len)
 {
        int i;
        struct l1_code *p = (struct l1_code *) dsp;
@@ -821,7 +820,7 @@ static int check_dsp_e4(u8 *dsp, int len)
 /*
  * send data to the idma pipe
  * */
-static int uea_idma_write(struct uea_softc *sc, void *data, u32 size)
+static int uea_idma_write(struct uea_softc *sc, const void *data, u32 size)
 {
        int ret = -ENOMEM;
        u8 *xfer_buff;
@@ -905,7 +904,7 @@ static void uea_load_page_e1(struct work_struct *work)
        u16 ovl = sc->ovl;
        struct block_info_e1 bi;
 
-       u8 *p;
+       const u8 *p;
        u8 pagecount, blockcount;
        u16 blockaddr, blocksize;
        u32 pageoffset;
@@ -928,7 +927,7 @@ static void uea_load_page_e1(struct work_struct *work)
                goto bad1;
 
        p += 4 * pageno;
-       pageoffset = FW_GET_LONG(p);
+       pageoffset = get_unaligned_le32(p);
 
        if (pageoffset == 0)
                goto bad1;
@@ -945,10 +944,10 @@ static void uea_load_page_e1(struct work_struct *work)
        bi.wOvlOffset = cpu_to_le16(ovl | 0x8000);
 
        for (i = 0; i < blockcount; i++) {
-               blockaddr = FW_GET_WORD(p);
+               blockaddr = get_unaligned_le16(p);
                p += 2;
 
-               blocksize = FW_GET_WORD(p);
+               blocksize = get_unaligned_le16(p);
                p += 2;
 
                bi.wSize = cpu_to_le16(blocksize);
@@ -988,7 +987,7 @@ static void __uea_load_page_e4(struct uea_softc *sc, u8 pageno, int boot)
        bi.wReserved = cpu_to_be16(UEA_RESERVED);
 
        do {
-               u8 *blockoffset;
+               const u8 *blockoffset;
                unsigned int blocksize;
 
                blockidx = &p->page_header[blockno];
@@ -996,10 +995,10 @@ 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 adress %x\n",
+                      "sending block %u for DSP page %u size %u address %x\n",
                       blockno, pageno, blocksize, le32_to_cpu(blockidx->PageAddress));
 
                /* send block info through the IDMA pipe */
@@ -1040,7 +1039,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 +1064,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))
@@ -1097,7 +1096,7 @@ static inline int wait_cmv_ack(struct uea_softc *sc)
 #define UCDC_SEND_ENCAPSULATED_COMMAND 0x00
 
 static int uea_request(struct uea_softc *sc,
-               u16 value, u16 index, u16 size, void *data)
+               u16 value, u16 index, u16 size, const void *data)
 {
        u8 *xfer_buff;
        int ret = -ENOMEM;
@@ -1152,9 +1151,9 @@ static int uea_cmv_e1(struct uea_softc *sc,
        cmv.bDirection = E1_HOSTTOMODEM;
        cmv.bFunction = function;
        cmv.wIndex = cpu_to_le16(sc->cmv_dsc.e1.idx);
-       put_unaligned(cpu_to_le32(address), &cmv.dwSymbolicAddress);
+       put_unaligned_le32(address, &cmv.dwSymbolicAddress);
        cmv.wOffsetAddress = cpu_to_le16(offset);
-       put_unaligned(cpu_to_le32(data >> 16 | data << 16), &cmv.dwData);
+       put_unaligned_le32(data >> 16 | data << 16, &cmv.dwData);
 
        ret = uea_request(sc, UEA_E1_SET_BLOCK, UEA_MPTX_START, sizeof(cmv), &cmv);
        if (ret < 0)
@@ -1566,9 +1565,9 @@ static void cmvs_file_name(struct uea_softc *sc, char *const cmv_name, int ver)
                file = cmv_file[sc->modem_index];
 
        strcpy(cmv_name, FW_DIR);
-       strlcat(cmv_name, file, FIRMWARE_NAME_MAX);
+       strlcat(cmv_name, file, UEA_FW_NAME_MAX);
        if (ver == 2)
-               strlcat(cmv_name, ".v2", FIRMWARE_NAME_MAX);
+               strlcat(cmv_name, ".v2", UEA_FW_NAME_MAX);
 }
 
 static int request_cmvs_old(struct uea_softc *sc,
@@ -1576,7 +1575,7 @@ static int request_cmvs_old(struct uea_softc *sc,
 {
        int ret, size;
        u8 *data;
-       char cmv_name[FIRMWARE_NAME_MAX]; /* 30 bytes stack variable */
+       char cmv_name[UEA_FW_NAME_MAX]; /* 30 bytes stack variable */
 
        cmvs_file_name(sc, cmv_name, 1);
        ret = request_firmware(fw, cmv_name, &sc->usb_dev->dev);
@@ -1610,7 +1609,7 @@ static int request_cmvs(struct uea_softc *sc,
        int ret, size;
        u32 crc;
        u8 *data;
-       char cmv_name[FIRMWARE_NAME_MAX]; /* 30 bytes stack variable */
+       char cmv_name[UEA_FW_NAME_MAX]; /* 30 bytes stack variable */
 
        cmvs_file_name(sc, cmv_name, 2);
        ret = request_firmware(fw, cmv_name, &sc->usb_dev->dev);
@@ -1646,7 +1645,7 @@ static int request_cmvs(struct uea_softc *sc,
        if (size < 5)
                goto err_fw_corrupted;
 
-       crc = FW_GET_LONG(data);
+       crc = get_unaligned_le32(data);
        data += 4;
        size -= 4;
        if (crc32_be(0, data, size) != crc)
@@ -1696,9 +1695,9 @@ static int uea_send_cmvs_e1(struct uea_softc *sc)
                        "please update your firmware\n");
 
                for (i = 0; i < len; i++) {
-                       ret = uea_write_cmv_e1(sc, FW_GET_LONG(&cmvs_v1[i].address),
-                                               FW_GET_WORD(&cmvs_v1[i].offset),
-                                               FW_GET_LONG(&cmvs_v1[i].data));
+                       ret = uea_write_cmv_e1(sc, get_unaligned_le32(&cmvs_v1[i].address),
+                                               get_unaligned_le16(&cmvs_v1[i].offset),
+                                               get_unaligned_le32(&cmvs_v1[i].data));
                        if (ret < 0)
                                goto out;
                }
@@ -1706,9 +1705,9 @@ static int uea_send_cmvs_e1(struct uea_softc *sc)
                struct uea_cmvs_v2 *cmvs_v2 = cmvs_ptr;
 
                for (i = 0; i < len; i++) {
-                       ret = uea_write_cmv_e1(sc, FW_GET_LONG(&cmvs_v2[i].address),
-                                               (u16) FW_GET_LONG(&cmvs_v2[i].offset),
-                                               FW_GET_LONG(&cmvs_v2[i].data));
+                       ret = uea_write_cmv_e1(sc, get_unaligned_le32(&cmvs_v2[i].address),
+                                               (u16) get_unaligned_le32(&cmvs_v2[i].offset),
+                                               get_unaligned_le32(&cmvs_v2[i].data));
                        if (ret < 0)
                                goto out;
                }
@@ -1759,10 +1758,10 @@ static int uea_send_cmvs_e4(struct uea_softc *sc)
 
                for (i = 0; i < len; i++) {
                        ret = uea_write_cmv_e4(sc, 1,
-                                               FW_GET_LONG(&cmvs_v2[i].group),
-                                               FW_GET_LONG(&cmvs_v2[i].address),
-                                               FW_GET_LONG(&cmvs_v2[i].offset),
-                                               FW_GET_LONG(&cmvs_v2[i].data));
+                                               get_unaligned_le32(&cmvs_v2[i].group),
+                                               get_unaligned_le32(&cmvs_v2[i].address),
+                                               get_unaligned_le32(&cmvs_v2[i].offset),
+                                               get_unaligned_le32(&cmvs_v2[i].data));
                        if (ret < 0)
                                goto out;
                }
@@ -1893,7 +1892,8 @@ static int load_XILINX_firmware(struct uea_softc *sc)
 {
        const struct firmware *fw_entry;
        int ret, size, u, ln;
-       u8 *pfw, value;
+       const u8 *pfw;
+       u8 value;
        char *fw_name = FW_DIR "930-fpga.bin";
 
        uea_enters(INS_TO_USBDEV(sc));
@@ -1958,13 +1958,13 @@ static void uea_dispatch_cmv_e1(struct uea_softc *sc, struct intr_pkt *intr)
                goto bad1;
 
        /* FIXME : ADI930 reply wrong preambule (func = 2, sub = 2) to
-        * the first MEMACESS cmv. Ignore it...
+        * the first MEMACCESS cmv. Ignore it...
         */
        if (cmv->bFunction != dsc->function) {
                if (UEA_CHIP_VERSION(sc) == ADI930
                                && cmv->bFunction ==  E1_MAKEFUNCTION(2, 2)) {
                        cmv->wIndex = cpu_to_le16(dsc->idx);
-                       put_unaligned(cpu_to_le32(dsc->address), &cmv->dwSymbolicAddress);
+                       put_unaligned_le32(dsc->address, &cmv->dwSymbolicAddress);
                        cmv->wOffsetAddress = cpu_to_le16(dsc->offset);
                } else
                        goto bad2;
@@ -1978,11 +1978,11 @@ static void uea_dispatch_cmv_e1(struct uea_softc *sc, struct intr_pkt *intr)
 
        /* in case of MEMACCESS */
        if (le16_to_cpu(cmv->wIndex) != dsc->idx ||
-           le32_to_cpu(get_unaligned(&cmv->dwSymbolicAddress)) != dsc->address ||
+           get_unaligned_le32(&cmv->dwSymbolicAddress) != dsc->address ||
            le16_to_cpu(cmv->wOffsetAddress) != dsc->offset)
                goto bad2;
 
-       sc->data = le32_to_cpu(get_unaligned(&cmv->dwData));
+       sc->data = get_unaligned_le32(&cmv->dwData);
        sc->data = sc->data << 16 | sc->data >> 16;
 
        wake_up_cmv_ack(sc);
@@ -1990,7 +1990,7 @@ static void uea_dispatch_cmv_e1(struct uea_softc *sc, struct intr_pkt *intr)
        return;
 
 bad2:
-       uea_err(INS_TO_USBDEV(sc), "unexpected cmv received,"
+       uea_err(INS_TO_USBDEV(sc), "unexpected cmv received, "
                        "Function : %d, Subfunction : %d\n",
                        E1_FUNCTION_TYPE(cmv->bFunction),
                        E1_FUNCTION_SUBTYPE(cmv->bFunction));
@@ -2038,7 +2038,7 @@ static void uea_dispatch_cmv_e4(struct uea_softc *sc, struct intr_pkt *intr)
        return;
 
 bad2:
-       uea_err(INS_TO_USBDEV(sc), "unexpected cmv received,"
+       uea_err(INS_TO_USBDEV(sc), "unexpected cmv received, "
                        "Function : %d, Subfunction : %d\n",
                        E4_FUNCTION_TYPE(cmv->wFunction),
                        E4_FUNCTION_SUBTYPE(cmv->wFunction));