aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/net
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>2006-05-26 16:07:48 -0400
committerJohn W. Linville <linville@tuxdriver.com>2006-06-05 15:34:18 -0400
commit2a8063403112030f1748e207d97d4f8654754dff (patch)
tree5a6d789aaf243d96807a3a8431c4c741a469e318 /drivers/usb/net
parentf6882a0688ea83db5fc2f3491ac9fcdce0834cc7 (diff)
[PATCH] usb wifi: zd1201 cleanups
Cleanup coding style and other small stuff in zd1201. No real code changes. Signed-off-by: Pavel Machek <pavel@suse.cz> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/usb/net')
-rw-r--r--drivers/usb/net/zd1201.c67
1 files changed, 26 insertions, 41 deletions
diff --git a/drivers/usb/net/zd1201.c b/drivers/usb/net/zd1201.c
index 9b1e4ed1d07e..662ecc8a33ff 100644
--- a/drivers/usb/net/zd1201.c
+++ b/drivers/usb/net/zd1201.c
@@ -33,7 +33,7 @@ static struct usb_device_id zd1201_table[] = {
33 {} 33 {}
34}; 34};
35 35
36static int ap = 0; /* Are we an AP or a normal station? */ 36static int ap; /* Are we an AP or a normal station? */
37 37
38#define ZD1201_VERSION "0.15" 38#define ZD1201_VERSION "0.15"
39 39
@@ -49,7 +49,7 @@ MODULE_DEVICE_TABLE(usb, zd1201_table);
49static int zd1201_fw_upload(struct usb_device *dev, int apfw) 49static int zd1201_fw_upload(struct usb_device *dev, int apfw)
50{ 50{
51 const struct firmware *fw_entry; 51 const struct firmware *fw_entry;
52 char* data; 52 char *data;
53 unsigned long len; 53 unsigned long len;
54 int err; 54 int err;
55 unsigned char ret; 55 unsigned char ret;
@@ -65,7 +65,7 @@ static int zd1201_fw_upload(struct usb_device *dev, int apfw)
65 if (err) { 65 if (err) {
66 dev_err(&dev->dev, "Failed to load %s firmware file!\n", fwfile); 66 dev_err(&dev->dev, "Failed to load %s firmware file!\n", fwfile);
67 dev_err(&dev->dev, "Make sure the hotplug firmware loader is installed.\n"); 67 dev_err(&dev->dev, "Make sure the hotplug firmware loader is installed.\n");
68 dev_err(&dev->dev, "Goto http://linux-lc100020.sourceforge.net for more info\n"); 68 dev_err(&dev->dev, "Goto http://linux-lc100020.sourceforge.net for more info.\n");
69 return err; 69 return err;
70 } 70 }
71 71
@@ -94,12 +94,12 @@ static int zd1201_fw_upload(struct usb_device *dev, int apfw)
94 USB_DIR_OUT | 0x40, 0, 0, NULL, 0, ZD1201_FW_TIMEOUT); 94 USB_DIR_OUT | 0x40, 0, 0, NULL, 0, ZD1201_FW_TIMEOUT);
95 if (err < 0) 95 if (err < 0)
96 goto exit; 96 goto exit;
97 97
98 err = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 0x4, 98 err = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 0x4,
99 USB_DIR_IN | 0x40, 0,0, &ret, sizeof(ret), ZD1201_FW_TIMEOUT); 99 USB_DIR_IN | 0x40, 0,0, &ret, sizeof(ret), ZD1201_FW_TIMEOUT);
100 if (err < 0) 100 if (err < 0)
101 goto exit; 101 goto exit;
102 102
103 if (ret & 0x80) { 103 if (ret & 0x80) {
104 err = -EIO; 104 err = -EIO;
105 goto exit; 105 goto exit;
@@ -166,13 +166,13 @@ static int zd1201_docmd(struct zd1201 *zd, int cmd, int parm0,
166 return -ENOMEM; 166 return -ENOMEM;
167 } 167 }
168 usb_fill_bulk_urb(urb, zd->usb, usb_sndbulkpipe(zd->usb, zd->endp_out2), 168 usb_fill_bulk_urb(urb, zd->usb, usb_sndbulkpipe(zd->usb, zd->endp_out2),
169 command, 16, zd1201_usbfree, zd); 169 command, 16, zd1201_usbfree, zd);
170 ret = usb_submit_urb(urb, GFP_ATOMIC); 170 ret = usb_submit_urb(urb, GFP_ATOMIC);
171 if (ret) { 171 if (ret) {
172 kfree(command); 172 kfree(command);
173 usb_free_urb(urb); 173 usb_free_urb(urb);
174 } 174 }
175 175
176 return ret; 176 return ret;
177} 177}
178 178
@@ -316,7 +316,7 @@ static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs)
316 fc = le16_to_cpu(*(__le16 *)&data[datalen-16]); 316 fc = le16_to_cpu(*(__le16 *)&data[datalen-16]);
317 seq = le16_to_cpu(*(__le16 *)&data[datalen-24]); 317 seq = le16_to_cpu(*(__le16 *)&data[datalen-24]);
318 318
319 if(zd->monitor) { 319 if (zd->monitor) {
320 if (datalen < 24) 320 if (datalen < 24)
321 goto resubmit; 321 goto resubmit;
322 if (!(skb = dev_alloc_skb(datalen+24))) 322 if (!(skb = dev_alloc_skb(datalen+24)))
@@ -364,7 +364,7 @@ static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs)
364 goto resubmit; 364 goto resubmit;
365 } 365 }
366 hlist_for_each_entry(frag, node, &zd->fraglist, fnode) 366 hlist_for_each_entry(frag, node, &zd->fraglist, fnode)
367 if(frag->seq == (seq&IEEE80211_SCTL_SEQ)) 367 if (frag->seq == (seq&IEEE80211_SCTL_SEQ))
368 break; 368 break;
369 if (!frag) 369 if (!frag)
370 goto resubmit; 370 goto resubmit;
@@ -376,7 +376,6 @@ static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs)
376 goto resubmit; 376 goto resubmit;
377 hlist_del_init(&frag->fnode); 377 hlist_del_init(&frag->fnode);
378 kfree(frag); 378 kfree(frag);
379 /* Fallthrough */
380 } else { 379 } else {
381 if (datalen<14) 380 if (datalen<14)
382 goto resubmit; 381 goto resubmit;
@@ -422,7 +421,7 @@ static int zd1201_getconfig(struct zd1201 *zd, int rid, void *riddata,
422 int rid_fid; 421 int rid_fid;
423 int length; 422 int length;
424 unsigned char *pdata; 423 unsigned char *pdata;
425 424
426 zd->rxdatas = 0; 425 zd->rxdatas = 0;
427 err = zd1201_docmd(zd, ZD1201_CMDCODE_ACCESS, rid, 0, 0); 426 err = zd1201_docmd(zd, ZD1201_CMDCODE_ACCESS, rid, 0, 0);
428 if (err) 427 if (err)
@@ -471,11 +470,11 @@ static int zd1201_getconfig(struct zd1201 *zd, int rid, void *riddata,
471 length = zd->rxlen; 470 length = zd->rxlen;
472 471
473 do { 472 do {
474 int actual_length; 473 int actual_length;
475 474
476 actual_length = (length > 64) ? 64 : length; 475 actual_length = (length > 64) ? 64 : length;
477 476
478 if(pdata[0] != 0x3) { 477 if (pdata[0] != 0x3) {
479 dev_dbg(&zd->usb->dev, "Rx Resource packet type error: %02X\n", 478 dev_dbg(&zd->usb->dev, "Rx Resource packet type error: %02X\n",
480 pdata[0]); 479 pdata[0]);
481 return -EINVAL; 480 return -EINVAL;
@@ -487,11 +486,10 @@ static int zd1201_getconfig(struct zd1201 *zd, int rid, void *riddata,
487 } 486 }
488 487
489 /* Skip the 4 bytes header (RID length and RID) */ 488 /* Skip the 4 bytes header (RID length and RID) */
490 if(i == 0) { 489 if (i == 0) {
491 pdata += 8; 490 pdata += 8;
492 actual_length -= 8; 491 actual_length -= 8;
493 } 492 } else {
494 else {
495 pdata += 4; 493 pdata += 4;
496 actual_length -= 4; 494 actual_length -= 4;
497 } 495 }
@@ -620,7 +618,7 @@ static int zd1201_drvr_start(struct zd1201 *zd)
620 short max; 618 short max;
621 __le16 zdmax; 619 __le16 zdmax;
622 unsigned char *buffer; 620 unsigned char *buffer;
623 621
624 buffer = kzalloc(ZD1201_RXSIZE, GFP_KERNEL); 622 buffer = kzalloc(ZD1201_RXSIZE, GFP_KERNEL);
625 if (!buffer) 623 if (!buffer)
626 return -ENOMEM; 624 return -ENOMEM;
@@ -632,7 +630,7 @@ static int zd1201_drvr_start(struct zd1201 *zd)
632 err = usb_submit_urb(zd->rx_urb, GFP_KERNEL); 630 err = usb_submit_urb(zd->rx_urb, GFP_KERNEL);
633 if (err) 631 if (err)
634 goto err_buffer; 632 goto err_buffer;
635 633
636 err = zd1201_docmd(zd, ZD1201_CMDCODE_INIT, 0, 0, 0); 634 err = zd1201_docmd(zd, ZD1201_CMDCODE_INIT, 0, 0, 0);
637 if (err) 635 if (err)
638 goto err_urb; 636 goto err_urb;
@@ -684,7 +682,7 @@ static int zd1201_enable(struct zd1201 *zd)
684static int zd1201_disable(struct zd1201 *zd) 682static int zd1201_disable(struct zd1201 *zd)
685{ 683{
686 int err; 684 int err;
687 685
688 if (!zd->mac_enabled) 686 if (!zd->mac_enabled)
689 return 0; 687 return 0;
690 if (zd->monitor) { 688 if (zd->monitor) {
@@ -764,7 +762,6 @@ static int zd1201_net_open(struct net_device *dev)
764static int zd1201_net_stop(struct net_device *dev) 762static int zd1201_net_stop(struct net_device *dev)
765{ 763{
766 netif_stop_queue(dev); 764 netif_stop_queue(dev);
767
768 return 0; 765 return 0;
769} 766}
770 767
@@ -915,7 +912,6 @@ static int zd1201_get_name(struct net_device *dev,
915 struct iw_request_info *info, char *name, char *extra) 912 struct iw_request_info *info, char *name, char *extra)
916{ 913{
917 strcpy(name, "IEEE 802.11b"); 914 strcpy(name, "IEEE 802.11b");
918
919 return 0; 915 return 0;
920} 916}
921 917
@@ -1013,11 +1009,10 @@ static int zd1201_set_mode(struct net_device *dev,
1013 if (err) 1009 if (err)
1014 return err; 1010 return err;
1015 } 1011 }
1016 zd->monitor=monitor; 1012 zd->monitor = monitor;
1017 /* If monitor mode is set we don't actually turn it on here since it 1013 /* If monitor mode is set we don't actually turn it on here since it
1018 * is done during mac reset anyway (see zd1201_mac_enable). 1014 * is done during mac reset anyway (see zd1201_mac_enable).
1019 */ 1015 */
1020
1021 zd1201_mac_reset(zd); 1016 zd1201_mac_reset(zd);
1022 1017
1023 return 0; 1018 return 0;
@@ -1117,7 +1112,7 @@ static int zd1201_get_wap(struct net_device *dev,
1117 zd->iwstats.qual.updated = 2; 1112 zd->iwstats.qual.updated = 2;
1118 } 1113 }
1119 1114
1120 return zd1201_getconfig(zd,ZD1201_RID_CURRENTBSSID,ap_addr->sa_data,6); 1115 return zd1201_getconfig(zd, ZD1201_RID_CURRENTBSSID, ap_addr->sa_data, 6);
1121} 1116}
1122 1117
1123static int zd1201_set_scan(struct net_device *dev, 1118static int zd1201_set_scan(struct net_device *dev,
@@ -1275,7 +1270,7 @@ static int zd1201_set_rate(struct net_device *dev,
1275 if (!rrq->fixed) { /* Also enable all lower bitrates */ 1270 if (!rrq->fixed) { /* Also enable all lower bitrates */
1276 rate |= rate-1; 1271 rate |= rate-1;
1277 } 1272 }
1278 1273
1279 err = zd1201_setconfig16(zd, ZD1201_RID_TXRATECNTL, rate); 1274 err = zd1201_setconfig16(zd, ZD1201_RID_TXRATECNTL, rate);
1280 if (err) 1275 if (err)
1281 return err; 1276 return err;
@@ -1486,7 +1481,7 @@ static int zd1201_get_encode(struct net_device *dev,
1486 return -EINVAL; 1481 return -EINVAL;
1487 1482
1488 erq->flags |= i+1; 1483 erq->flags |= i+1;
1489 1484
1490 erq->length = zd->encode_keylen[i]; 1485 erq->length = zd->encode_keylen[i];
1491 memcpy(key, zd->encode_keys[i], erq->length); 1486 memcpy(key, zd->encode_keys[i], erq->length);
1492 1487
@@ -1529,11 +1524,7 @@ static int zd1201_set_power(struct net_device *dev,
1529 return -EINVAL; 1524 return -EINVAL;
1530 } 1525 }
1531out: 1526out:
1532 err = zd1201_setconfig16(zd, ZD1201_RID_CNFPMENABLED, enabled); 1527 return zd1201_setconfig16(zd, ZD1201_RID_CNFPMENABLED, enabled);
1533 if (err)
1534 return err;
1535
1536 return 0;
1537} 1528}
1538 1529
1539static int zd1201_get_power(struct net_device *dev, 1530static int zd1201_get_power(struct net_device *dev,
@@ -1627,15 +1618,11 @@ static int zd1201_set_hostauth(struct net_device *dev,
1627 struct iw_request_info *info, struct iw_param *rrq, char *extra) 1618 struct iw_request_info *info, struct iw_param *rrq, char *extra)
1628{ 1619{
1629 struct zd1201 *zd = (struct zd1201 *)dev->priv; 1620 struct zd1201 *zd = (struct zd1201 *)dev->priv;
1630 int err;
1631 1621
1632 if (!zd->ap) 1622 if (!zd->ap)
1633 return -EOPNOTSUPP; 1623 return -EOPNOTSUPP;
1634 1624
1635 err = zd1201_setconfig16(zd, ZD1201_RID_CNFHOSTAUTH, rrq->value); 1625 return zd1201_setconfig16(zd, ZD1201_RID_CNFHOSTAUTH, rrq->value);
1636 if (err)
1637 return err;
1638 return 0;
1639} 1626}
1640 1627
1641static int zd1201_get_hostauth(struct net_device *dev, 1628static int zd1201_get_hostauth(struct net_device *dev,
@@ -1744,7 +1731,7 @@ static int zd1201_probe(struct usb_interface *interface,
1744{ 1731{
1745 struct zd1201 *zd; 1732 struct zd1201 *zd;
1746 struct usb_device *usb; 1733 struct usb_device *usb;
1747 int i, err; 1734 int err;
1748 short porttype; 1735 short porttype;
1749 char buf[IW_ESSID_MAX_SIZE+2]; 1736 char buf[IW_ESSID_MAX_SIZE+2];
1750 1737
@@ -1773,9 +1760,7 @@ static int zd1201_probe(struct usb_interface *interface,
1773 if (!zd->rx_urb || !zd->tx_urb) 1760 if (!zd->rx_urb || !zd->tx_urb)
1774 goto err_zd; 1761 goto err_zd;
1775 1762
1776 for(i = 0; i<100; i++) 1763 mdelay(100);
1777 udelay(1000);
1778
1779 err = zd1201_drvr_start(zd); 1764 err = zd1201_drvr_start(zd);
1780 if (err) 1765 if (err)
1781 goto err_zd; 1766 goto err_zd;
@@ -1833,7 +1818,7 @@ static int zd1201_probe(struct usb_interface *interface,
1833 goto err_net; 1818 goto err_net;
1834 dev_info(&usb->dev, "%s: ZD1201 USB Wireless interface\n", 1819 dev_info(&usb->dev, "%s: ZD1201 USB Wireless interface\n",
1835 zd->dev->name); 1820 zd->dev->name);
1836 1821
1837 usb_set_intfdata(interface, zd); 1822 usb_set_intfdata(interface, zd);
1838 return 0; 1823 return 0;
1839 1824