Commit fd05e720 authored by Al Viro's avatar Al Viro Committed by Linus Torvalds

drivers/usb annotations and fixes

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