aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/rndis.c99
1 files changed, 48 insertions, 51 deletions
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index 8c26f5ea2b83..2b4660e08c4d 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -63,7 +63,7 @@ MODULE_PARM_DESC (rndis_debug, "enable debugging");
63static rndis_params rndis_per_dev_params [RNDIS_MAX_CONFIGS]; 63static rndis_params rndis_per_dev_params [RNDIS_MAX_CONFIGS];
64 64
65/* Driver Version */ 65/* Driver Version */
66static const __le32 rndis_driver_version = __constant_cpu_to_le32 (1); 66static const __le32 rndis_driver_version = cpu_to_le32 (1);
67 67
68/* Function Prototypes */ 68/* Function Prototypes */
69static rndis_resp_t *rndis_add_response (int configNr, u32 length); 69static rndis_resp_t *rndis_add_response (int configNr, u32 length);
@@ -170,7 +170,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
170 int i, count; 170 int i, count;
171 rndis_query_cmplt_type *resp; 171 rndis_query_cmplt_type *resp;
172 struct net_device *net; 172 struct net_device *net;
173 struct net_device_stats *stats; 173 const struct net_device_stats *stats;
174 174
175 if (!r) return -ENOMEM; 175 if (!r) return -ENOMEM;
176 resp = (rndis_query_cmplt_type *) r->buf; 176 resp = (rndis_query_cmplt_type *) r->buf;
@@ -190,13 +190,10 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
190 190
191 /* response goes here, right after the header */ 191 /* response goes here, right after the header */
192 outbuf = (__le32 *) &resp[1]; 192 outbuf = (__le32 *) &resp[1];
193 resp->InformationBufferOffset = __constant_cpu_to_le32 (16); 193 resp->InformationBufferOffset = cpu_to_le32 (16);
194 194
195 net = rndis_per_dev_params[configNr].dev; 195 net = rndis_per_dev_params[configNr].dev;
196 if (net->get_stats) 196 stats = dev_get_stats(net);
197 stats = net->get_stats(net);
198 else
199 stats = NULL;
200 197
201 switch (OID) { 198 switch (OID) {
202 199
@@ -221,7 +218,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
221 * reddite ergo quae sunt Caesaris Caesari 218 * reddite ergo quae sunt Caesaris Caesari
222 * et quae sunt Dei Deo! 219 * et quae sunt Dei Deo!
223 */ 220 */
224 *outbuf = __constant_cpu_to_le32 (0); 221 *outbuf = cpu_to_le32 (0);
225 retval = 0; 222 retval = 0;
226 break; 223 break;
227 224
@@ -256,7 +253,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
256 pr_debug("%s: OID_GEN_LINK_SPEED\n", __func__); 253 pr_debug("%s: OID_GEN_LINK_SPEED\n", __func__);
257 if (rndis_per_dev_params [configNr].media_state 254 if (rndis_per_dev_params [configNr].media_state
258 == NDIS_MEDIA_STATE_DISCONNECTED) 255 == NDIS_MEDIA_STATE_DISCONNECTED)
259 *outbuf = __constant_cpu_to_le32 (0); 256 *outbuf = cpu_to_le32 (0);
260 else 257 else
261 *outbuf = cpu_to_le32 ( 258 *outbuf = cpu_to_le32 (
262 rndis_per_dev_params [configNr].speed); 259 rndis_per_dev_params [configNr].speed);
@@ -317,7 +314,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
317 /* mandatory */ 314 /* mandatory */
318 case OID_GEN_MAXIMUM_TOTAL_SIZE: 315 case OID_GEN_MAXIMUM_TOTAL_SIZE:
319 pr_debug("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __func__); 316 pr_debug("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __func__);
320 *outbuf = __constant_cpu_to_le32(RNDIS_MAX_TOTAL_SIZE); 317 *outbuf = cpu_to_le32(RNDIS_MAX_TOTAL_SIZE);
321 retval = 0; 318 retval = 0;
322 break; 319 break;
323 320
@@ -332,7 +329,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
332 329
333 case OID_GEN_PHYSICAL_MEDIUM: 330 case OID_GEN_PHYSICAL_MEDIUM:
334 pr_debug("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__); 331 pr_debug("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__);
335 *outbuf = __constant_cpu_to_le32 (0); 332 *outbuf = cpu_to_le32 (0);
336 retval = 0; 333 retval = 0;
337 break; 334 break;
338 335
@@ -342,7 +339,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
342 */ 339 */
343 case OID_GEN_MAC_OPTIONS: /* from WinME */ 340 case OID_GEN_MAC_OPTIONS: /* from WinME */
344 pr_debug("%s: OID_GEN_MAC_OPTIONS\n", __func__); 341 pr_debug("%s: OID_GEN_MAC_OPTIONS\n", __func__);
345 *outbuf = __constant_cpu_to_le32( 342 *outbuf = cpu_to_le32(
346 NDIS_MAC_OPTION_RECEIVE_SERIALIZED 343 NDIS_MAC_OPTION_RECEIVE_SERIALIZED
347 | NDIS_MAC_OPTION_FULL_DUPLEX); 344 | NDIS_MAC_OPTION_FULL_DUPLEX);
348 retval = 0; 345 retval = 0;
@@ -431,7 +428,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
431 case OID_802_3_MULTICAST_LIST: 428 case OID_802_3_MULTICAST_LIST:
432 pr_debug("%s: OID_802_3_MULTICAST_LIST\n", __func__); 429 pr_debug("%s: OID_802_3_MULTICAST_LIST\n", __func__);
433 /* Multicast base address only */ 430 /* Multicast base address only */
434 *outbuf = __constant_cpu_to_le32 (0xE0000000); 431 *outbuf = cpu_to_le32 (0xE0000000);
435 retval = 0; 432 retval = 0;
436 break; 433 break;
437 434
@@ -439,7 +436,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
439 case OID_802_3_MAXIMUM_LIST_SIZE: 436 case OID_802_3_MAXIMUM_LIST_SIZE:
440 pr_debug("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__); 437 pr_debug("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__);
441 /* Multicast base address only */ 438 /* Multicast base address only */
442 *outbuf = __constant_cpu_to_le32 (1); 439 *outbuf = cpu_to_le32 (1);
443 retval = 0; 440 retval = 0;
444 break; 441 break;
445 442
@@ -461,14 +458,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
461 /* mandatory */ 458 /* mandatory */
462 case OID_802_3_XMIT_ONE_COLLISION: 459 case OID_802_3_XMIT_ONE_COLLISION:
463 pr_debug("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__); 460 pr_debug("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__);
464 *outbuf = __constant_cpu_to_le32 (0); 461 *outbuf = cpu_to_le32 (0);
465 retval = 0; 462 retval = 0;
466 break; 463 break;
467 464
468 /* mandatory */ 465 /* mandatory */
469 case OID_802_3_XMIT_MORE_COLLISIONS: 466 case OID_802_3_XMIT_MORE_COLLISIONS:
470 pr_debug("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__); 467 pr_debug("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__);
471 *outbuf = __constant_cpu_to_le32 (0); 468 *outbuf = cpu_to_le32 (0);
472 retval = 0; 469 retval = 0;
473 break; 470 break;
474 471
@@ -572,24 +569,24 @@ static int rndis_init_response (int configNr, rndis_init_msg_type *buf)
572 return -ENOMEM; 569 return -ENOMEM;
573 resp = (rndis_init_cmplt_type *) r->buf; 570 resp = (rndis_init_cmplt_type *) r->buf;
574 571
575 resp->MessageType = __constant_cpu_to_le32 ( 572 resp->MessageType = cpu_to_le32 (
576 REMOTE_NDIS_INITIALIZE_CMPLT); 573 REMOTE_NDIS_INITIALIZE_CMPLT);
577 resp->MessageLength = __constant_cpu_to_le32 (52); 574 resp->MessageLength = cpu_to_le32 (52);
578 resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ 575 resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
579 resp->Status = __constant_cpu_to_le32 (RNDIS_STATUS_SUCCESS); 576 resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS);
580 resp->MajorVersion = __constant_cpu_to_le32 (RNDIS_MAJOR_VERSION); 577 resp->MajorVersion = cpu_to_le32 (RNDIS_MAJOR_VERSION);
581 resp->MinorVersion = __constant_cpu_to_le32 (RNDIS_MINOR_VERSION); 578 resp->MinorVersion = cpu_to_le32 (RNDIS_MINOR_VERSION);
582 resp->DeviceFlags = __constant_cpu_to_le32 (RNDIS_DF_CONNECTIONLESS); 579 resp->DeviceFlags = cpu_to_le32 (RNDIS_DF_CONNECTIONLESS);
583 resp->Medium = __constant_cpu_to_le32 (RNDIS_MEDIUM_802_3); 580 resp->Medium = cpu_to_le32 (RNDIS_MEDIUM_802_3);
584 resp->MaxPacketsPerTransfer = __constant_cpu_to_le32 (1); 581 resp->MaxPacketsPerTransfer = cpu_to_le32 (1);
585 resp->MaxTransferSize = cpu_to_le32 ( 582 resp->MaxTransferSize = cpu_to_le32 (
586 params->dev->mtu 583 params->dev->mtu
587 + sizeof (struct ethhdr) 584 + sizeof (struct ethhdr)
588 + sizeof (struct rndis_packet_msg_type) 585 + sizeof (struct rndis_packet_msg_type)
589 + 22); 586 + 22);
590 resp->PacketAlignmentFactor = __constant_cpu_to_le32 (0); 587 resp->PacketAlignmentFactor = cpu_to_le32 (0);
591 resp->AFListOffset = __constant_cpu_to_le32 (0); 588 resp->AFListOffset = cpu_to_le32 (0);
592 resp->AFListSize = __constant_cpu_to_le32 (0); 589 resp->AFListSize = cpu_to_le32 (0);
593 590
594 params->resp_avail(params->v); 591 params->resp_avail(params->v);
595 return 0; 592 return 0;
@@ -617,7 +614,7 @@ static int rndis_query_response (int configNr, rndis_query_msg_type *buf)
617 return -ENOMEM; 614 return -ENOMEM;
618 resp = (rndis_query_cmplt_type *) r->buf; 615 resp = (rndis_query_cmplt_type *) r->buf;
619 616
620 resp->MessageType = __constant_cpu_to_le32 (REMOTE_NDIS_QUERY_CMPLT); 617 resp->MessageType = cpu_to_le32 (REMOTE_NDIS_QUERY_CMPLT);
621 resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ 618 resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
622 619
623 if (gen_ndis_query_resp (configNr, le32_to_cpu (buf->OID), 620 if (gen_ndis_query_resp (configNr, le32_to_cpu (buf->OID),
@@ -626,13 +623,13 @@ static int rndis_query_response (int configNr, rndis_query_msg_type *buf)
626 le32_to_cpu(buf->InformationBufferLength), 623 le32_to_cpu(buf->InformationBufferLength),
627 r)) { 624 r)) {
628 /* OID not supported */ 625 /* OID not supported */
629 resp->Status = __constant_cpu_to_le32 ( 626 resp->Status = cpu_to_le32 (
630 RNDIS_STATUS_NOT_SUPPORTED); 627 RNDIS_STATUS_NOT_SUPPORTED);
631 resp->MessageLength = __constant_cpu_to_le32 (sizeof *resp); 628 resp->MessageLength = cpu_to_le32 (sizeof *resp);
632 resp->InformationBufferLength = __constant_cpu_to_le32 (0); 629 resp->InformationBufferLength = cpu_to_le32 (0);
633 resp->InformationBufferOffset = __constant_cpu_to_le32 (0); 630 resp->InformationBufferOffset = cpu_to_le32 (0);
634 } else 631 } else
635 resp->Status = __constant_cpu_to_le32 (RNDIS_STATUS_SUCCESS); 632 resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS);
636 633
637 params->resp_avail(params->v); 634 params->resp_avail(params->v);
638 return 0; 635 return 0;
@@ -665,14 +662,14 @@ static int rndis_set_response (int configNr, rndis_set_msg_type *buf)
665 pr_debug("\n"); 662 pr_debug("\n");
666#endif 663#endif
667 664
668 resp->MessageType = __constant_cpu_to_le32 (REMOTE_NDIS_SET_CMPLT); 665 resp->MessageType = cpu_to_le32 (REMOTE_NDIS_SET_CMPLT);
669 resp->MessageLength = __constant_cpu_to_le32 (16); 666 resp->MessageLength = cpu_to_le32 (16);
670 resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ 667 resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
671 if (gen_ndis_set_resp (configNr, le32_to_cpu (buf->OID), 668 if (gen_ndis_set_resp (configNr, le32_to_cpu (buf->OID),
672 ((u8 *) buf) + 8 + BufOffset, BufLength, r)) 669 ((u8 *) buf) + 8 + BufOffset, BufLength, r))
673 resp->Status = __constant_cpu_to_le32 (RNDIS_STATUS_NOT_SUPPORTED); 670 resp->Status = cpu_to_le32 (RNDIS_STATUS_NOT_SUPPORTED);
674 else 671 else
675 resp->Status = __constant_cpu_to_le32 (RNDIS_STATUS_SUCCESS); 672 resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS);
676 673
677 params->resp_avail(params->v); 674 params->resp_avail(params->v);
678 return 0; 675 return 0;
@@ -689,11 +686,11 @@ static int rndis_reset_response (int configNr, rndis_reset_msg_type *buf)
689 return -ENOMEM; 686 return -ENOMEM;
690 resp = (rndis_reset_cmplt_type *) r->buf; 687 resp = (rndis_reset_cmplt_type *) r->buf;
691 688
692 resp->MessageType = __constant_cpu_to_le32 (REMOTE_NDIS_RESET_CMPLT); 689 resp->MessageType = cpu_to_le32 (REMOTE_NDIS_RESET_CMPLT);
693 resp->MessageLength = __constant_cpu_to_le32 (16); 690 resp->MessageLength = cpu_to_le32 (16);
694 resp->Status = __constant_cpu_to_le32 (RNDIS_STATUS_SUCCESS); 691 resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS);
695 /* resent information */ 692 /* resent information */
696 resp->AddressingReset = __constant_cpu_to_le32 (1); 693 resp->AddressingReset = cpu_to_le32 (1);
697 694
698 params->resp_avail(params->v); 695 params->resp_avail(params->v);
699 return 0; 696 return 0;
@@ -713,11 +710,11 @@ static int rndis_keepalive_response (int configNr,
713 return -ENOMEM; 710 return -ENOMEM;
714 resp = (rndis_keepalive_cmplt_type *) r->buf; 711 resp = (rndis_keepalive_cmplt_type *) r->buf;
715 712
716 resp->MessageType = __constant_cpu_to_le32 ( 713 resp->MessageType = cpu_to_le32 (
717 REMOTE_NDIS_KEEPALIVE_CMPLT); 714 REMOTE_NDIS_KEEPALIVE_CMPLT);
718 resp->MessageLength = __constant_cpu_to_le32 (16); 715 resp->MessageLength = cpu_to_le32 (16);
719 resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ 716 resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
720 resp->Status = __constant_cpu_to_le32 (RNDIS_STATUS_SUCCESS); 717 resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS);
721 718
722 params->resp_avail(params->v); 719 params->resp_avail(params->v);
723 return 0; 720 return 0;
@@ -742,12 +739,12 @@ static int rndis_indicate_status_msg (int configNr, u32 status)
742 return -ENOMEM; 739 return -ENOMEM;
743 resp = (rndis_indicate_status_msg_type *) r->buf; 740 resp = (rndis_indicate_status_msg_type *) r->buf;
744 741
745 resp->MessageType = __constant_cpu_to_le32 ( 742 resp->MessageType = cpu_to_le32 (
746 REMOTE_NDIS_INDICATE_STATUS_MSG); 743 REMOTE_NDIS_INDICATE_STATUS_MSG);
747 resp->MessageLength = __constant_cpu_to_le32 (20); 744 resp->MessageLength = cpu_to_le32 (20);
748 resp->Status = cpu_to_le32 (status); 745 resp->Status = cpu_to_le32 (status);
749 resp->StatusBufferLength = __constant_cpu_to_le32 (0); 746 resp->StatusBufferLength = cpu_to_le32 (0);
750 resp->StatusBufferOffset = __constant_cpu_to_le32 (0); 747 resp->StatusBufferOffset = cpu_to_le32 (0);
751 748
752 params->resp_avail(params->v); 749 params->resp_avail(params->v);
753 return 0; 750 return 0;
@@ -963,9 +960,9 @@ void rndis_add_hdr (struct sk_buff *skb)
963 return; 960 return;
964 header = (void *) skb_push (skb, sizeof *header); 961 header = (void *) skb_push (skb, sizeof *header);
965 memset (header, 0, sizeof *header); 962 memset (header, 0, sizeof *header);
966 header->MessageType = __constant_cpu_to_le32(REMOTE_NDIS_PACKET_MSG); 963 header->MessageType = cpu_to_le32(REMOTE_NDIS_PACKET_MSG);
967 header->MessageLength = cpu_to_le32(skb->len); 964 header->MessageLength = cpu_to_le32(skb->len);
968 header->DataOffset = __constant_cpu_to_le32 (36); 965 header->DataOffset = cpu_to_le32 (36);
969 header->DataLength = cpu_to_le32(skb->len - sizeof *header); 966 header->DataLength = cpu_to_le32(skb->len - sizeof *header);
970} 967}
971 968
@@ -1029,7 +1026,7 @@ int rndis_rm_hdr(struct sk_buff *skb)
1029 __le32 *tmp = (void *) skb->data; 1026 __le32 *tmp = (void *) skb->data;
1030 1027
1031 /* MessageType, MessageLength */ 1028 /* MessageType, MessageLength */
1032 if (__constant_cpu_to_le32(REMOTE_NDIS_PACKET_MSG) 1029 if (cpu_to_le32(REMOTE_NDIS_PACKET_MSG)
1033 != get_unaligned(tmp++)) 1030 != get_unaligned(tmp++))
1034 return -EINVAL; 1031 return -EINVAL;
1035 tmp++; 1032 tmp++;