Commit 818727ba authored by Jussi Kivilinna's avatar Jussi Kivilinna Committed by Jeff Garzik

rndis_host: pass buffer length to rndis_command

Pass buffer length to rndis_command so that rndis_command can read full
response buffer from device instead of max CONTROL_BUFFER_SIZE bytes.
Signed-off-by: default avatarJussi Kivilinna <jussi.kivilinna@mbnet.fi>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent 0caa1166
...@@ -74,7 +74,7 @@ EXPORT_SYMBOL_GPL(rndis_status); ...@@ -74,7 +74,7 @@ EXPORT_SYMBOL_GPL(rndis_status);
* Call context is likely probe(), before interface name is known, * Call context is likely probe(), before interface name is known,
* which is why we won't try to use it in the diagnostics. * which is why we won't try to use it in the diagnostics.
*/ */
int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf) int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen)
{ {
struct cdc_state *info = (void *) &dev->data; struct cdc_state *info = (void *) &dev->data;
int master_ifnum; int master_ifnum;
...@@ -121,7 +121,7 @@ int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf) ...@@ -121,7 +121,7 @@ int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf)
USB_CDC_GET_ENCAPSULATED_RESPONSE, USB_CDC_GET_ENCAPSULATED_RESPONSE,
USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
0, master_ifnum, 0, master_ifnum,
buf, CONTROL_BUFFER_SIZE, buf, buflen,
RNDIS_CONTROL_TIMEOUT_MS); RNDIS_CONTROL_TIMEOUT_MS);
if (likely(retval >= 8)) { if (likely(retval >= 8)) {
msg_len = le32_to_cpu(buf->msg_len); msg_len = le32_to_cpu(buf->msg_len);
...@@ -239,7 +239,7 @@ static int rndis_query(struct usbnet *dev, struct usb_interface *intf, ...@@ -239,7 +239,7 @@ static int rndis_query(struct usbnet *dev, struct usb_interface *intf,
u.get->len = cpu_to_le32(in_len); u.get->len = cpu_to_le32(in_len);
u.get->offset = ccpu2(20); u.get->offset = ccpu2(20);
retval = rndis_command(dev, u.header); retval = rndis_command(dev, u.header, CONTROL_BUFFER_SIZE);
if (unlikely(retval < 0)) { if (unlikely(retval < 0)) {
dev_err(&intf->dev, "RNDIS_MSG_QUERY(0x%08x) failed, %d\n", dev_err(&intf->dev, "RNDIS_MSG_QUERY(0x%08x) failed, %d\n",
oid, retval); oid, retval);
...@@ -328,7 +328,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags) ...@@ -328,7 +328,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
u.init->max_transfer_size = cpu_to_le32(dev->rx_urb_size); u.init->max_transfer_size = cpu_to_le32(dev->rx_urb_size);
net->change_mtu = NULL; net->change_mtu = NULL;
retval = rndis_command(dev, u.header); retval = rndis_command(dev, u.header, CONTROL_BUFFER_SIZE);
if (unlikely(retval < 0)) { if (unlikely(retval < 0)) {
/* it might not even be an RNDIS device!! */ /* it might not even be an RNDIS device!! */
dev_err(&intf->dev, "RNDIS init failed, %d\n", retval); dev_err(&intf->dev, "RNDIS init failed, %d\n", retval);
...@@ -409,7 +409,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags) ...@@ -409,7 +409,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
u.set->offset = ccpu2((sizeof *u.set) - 8); u.set->offset = ccpu2((sizeof *u.set) - 8);
*(__le32 *)(u.buf + sizeof *u.set) = RNDIS_DEFAULT_FILTER; *(__le32 *)(u.buf + sizeof *u.set) = RNDIS_DEFAULT_FILTER;
retval = rndis_command(dev, u.header); retval = rndis_command(dev, u.header, CONTROL_BUFFER_SIZE);
if (unlikely(retval < 0)) { if (unlikely(retval < 0)) {
dev_err(&intf->dev, "rndis set packet filter, %d\n", retval); dev_err(&intf->dev, "rndis set packet filter, %d\n", retval);
goto halt_fail_and_release; goto halt_fail_and_release;
...@@ -424,7 +424,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags) ...@@ -424,7 +424,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
memset(u.halt, 0, sizeof *u.halt); memset(u.halt, 0, sizeof *u.halt);
u.halt->msg_type = RNDIS_MSG_HALT; u.halt->msg_type = RNDIS_MSG_HALT;
u.halt->msg_len = ccpu2(sizeof *u.halt); u.halt->msg_len = ccpu2(sizeof *u.halt);
(void) rndis_command(dev, (void *)u.halt); (void) rndis_command(dev, (void *)u.halt, CONTROL_BUFFER_SIZE);
fail_and_release: fail_and_release:
usb_set_intfdata(info->data, NULL); usb_set_intfdata(info->data, NULL);
usb_driver_release_interface(driver_of(intf), info->data); usb_driver_release_interface(driver_of(intf), info->data);
...@@ -449,7 +449,7 @@ void rndis_unbind(struct usbnet *dev, struct usb_interface *intf) ...@@ -449,7 +449,7 @@ void rndis_unbind(struct usbnet *dev, struct usb_interface *intf)
if (halt) { if (halt) {
halt->msg_type = RNDIS_MSG_HALT; halt->msg_type = RNDIS_MSG_HALT;
halt->msg_len = ccpu2(sizeof *halt); halt->msg_len = ccpu2(sizeof *halt);
(void) rndis_command(dev, (void *)halt); (void) rndis_command(dev, (void *)halt, CONTROL_BUFFER_SIZE);
kfree(halt); kfree(halt);
} }
......
...@@ -448,7 +448,7 @@ static int rndis_query_oid(struct usbnet *dev, __le32 oid, void *data, int *len) ...@@ -448,7 +448,7 @@ static int rndis_query_oid(struct usbnet *dev, __le32 oid, void *data, int *len)
u.get->msg_len = ccpu2(sizeof *u.get); u.get->msg_len = ccpu2(sizeof *u.get);
u.get->oid = oid; u.get->oid = oid;
ret = rndis_command(dev, u.header); ret = rndis_command(dev, u.header, buflen);
if (ret == 0) { if (ret == 0) {
ret = le32_to_cpu(u.get_c->len); ret = le32_to_cpu(u.get_c->len);
*len = (*len > ret) ? ret : *len; *len = (*len > ret) ? ret : *len;
...@@ -498,7 +498,7 @@ static int rndis_set_oid(struct usbnet *dev, __le32 oid, void *data, int len) ...@@ -498,7 +498,7 @@ static int rndis_set_oid(struct usbnet *dev, __le32 oid, void *data, int len)
u.set->handle = ccpu2(0); u.set->handle = ccpu2(0);
memcpy(u.buf + sizeof(*u.set), data, len); memcpy(u.buf + sizeof(*u.set), data, len);
ret = rndis_command(dev, u.header); ret = rndis_command(dev, u.header, buflen);
if (ret == 0) if (ret == 0)
ret = rndis_error_status(u.set_c->status); ret = rndis_error_status(u.set_c->status);
......
...@@ -260,7 +260,8 @@ struct rndis_keepalive_c { /* IN (optionally OUT) */ ...@@ -260,7 +260,8 @@ struct rndis_keepalive_c { /* IN (optionally OUT) */
extern void rndis_status(struct usbnet *dev, struct urb *urb); extern void rndis_status(struct usbnet *dev, struct urb *urb);
extern int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf); extern int
rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen);
extern int extern int
generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags); generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags);
extern void rndis_unbind(struct usbnet *dev, struct usb_interface *intf); extern void rndis_unbind(struct usbnet *dev, struct usb_interface *intf);
......
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