aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2012-05-11 18:15:39 -0400
committerDavid S. Miller <davem@davemloft.net>2012-05-12 15:00:45 -0400
commit7390e8b0dee778b0a964337558990a91094e679a (patch)
treeaf1fc449dcfa152e55e6b8544ff3102ab4f44891 /drivers/net/usb
parent647c0c70e8a44e359d1d90d9d067d0b6b611076a (diff)
usb/net: rndis: inline the cpu_to_le32() macro
The header file <linux/usb/rndis_host.h> used a number of #defines that included the cpu_to_le32() macro to assure the result will be in LE endianness. Inlining this into the code instead of using it in the code definitions yields consolidation opportunities later on as you will see in the following patches. The individual drivers also used local defines - all are switched over to the pattern of doing the conversion at the call sites instead. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/rndis_host.c54
1 files changed, 28 insertions, 26 deletions
diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c
index c8f1b5b3aff..3b7ddfd25fd 100644
--- a/drivers/net/usb/rndis_host.c
+++ b/drivers/net/usb/rndis_host.c
@@ -78,10 +78,10 @@ static void rndis_msg_indicate(struct usbnet *dev, struct rndis_indicate *msg,
78 dev->driver_info->indication(dev, msg, buflen); 78 dev->driver_info->indication(dev, msg, buflen);
79 } else { 79 } else {
80 switch (msg->status) { 80 switch (msg->status) {
81 case RNDIS_STATUS_MEDIA_CONNECT: 81 case cpu_to_le32(RNDIS_STATUS_MEDIA_CONNECT):
82 dev_info(udev, "rndis media connect\n"); 82 dev_info(udev, "rndis media connect\n");
83 break; 83 break;
84 case RNDIS_STATUS_MEDIA_DISCONNECT: 84 case cpu_to_le32(RNDIS_STATUS_MEDIA_DISCONNECT):
85 dev_info(udev, "rndis media disconnect\n"); 85 dev_info(udev, "rndis media disconnect\n");
86 break; 86 break;
87 default: 87 default:
@@ -117,8 +117,8 @@ int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen)
117 */ 117 */
118 118
119 /* Issue the request; xid is unique, don't bother byteswapping it */ 119 /* Issue the request; xid is unique, don't bother byteswapping it */
120 if (likely(buf->msg_type != RNDIS_MSG_HALT && 120 if (likely(buf->msg_type != cpu_to_le32(RNDIS_MSG_HALT) &&
121 buf->msg_type != RNDIS_MSG_RESET)) { 121 buf->msg_type != cpu_to_le32(RNDIS_MSG_RESET))) {
122 xid = dev->xid++; 122 xid = dev->xid++;
123 if (!xid) 123 if (!xid)
124 xid = dev->xid++; 124 xid = dev->xid++;
@@ -149,7 +149,7 @@ int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen)
149 } 149 }
150 150
151 /* Poll the control channel; the request probably completed immediately */ 151 /* Poll the control channel; the request probably completed immediately */
152 rsp = buf->msg_type | RNDIS_MSG_COMPLETION; 152 rsp = buf->msg_type | cpu_to_le32(RNDIS_MSG_COMPLETION);
153 for (count = 0; count < 10; count++) { 153 for (count = 0; count < 10; count++) {
154 memset(buf, 0, CONTROL_BUFFER_SIZE); 154 memset(buf, 0, CONTROL_BUFFER_SIZE);
155 retval = usb_control_msg(dev->udev, 155 retval = usb_control_msg(dev->udev,
@@ -164,9 +164,10 @@ int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen)
164 request_id = (__force u32) buf->request_id; 164 request_id = (__force u32) buf->request_id;
165 if (likely(buf->msg_type == rsp)) { 165 if (likely(buf->msg_type == rsp)) {
166 if (likely(request_id == xid)) { 166 if (likely(request_id == xid)) {
167 if (unlikely(rsp == RNDIS_MSG_RESET_C)) 167 if (unlikely(rsp ==
168 cpu_to_le32(RNDIS_MSG_RESET_C)))
168 return 0; 169 return 0;
169 if (likely(RNDIS_STATUS_SUCCESS 170 if (likely(cpu_to_le32(RNDIS_STATUS_SUCCESS)
170 == buf->status)) 171 == buf->status))
171 return 0; 172 return 0;
172 dev_dbg(&info->control->dev, 173 dev_dbg(&info->control->dev,
@@ -179,16 +180,15 @@ int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen)
179 request_id, xid); 180 request_id, xid);
180 /* then likely retry */ 181 /* then likely retry */
181 } else switch (buf->msg_type) { 182 } else switch (buf->msg_type) {
182 case RNDIS_MSG_INDICATE: /* fault/event */ 183 case cpu_to_le32(RNDIS_MSG_INDICATE): /* fault/event */
183 rndis_msg_indicate(dev, (void *)buf, buflen); 184 rndis_msg_indicate(dev, (void *)buf, buflen);
184
185 break; 185 break;
186 case RNDIS_MSG_KEEPALIVE: { /* ping */ 186 case cpu_to_le32(RNDIS_MSG_KEEPALIVE): { /* ping */
187 struct rndis_keepalive_c *msg = (void *)buf; 187 struct rndis_keepalive_c *msg = (void *)buf;
188 188
189 msg->msg_type = RNDIS_MSG_KEEPALIVE_C; 189 msg->msg_type = cpu_to_le32(RNDIS_MSG_KEEPALIVE_C);
190 msg->msg_len = cpu_to_le32(sizeof *msg); 190 msg->msg_len = cpu_to_le32(sizeof *msg);
191 msg->status = RNDIS_STATUS_SUCCESS; 191 msg->status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
192 retval = usb_control_msg(dev->udev, 192 retval = usb_control_msg(dev->udev,
193 usb_sndctrlpipe(dev->udev, 0), 193 usb_sndctrlpipe(dev->udev, 0),
194 USB_CDC_SEND_ENCAPSULATED_COMMAND, 194 USB_CDC_SEND_ENCAPSULATED_COMMAND,
@@ -251,7 +251,7 @@ static int rndis_query(struct usbnet *dev, struct usb_interface *intf,
251 u.buf = buf; 251 u.buf = buf;
252 252
253 memset(u.get, 0, sizeof *u.get + in_len); 253 memset(u.get, 0, sizeof *u.get + in_len);
254 u.get->msg_type = RNDIS_MSG_QUERY; 254 u.get->msg_type = cpu_to_le32(RNDIS_MSG_QUERY);
255 u.get->msg_len = cpu_to_le32(sizeof *u.get + in_len); 255 u.get->msg_len = cpu_to_le32(sizeof *u.get + in_len);
256 u.get->oid = oid; 256 u.get->oid = oid;
257 u.get->len = cpu_to_le32(in_len); 257 u.get->len = cpu_to_le32(in_len);
@@ -324,7 +324,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
324 if (retval < 0) 324 if (retval < 0)
325 goto fail; 325 goto fail;
326 326
327 u.init->msg_type = RNDIS_MSG_INIT; 327 u.init->msg_type = cpu_to_le32(RNDIS_MSG_INIT);
328 u.init->msg_len = cpu_to_le32(sizeof *u.init); 328 u.init->msg_len = cpu_to_le32(sizeof *u.init);
329 u.init->major_version = cpu_to_le32(1); 329 u.init->major_version = cpu_to_le32(1);
330 u.init->minor_version = cpu_to_le32(0); 330 u.init->minor_version = cpu_to_le32(0);
@@ -395,22 +395,23 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
395 /* Check physical medium */ 395 /* Check physical medium */
396 phym = NULL; 396 phym = NULL;
397 reply_len = sizeof *phym; 397 reply_len = sizeof *phym;
398 retval = rndis_query(dev, intf, u.buf, OID_GEN_PHYSICAL_MEDIUM, 398 retval = rndis_query(dev, intf, u.buf,
399 cpu_to_le32(OID_GEN_PHYSICAL_MEDIUM),
399 0, (void **) &phym, &reply_len); 400 0, (void **) &phym, &reply_len);
400 if (retval != 0 || !phym) { 401 if (retval != 0 || !phym) {
401 /* OID is optional so don't fail here. */ 402 /* OID is optional so don't fail here. */
402 phym_unspec = RNDIS_PHYSICAL_MEDIUM_UNSPECIFIED; 403 phym_unspec = cpu_to_le32(RNDIS_PHYSICAL_MEDIUM_UNSPECIFIED);
403 phym = &phym_unspec; 404 phym = &phym_unspec;
404 } 405 }
405 if ((flags & FLAG_RNDIS_PHYM_WIRELESS) && 406 if ((flags & FLAG_RNDIS_PHYM_WIRELESS) &&
406 *phym != RNDIS_PHYSICAL_MEDIUM_WIRELESS_LAN) { 407 *phym != cpu_to_le32(RNDIS_PHYSICAL_MEDIUM_WIRELESS_LAN)) {
407 netif_dbg(dev, probe, dev->net, 408 netif_dbg(dev, probe, dev->net,
408 "driver requires wireless physical medium, but device is not\n"); 409 "driver requires wireless physical medium, but device is not\n");
409 retval = -ENODEV; 410 retval = -ENODEV;
410 goto halt_fail_and_release; 411 goto halt_fail_and_release;
411 } 412 }
412 if ((flags & FLAG_RNDIS_PHYM_NOT_WIRELESS) && 413 if ((flags & FLAG_RNDIS_PHYM_NOT_WIRELESS) &&
413 *phym == RNDIS_PHYSICAL_MEDIUM_WIRELESS_LAN) { 414 *phym == cpu_to_le32(RNDIS_PHYSICAL_MEDIUM_WIRELESS_LAN)) {
414 netif_dbg(dev, probe, dev->net, 415 netif_dbg(dev, probe, dev->net,
415 "driver requires non-wireless physical medium, but device is wireless.\n"); 416 "driver requires non-wireless physical medium, but device is wireless.\n");
416 retval = -ENODEV; 417 retval = -ENODEV;
@@ -419,7 +420,8 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
419 420
420 /* Get designated host ethernet address */ 421 /* Get designated host ethernet address */
421 reply_len = ETH_ALEN; 422 reply_len = ETH_ALEN;
422 retval = rndis_query(dev, intf, u.buf, OID_802_3_PERMANENT_ADDRESS, 423 retval = rndis_query(dev, intf, u.buf,
424 cpu_to_le32(OID_802_3_PERMANENT_ADDRESS),
423 48, (void **) &bp, &reply_len); 425 48, (void **) &bp, &reply_len);
424 if (unlikely(retval< 0)) { 426 if (unlikely(retval< 0)) {
425 dev_err(&intf->dev, "rndis get ethaddr, %d\n", retval); 427 dev_err(&intf->dev, "rndis get ethaddr, %d\n", retval);
@@ -430,12 +432,12 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
430 432
431 /* set a nonzero filter to enable data transfers */ 433 /* set a nonzero filter to enable data transfers */
432 memset(u.set, 0, sizeof *u.set); 434 memset(u.set, 0, sizeof *u.set);
433 u.set->msg_type = RNDIS_MSG_SET; 435 u.set->msg_type = cpu_to_le32(RNDIS_MSG_SET);
434 u.set->msg_len = cpu_to_le32(4 + sizeof *u.set); 436 u.set->msg_len = cpu_to_le32(4 + sizeof *u.set);
435 u.set->oid = OID_GEN_CURRENT_PACKET_FILTER; 437 u.set->oid = cpu_to_le32(OID_GEN_CURRENT_PACKET_FILTER);
436 u.set->len = cpu_to_le32(4); 438 u.set->len = cpu_to_le32(4);
437 u.set->offset = cpu_to_le32((sizeof *u.set) - 8); 439 u.set->offset = cpu_to_le32((sizeof *u.set) - 8);
438 *(__le32 *)(u.buf + sizeof *u.set) = RNDIS_DEFAULT_FILTER; 440 *(__le32 *)(u.buf + sizeof *u.set) = cpu_to_le32(RNDIS_DEFAULT_FILTER);
439 441
440 retval = rndis_command(dev, u.header, CONTROL_BUFFER_SIZE); 442 retval = rndis_command(dev, u.header, CONTROL_BUFFER_SIZE);
441 if (unlikely(retval < 0)) { 443 if (unlikely(retval < 0)) {
@@ -450,7 +452,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
450 452
451halt_fail_and_release: 453halt_fail_and_release:
452 memset(u.halt, 0, sizeof *u.halt); 454 memset(u.halt, 0, sizeof *u.halt);
453 u.halt->msg_type = RNDIS_MSG_HALT; 455 u.halt->msg_type = cpu_to_le32(RNDIS_MSG_HALT);
454 u.halt->msg_len = cpu_to_le32(sizeof *u.halt); 456 u.halt->msg_len = cpu_to_le32(sizeof *u.halt);
455 (void) rndis_command(dev, (void *)u.halt, CONTROL_BUFFER_SIZE); 457 (void) rndis_command(dev, (void *)u.halt, CONTROL_BUFFER_SIZE);
456fail_and_release: 458fail_and_release:
@@ -475,7 +477,7 @@ void rndis_unbind(struct usbnet *dev, struct usb_interface *intf)
475 /* try to clear any rndis state/activity (no i/o from stack!) */ 477 /* try to clear any rndis state/activity (no i/o from stack!) */
476 halt = kzalloc(CONTROL_BUFFER_SIZE, GFP_KERNEL); 478 halt = kzalloc(CONTROL_BUFFER_SIZE, GFP_KERNEL);
477 if (halt) { 479 if (halt) {
478 halt->msg_type = RNDIS_MSG_HALT; 480 halt->msg_type = cpu_to_le32(RNDIS_MSG_HALT);
479 halt->msg_len = cpu_to_le32(sizeof *halt); 481 halt->msg_len = cpu_to_le32(sizeof *halt);
480 (void) rndis_command(dev, (void *)halt, CONTROL_BUFFER_SIZE); 482 (void) rndis_command(dev, (void *)halt, CONTROL_BUFFER_SIZE);
481 kfree(halt); 483 kfree(halt);
@@ -501,7 +503,7 @@ int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
501 data_len = le32_to_cpu(hdr->data_len); 503 data_len = le32_to_cpu(hdr->data_len);
502 504
503 /* don't choke if we see oob, per-packet data, etc */ 505 /* don't choke if we see oob, per-packet data, etc */
504 if (unlikely(hdr->msg_type != RNDIS_MSG_PACKET || 506 if (unlikely(hdr->msg_type != cpu_to_le32(RNDIS_MSG_PACKET) ||
505 skb->len < msg_len || 507 skb->len < msg_len ||
506 (data_offset + data_len + 8) > msg_len)) { 508 (data_offset + data_len + 8) > msg_len)) {
507 dev->net->stats.rx_frame_errors++; 509 dev->net->stats.rx_frame_errors++;
@@ -569,7 +571,7 @@ rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
569fill: 571fill:
570 hdr = (void *) __skb_push(skb, sizeof *hdr); 572 hdr = (void *) __skb_push(skb, sizeof *hdr);
571 memset(hdr, 0, sizeof *hdr); 573 memset(hdr, 0, sizeof *hdr);
572 hdr->msg_type = RNDIS_MSG_PACKET; 574 hdr->msg_type = cpu_to_le32(RNDIS_MSG_PACKET);
573 hdr->msg_len = cpu_to_le32(skb->len); 575 hdr->msg_len = cpu_to_le32(skb->len);
574 hdr->data_offset = cpu_to_le32(sizeof(*hdr) - 8); 576 hdr->data_offset = cpu_to_le32(sizeof(*hdr) - 8);
575 hdr->data_len = cpu_to_le32(len); 577 hdr->data_len = cpu_to_le32(len);