aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHarvey Harrison <harvey.harrison@gmail.com>2008-04-29 04:03:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:28 -0400
commita5abdeafedf722b0f3f357f4a23089a686b1b80d (patch)
tree06dc1712a552ddd190c4e1a323e9e069a4d5e059 /drivers
parent6b1e6f637469647f435f8f8ab00fbafa3c129712 (diff)
usb: use get/put_unaligned_* helpers
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Cc: Alan Stern <stern@rowland.harvard.edu> Cc: David Brownell <dbrownell@users.sourceforge.net> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/atm/ueagle-atm.c48
-rw-r--r--drivers/usb/class/cdc-acm.c2
-rw-r--r--drivers/usb/gadget/goku_udc.c2
-rw-r--r--drivers/usb/gadget/rndis.c40
-rw-r--r--drivers/usb/gadget/usbstring.c2
-rw-r--r--drivers/usb/host/ehci-hub.c2
-rw-r--r--drivers/usb/host/ohci-hub.c4
7 files changed, 44 insertions, 56 deletions
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index 4220f22b6660..5f71ff3aee35 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -305,8 +305,6 @@ enum {
305 */ 305 */
306 306
307#define FW_GET_BYTE(p) *((__u8 *) (p)) 307#define FW_GET_BYTE(p) *((__u8 *) (p))
308#define FW_GET_WORD(p) le16_to_cpu(get_unaligned((__le16 *) (p)))
309#define FW_GET_LONG(p) le32_to_cpu(get_unaligned((__le32 *) (p)))
310 308
311#define FW_DIR "ueagle-atm/" 309#define FW_DIR "ueagle-atm/"
312#define NB_MODEM 4 310#define NB_MODEM 4
@@ -621,7 +619,7 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry, void *conte
621 if (size < 4) 619 if (size < 4)
622 goto err_fw_corrupted; 620 goto err_fw_corrupted;
623 621
624 crc = FW_GET_LONG(pfw); 622 crc = get_unaligned_le32(pfw);
625 pfw += 4; 623 pfw += 4;
626 size -= 4; 624 size -= 4;
627 if (crc32_be(0, pfw, size) != crc) 625 if (crc32_be(0, pfw, size) != crc)
@@ -640,7 +638,7 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry, void *conte
640 638
641 while (size > 3) { 639 while (size > 3) {
642 u8 len = FW_GET_BYTE(pfw); 640 u8 len = FW_GET_BYTE(pfw);
643 u16 add = FW_GET_WORD(pfw + 1); 641 u16 add = get_unaligned_le16(pfw + 1);
644 642
645 size -= len + 3; 643 size -= len + 3;
646 if (size < 0) 644 if (size < 0)
@@ -738,7 +736,7 @@ static int check_dsp_e1(u8 *dsp, unsigned int len)
738 736
739 for (i = 0; i < pagecount; i++) { 737 for (i = 0; i < pagecount; i++) {
740 738
741 pageoffset = FW_GET_LONG(dsp + p); 739 pageoffset = get_unaligned_le32(dsp + p);
742 p += 4; 740 p += 4;
743 741
744 if (pageoffset == 0) 742 if (pageoffset == 0)
@@ -759,7 +757,7 @@ static int check_dsp_e1(u8 *dsp, unsigned int len)
759 return 1; 757 return 1;
760 758
761 pp += 2; /* skip blockaddr */ 759 pp += 2; /* skip blockaddr */
762 blocksize = FW_GET_WORD(dsp + pp); 760 blocksize = get_unaligned_le16(dsp + pp);
763 pp += 2; 761 pp += 2;
764 762
765 /* enough space for block data? */ 763 /* enough space for block data? */
@@ -928,7 +926,7 @@ static void uea_load_page_e1(struct work_struct *work)
928 goto bad1; 926 goto bad1;
929 927
930 p += 4 * pageno; 928 p += 4 * pageno;
931 pageoffset = FW_GET_LONG(p); 929 pageoffset = get_unaligned_le32(p);
932 930
933 if (pageoffset == 0) 931 if (pageoffset == 0)
934 goto bad1; 932 goto bad1;
@@ -945,10 +943,10 @@ static void uea_load_page_e1(struct work_struct *work)
945 bi.wOvlOffset = cpu_to_le16(ovl | 0x8000); 943 bi.wOvlOffset = cpu_to_le16(ovl | 0x8000);
946 944
947 for (i = 0; i < blockcount; i++) { 945 for (i = 0; i < blockcount; i++) {
948 blockaddr = FW_GET_WORD(p); 946 blockaddr = get_unaligned_le16(p);
949 p += 2; 947 p += 2;
950 948
951 blocksize = FW_GET_WORD(p); 949 blocksize = get_unaligned_le16(p);
952 p += 2; 950 p += 2;
953 951
954 bi.wSize = cpu_to_le16(blocksize); 952 bi.wSize = cpu_to_le16(blocksize);
@@ -1152,9 +1150,9 @@ static int uea_cmv_e1(struct uea_softc *sc,
1152 cmv.bDirection = E1_HOSTTOMODEM; 1150 cmv.bDirection = E1_HOSTTOMODEM;
1153 cmv.bFunction = function; 1151 cmv.bFunction = function;
1154 cmv.wIndex = cpu_to_le16(sc->cmv_dsc.e1.idx); 1152 cmv.wIndex = cpu_to_le16(sc->cmv_dsc.e1.idx);
1155 put_unaligned(cpu_to_le32(address), &cmv.dwSymbolicAddress); 1153 put_unaligned_le32(address, &cmv.dwSymbolicAddress);
1156 cmv.wOffsetAddress = cpu_to_le16(offset); 1154 cmv.wOffsetAddress = cpu_to_le16(offset);
1157 put_unaligned(cpu_to_le32(data >> 16 | data << 16), &cmv.dwData); 1155 put_unaligned_le32(data >> 16 | data << 16, &cmv.dwData);
1158 1156
1159 ret = uea_request(sc, UEA_E1_SET_BLOCK, UEA_MPTX_START, sizeof(cmv), &cmv); 1157 ret = uea_request(sc, UEA_E1_SET_BLOCK, UEA_MPTX_START, sizeof(cmv), &cmv);
1160 if (ret < 0) 1158 if (ret < 0)
@@ -1646,7 +1644,7 @@ static int request_cmvs(struct uea_softc *sc,
1646 if (size < 5) 1644 if (size < 5)
1647 goto err_fw_corrupted; 1645 goto err_fw_corrupted;
1648 1646
1649 crc = FW_GET_LONG(data); 1647 crc = get_unaligned_le32(data);
1650 data += 4; 1648 data += 4;
1651 size -= 4; 1649 size -= 4;
1652 if (crc32_be(0, data, size) != crc) 1650 if (crc32_be(0, data, size) != crc)
@@ -1696,9 +1694,9 @@ static int uea_send_cmvs_e1(struct uea_softc *sc)
1696 "please update your firmware\n"); 1694 "please update your firmware\n");
1697 1695
1698 for (i = 0; i < len; i++) { 1696 for (i = 0; i < len; i++) {
1699 ret = uea_write_cmv_e1(sc, FW_GET_LONG(&cmvs_v1[i].address), 1697 ret = uea_write_cmv_e1(sc, get_unaligned_le32(&cmvs_v1[i].address),
1700 FW_GET_WORD(&cmvs_v1[i].offset), 1698 get_unaligned_le16(&cmvs_v1[i].offset),
1701 FW_GET_LONG(&cmvs_v1[i].data)); 1699 get_unaligned_le32(&cmvs_v1[i].data));
1702 if (ret < 0) 1700 if (ret < 0)
1703 goto out; 1701 goto out;
1704 } 1702 }
@@ -1706,9 +1704,9 @@ static int uea_send_cmvs_e1(struct uea_softc *sc)
1706 struct uea_cmvs_v2 *cmvs_v2 = cmvs_ptr; 1704 struct uea_cmvs_v2 *cmvs_v2 = cmvs_ptr;
1707 1705
1708 for (i = 0; i < len; i++) { 1706 for (i = 0; i < len; i++) {
1709 ret = uea_write_cmv_e1(sc, FW_GET_LONG(&cmvs_v2[i].address), 1707 ret = uea_write_cmv_e1(sc, get_unaligned_le32(&cmvs_v2[i].address),
1710 (u16) FW_GET_LONG(&cmvs_v2[i].offset), 1708 (u16) get_unaligned_le32(&cmvs_v2[i].offset),
1711 FW_GET_LONG(&cmvs_v2[i].data)); 1709 get_unaligned_le32(&cmvs_v2[i].data));
1712 if (ret < 0) 1710 if (ret < 0)
1713 goto out; 1711 goto out;
1714 } 1712 }
@@ -1759,10 +1757,10 @@ static int uea_send_cmvs_e4(struct uea_softc *sc)
1759 1757
1760 for (i = 0; i < len; i++) { 1758 for (i = 0; i < len; i++) {
1761 ret = uea_write_cmv_e4(sc, 1, 1759 ret = uea_write_cmv_e4(sc, 1,
1762 FW_GET_LONG(&cmvs_v2[i].group), 1760 get_unaligned_le32(&cmvs_v2[i].group),
1763 FW_GET_LONG(&cmvs_v2[i].address), 1761 get_unaligned_le32(&cmvs_v2[i].address),
1764 FW_GET_LONG(&cmvs_v2[i].offset), 1762 get_unaligned_le32(&cmvs_v2[i].offset),
1765 FW_GET_LONG(&cmvs_v2[i].data)); 1763 get_unaligned_le32(&cmvs_v2[i].data));
1766 if (ret < 0) 1764 if (ret < 0)
1767 goto out; 1765 goto out;
1768 } 1766 }
@@ -1964,7 +1962,7 @@ static void uea_dispatch_cmv_e1(struct uea_softc *sc, struct intr_pkt *intr)
1964 if (UEA_CHIP_VERSION(sc) == ADI930 1962 if (UEA_CHIP_VERSION(sc) == ADI930
1965 && cmv->bFunction == E1_MAKEFUNCTION(2, 2)) { 1963 && cmv->bFunction == E1_MAKEFUNCTION(2, 2)) {
1966 cmv->wIndex = cpu_to_le16(dsc->idx); 1964 cmv->wIndex = cpu_to_le16(dsc->idx);
1967 put_unaligned(cpu_to_le32(dsc->address), &cmv->dwSymbolicAddress); 1965 put_unaligned_le32(dsc->address, &cmv->dwSymbolicAddress);
1968 cmv->wOffsetAddress = cpu_to_le16(dsc->offset); 1966 cmv->wOffsetAddress = cpu_to_le16(dsc->offset);
1969 } else 1967 } else
1970 goto bad2; 1968 goto bad2;
@@ -1978,11 +1976,11 @@ static void uea_dispatch_cmv_e1(struct uea_softc *sc, struct intr_pkt *intr)
1978 1976
1979 /* in case of MEMACCESS */ 1977 /* in case of MEMACCESS */
1980 if (le16_to_cpu(cmv->wIndex) != dsc->idx || 1978 if (le16_to_cpu(cmv->wIndex) != dsc->idx ||
1981 le32_to_cpu(get_unaligned(&cmv->dwSymbolicAddress)) != dsc->address || 1979 get_unaligned_le32(&cmv->dwSymbolicAddress) != dsc->address ||
1982 le16_to_cpu(cmv->wOffsetAddress) != dsc->offset) 1980 le16_to_cpu(cmv->wOffsetAddress) != dsc->offset)
1983 goto bad2; 1981 goto bad2;
1984 1982
1985 sc->data = le32_to_cpu(get_unaligned(&cmv->dwData)); 1983 sc->data = get_unaligned_le32(&cmv->dwData);
1986 sc->data = sc->data << 16 | sc->data >> 16; 1984 sc->data = sc->data << 16 | sc->data >> 16;
1987 1985
1988 wake_up_cmv_ack(sc); 1986 wake_up_cmv_ack(sc);
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 7b572e75e73c..cefe7f2c6f75 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -280,7 +280,7 @@ static void acm_ctrl_irq(struct urb *urb)
280 280
281 case USB_CDC_NOTIFY_SERIAL_STATE: 281 case USB_CDC_NOTIFY_SERIAL_STATE:
282 282
283 newctrl = le16_to_cpu(get_unaligned((__le16 *) data)); 283 newctrl = get_unaligned_le16(data);
284 284
285 if (acm->tty && !acm->clocal && (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) { 285 if (acm->tty && !acm->clocal && (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) {
286 dbg("calling hangup"); 286 dbg("calling hangup");
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index 64a592cbbe7b..be6613afedbf 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -127,7 +127,7 @@ goku_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
127 127
128 /* enabling the no-toggle interrupt mode would need an api hook */ 128 /* enabling the no-toggle interrupt mode would need an api hook */
129 mode = 0; 129 mode = 0;
130 max = le16_to_cpu(get_unaligned(&desc->wMaxPacketSize)); 130 max = get_unaligned_le16(&desc->wMaxPacketSize);
131 switch (max) { 131 switch (max) {
132 case 64: mode++; 132 case 64: mode++;
133 case 32: mode++; 133 case 32: mode++;
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index bd58dd504f6f..d0677f5d3cd5 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -183,14 +183,10 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
183 DBG("query OID %08x value, len %d:\n", OID, buf_len); 183 DBG("query OID %08x value, len %d:\n", OID, buf_len);
184 for (i = 0; i < buf_len; i += 16) { 184 for (i = 0; i < buf_len; i += 16) {
185 DBG("%03d: %08x %08x %08x %08x\n", i, 185 DBG("%03d: %08x %08x %08x %08x\n", i,
186 le32_to_cpu(get_unaligned((__le32 *) 186 get_unaligned_le32(&buf[i]),
187 &buf[i])), 187 get_unaligned_le32(&buf[i + 4]),
188 le32_to_cpu(get_unaligned((__le32 *) 188 get_unaligned_le32(&buf[i + 8]),
189 &buf[i + 4])), 189 get_unaligned_le32(&buf[i + 12]));
190 le32_to_cpu(get_unaligned((__le32 *)
191 &buf[i + 8])),
192 le32_to_cpu(get_unaligned((__le32 *)
193 &buf[i + 12])));
194 } 190 }
195 } 191 }
196 192
@@ -666,7 +662,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
666 break; 662 break;
667 case OID_PNP_QUERY_POWER: 663 case OID_PNP_QUERY_POWER:
668 DBG("%s: OID_PNP_QUERY_POWER D%d\n", __func__, 664 DBG("%s: OID_PNP_QUERY_POWER D%d\n", __func__,
669 le32_to_cpu(get_unaligned((__le32 *)buf)) - 1); 665 get_unaligned_le32(buf) - 1);
670 /* only suspend is a real power state, and 666 /* only suspend is a real power state, and
671 * it can't be entered by OID_PNP_SET_POWER... 667 * it can't be entered by OID_PNP_SET_POWER...
672 */ 668 */
@@ -705,14 +701,10 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len,
705 DBG("set OID %08x value, len %d:\n", OID, buf_len); 701 DBG("set OID %08x value, len %d:\n", OID, buf_len);
706 for (i = 0; i < buf_len; i += 16) { 702 for (i = 0; i < buf_len; i += 16) {
707 DBG("%03d: %08x %08x %08x %08x\n", i, 703 DBG("%03d: %08x %08x %08x %08x\n", i,
708 le32_to_cpu(get_unaligned((__le32 *) 704 get_unaligned_le32(&buf[i]),
709 &buf[i])), 705 get_unaligned_le32(&buf[i + 4]),
710 le32_to_cpu(get_unaligned((__le32 *) 706 get_unaligned_le32(&buf[i + 8]),
711 &buf[i + 4])), 707 get_unaligned_le32(&buf[i + 12]));
712 le32_to_cpu(get_unaligned((__le32 *)
713 &buf[i + 8])),
714 le32_to_cpu(get_unaligned((__le32 *)
715 &buf[i + 12])));
716 } 708 }
717 } 709 }
718 710
@@ -726,8 +718,7 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len,
726 * PROMISCUOUS, DIRECTED, 718 * PROMISCUOUS, DIRECTED,
727 * MULTICAST, ALL_MULTICAST, BROADCAST 719 * MULTICAST, ALL_MULTICAST, BROADCAST
728 */ 720 */
729 *params->filter = (u16) le32_to_cpu(get_unaligned( 721 *params->filter = (u16)get_unaligned_le32(buf);
730 (__le32 *)buf));
731 DBG("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n", 722 DBG("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n",
732 __func__, *params->filter); 723 __func__, *params->filter);
733 724
@@ -777,7 +768,7 @@ update_linkstate:
777 * resuming, Windows forces a reset, and then SET_POWER D0. 768 * resuming, Windows forces a reset, and then SET_POWER D0.
778 * FIXME ... then things go batty; Windows wedges itself. 769 * FIXME ... then things go batty; Windows wedges itself.
779 */ 770 */
780 i = le32_to_cpu(get_unaligned((__le32 *)buf)); 771 i = get_unaligned_le32(buf);
781 DBG("%s: OID_PNP_SET_POWER D%d\n", __func__, i - 1); 772 DBG("%s: OID_PNP_SET_POWER D%d\n", __func__, i - 1);
782 switch (i) { 773 switch (i) {
783 case NdisDeviceStateD0: 774 case NdisDeviceStateD0:
@@ -1064,8 +1055,8 @@ int rndis_msg_parser (u8 configNr, u8 *buf)
1064 return -ENOMEM; 1055 return -ENOMEM;
1065 1056
1066 tmp = (__le32 *) buf; 1057 tmp = (__le32 *) buf;
1067 MsgType = le32_to_cpu(get_unaligned(tmp++)); 1058 MsgType = get_unaligned_le32(tmp++);
1068 MsgLength = le32_to_cpu(get_unaligned(tmp++)); 1059 MsgLength = get_unaligned_le32(tmp++);
1069 1060
1070 if (configNr >= RNDIS_MAX_CONFIGS) 1061 if (configNr >= RNDIS_MAX_CONFIGS)
1071 return -ENOTSUPP; 1062 return -ENOTSUPP;
@@ -1296,10 +1287,9 @@ int rndis_rm_hdr(struct sk_buff *skb)
1296 tmp++; 1287 tmp++;
1297 1288
1298 /* DataOffset, DataLength */ 1289 /* DataOffset, DataLength */
1299 if (!skb_pull(skb, le32_to_cpu(get_unaligned(tmp++)) 1290 if (!skb_pull(skb, get_unaligned_le32(tmp++) + 8))
1300 + 8 /* offset of DataOffset */))
1301 return -EOVERFLOW; 1291 return -EOVERFLOW;
1302 skb_trim(skb, le32_to_cpu(get_unaligned(tmp++))); 1292 skb_trim(skb, get_unaligned_le32(tmp++));
1303 1293
1304 return 0; 1294 return 0;
1305} 1295}
diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c
index 878e428a0ec1..4154be375c7a 100644
--- a/drivers/usb/gadget/usbstring.c
+++ b/drivers/usb/gadget/usbstring.c
@@ -74,7 +74,7 @@ static int utf8_to_utf16le(const char *s, __le16 *cp, unsigned len)
74 goto fail; 74 goto fail;
75 } else 75 } else
76 uchar = c; 76 uchar = c;
77 put_unaligned (cpu_to_le16 (uchar), cp++); 77 put_unaligned_le16(uchar, cp++);
78 count++; 78 count++;
79 len--; 79 len--;
80 } 80 }
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index f13d1029aeb2..382587c4457c 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -770,7 +770,7 @@ static int ehci_hub_control (
770 if (status & ~0xffff) /* only if wPortChange is interesting */ 770 if (status & ~0xffff) /* only if wPortChange is interesting */
771#endif 771#endif
772 dbg_port (ehci, "GetStatus", wIndex + 1, temp); 772 dbg_port (ehci, "GetStatus", wIndex + 1, temp);
773 put_unaligned(cpu_to_le32 (status), (__le32 *) buf); 773 put_unaligned_le32(status, buf);
774 break; 774 break;
775 case SetHubFeature: 775 case SetHubFeature:
776 switch (wValue) { 776 switch (wValue) {
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 5be3bb3e6a9d..17dc2eccda83 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -736,14 +736,14 @@ static int ohci_hub_control (
736 break; 736 break;
737 case GetHubStatus: 737 case GetHubStatus:
738 temp = roothub_status (ohci) & ~(RH_HS_CRWE | RH_HS_DRWE); 738 temp = roothub_status (ohci) & ~(RH_HS_CRWE | RH_HS_DRWE);
739 put_unaligned(cpu_to_le32 (temp), (__le32 *) buf); 739 put_unaligned_le32(temp, buf);
740 break; 740 break;
741 case GetPortStatus: 741 case GetPortStatus:
742 if (!wIndex || wIndex > ports) 742 if (!wIndex || wIndex > ports)
743 goto error; 743 goto error;
744 wIndex--; 744 wIndex--;
745 temp = roothub_portstatus (ohci, wIndex); 745 temp = roothub_portstatus (ohci, wIndex);
746 put_unaligned(cpu_to_le32 (temp), (__le32 *) buf); 746 put_unaligned_le32(temp, buf);
747 747
748#ifndef OHCI_VERBOSE_DEBUG 748#ifndef OHCI_VERBOSE_DEBUG
749 if (*(u16*)(buf+2)) /* only if wPortChange is interesting */ 749 if (*(u16*)(buf+2)) /* only if wPortChange is interesting */