Commit eb771e2c authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

USB: mos7720: fix DMA buffers on stack and clean up send_mos_cmd

Change data-argument type from (void *) to (u8 *) to prevent endianess
problems.
Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent abf492e7
...@@ -275,13 +275,11 @@ static void mos7720_bulk_out_data_callback(struct urb *urb) ...@@ -275,13 +275,11 @@ static void mos7720_bulk_out_data_callback(struct urb *urb)
* this function will be used for sending command to device * this function will be used for sending command to device
*/ */
static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value, static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value,
__u16 index, void *data) __u16 index, u8 *data)
{ {
int status; int status;
unsigned int pipe; u8 *buf;
u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
__u8 requesttype;
__u16 size = 0x0000;
if (value < MOS_MAX_PORT) { if (value < MOS_MAX_PORT) {
if (product == MOSCHIP_DEVICE_ID_7715) if (product == MOSCHIP_DEVICE_ID_7715)
...@@ -298,21 +296,23 @@ static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value, ...@@ -298,21 +296,23 @@ static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value,
} }
if (request == MOS_WRITE) { if (request == MOS_WRITE) {
request = (__u8)MOS_WRITE; value = value + *data;
requesttype = (__u8)0x40; status = usb_control_msg(serial->dev,
value = value + (__u16)*((unsigned char *)data); usb_sndctrlpipe(serial->dev, 0), MOS_WRITE,
data = NULL; 0x40, value, index, NULL, 0, MOS_WDR_TIMEOUT);
pipe = usb_sndctrlpipe(serial->dev, 0);
} else { } else {
request = (__u8)MOS_READ; buf = kmalloc(1, GFP_KERNEL);
requesttype = (__u8)0xC0; if (!buf) {
size = 0x01; status = -ENOMEM;
pipe = usb_rcvctrlpipe(serial->dev, 0); goto out;
}
status = usb_control_msg(serial->dev,
usb_rcvctrlpipe(serial->dev, 0), MOS_READ,
0xc0, value, index, buf, 1, MOS_WDR_TIMEOUT);
*data = *buf;
kfree(buf);
} }
out:
status = usb_control_msg(serial->dev, pipe, request, requesttype,
value, index, data, size, MOS_WDR_TIMEOUT);
if (status < 0) if (status < 0)
dbg("Command Write failed Value %x index %x\n", value, index); dbg("Command Write failed Value %x index %x\n", value, index);
......
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