aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/zd1211rw
diff options
context:
space:
mode:
authorUlrich Kunitz <kune@deine-taler.de>2006-11-21 19:05:53 -0500
committerJeff Garzik <jeff@garzik.org>2006-12-02 00:12:05 -0500
commit741fec53f268b691b869ffc70023319406e0cc97 (patch)
tree47ea2334fd44daaaa19b9a3d22d34466d0250069 /drivers/net/wireless/zd1211rw
parent84bc715c465f76584fc5127955fca0c61592e04b (diff)
[PATCH] zd1211rw: cleanups
Bit-field constants in zd_chip.h are now defined using a shift expression. The value 0x08 is now (1 << 3). The fix is intended to improve readability. Remove misleading comment in zd_mac.c: The function already returns -EPERM in managed mode (IW_MODE_INFRA). Remove unused code in zd_mac.c: The unused code intended for debugging rx_status values is no longer useful. Added dump_stack() to ZD_ASSERT macro: Output of the stack helps to debug assertions. Keep in mind that the ZD_ASSERT() macro only results in code, if DEBUG is defined. Improved comments for filter_rx() zd_usb.c: Added driver name to module init and exit functions Signed-off-by: Ulrich Kunitz <kune@deine-taler.de> Signed-off-by: Daniel Drake <dsd@gentoo.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/zd1211rw')
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.h80
-rw-r--r--drivers/net/wireless/zd1211rw/zd_def.h1
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c71
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c11
4 files changed, 53 insertions, 110 deletions
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.h b/drivers/net/wireless/zd1211rw/zd_chip.h
index ae59597ce4e1..f441cf40f74b 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.h
+++ b/drivers/net/wireless/zd1211rw/zd_chip.h
@@ -337,24 +337,24 @@
337#define CR_MAC_PS_STATE CTL_REG(0x050C) 337#define CR_MAC_PS_STATE CTL_REG(0x050C)
338 338
339#define CR_INTERRUPT CTL_REG(0x0510) 339#define CR_INTERRUPT CTL_REG(0x0510)
340#define INT_TX_COMPLETE 0x00000001 340#define INT_TX_COMPLETE (1 << 0)
341#define INT_RX_COMPLETE 0x00000002 341#define INT_RX_COMPLETE (1 << 1)
342#define INT_RETRY_FAIL 0x00000004 342#define INT_RETRY_FAIL (1 << 2)
343#define INT_WAKEUP 0x00000008 343#define INT_WAKEUP (1 << 3)
344#define INT_DTIM_NOTIFY 0x00000020 344#define INT_DTIM_NOTIFY (1 << 5)
345#define INT_CFG_NEXT_BCN 0x00000040 345#define INT_CFG_NEXT_BCN (1 << 6)
346#define INT_BUS_ABORT 0x00000080 346#define INT_BUS_ABORT (1 << 7)
347#define INT_TX_FIFO_READY 0x00000100 347#define INT_TX_FIFO_READY (1 << 8)
348#define INT_UART 0x00000200 348#define INT_UART (1 << 9)
349#define INT_TX_COMPLETE_EN 0x00010000 349#define INT_TX_COMPLETE_EN (1 << 16)
350#define INT_RX_COMPLETE_EN 0x00020000 350#define INT_RX_COMPLETE_EN (1 << 17)
351#define INT_RETRY_FAIL_EN 0x00040000 351#define INT_RETRY_FAIL_EN (1 << 18)
352#define INT_WAKEUP_EN 0x00080000 352#define INT_WAKEUP_EN (1 << 19)
353#define INT_DTIM_NOTIFY_EN 0x00200000 353#define INT_DTIM_NOTIFY_EN (1 << 21)
354#define INT_CFG_NEXT_BCN_EN 0x00400000 354#define INT_CFG_NEXT_BCN_EN (1 << 22)
355#define INT_BUS_ABORT_EN 0x00800000 355#define INT_BUS_ABORT_EN (1 << 23)
356#define INT_TX_FIFO_READY_EN 0x01000000 356#define INT_TX_FIFO_READY_EN (1 << 24)
357#define INT_UART_EN 0x02000000 357#define INT_UART_EN (1 << 25)
358 358
359#define CR_TSF_LOW_PART CTL_REG(0x0514) 359#define CR_TSF_LOW_PART CTL_REG(0x0514)
360#define CR_TSF_HIGH_PART CTL_REG(0x0518) 360#define CR_TSF_HIGH_PART CTL_REG(0x0518)
@@ -398,18 +398,18 @@
398 * device will use a rate in this table that is less than or equal to the rate 398 * device will use a rate in this table that is less than or equal to the rate
399 * of the incoming frame which prompted the response */ 399 * of the incoming frame which prompted the response */
400#define CR_BASIC_RATE_TBL CTL_REG(0x0630) 400#define CR_BASIC_RATE_TBL CTL_REG(0x0630)
401#define CR_RATE_1M 0x0001 /* 802.11b */ 401#define CR_RATE_1M (1 << 0) /* 802.11b */
402#define CR_RATE_2M 0x0002 /* 802.11b */ 402#define CR_RATE_2M (1 << 1) /* 802.11b */
403#define CR_RATE_5_5M 0x0004 /* 802.11b */ 403#define CR_RATE_5_5M (1 << 2) /* 802.11b */
404#define CR_RATE_11M 0x0008 /* 802.11b */ 404#define CR_RATE_11M (1 << 3) /* 802.11b */
405#define CR_RATE_6M 0x0100 /* 802.11g */ 405#define CR_RATE_6M (1 << 8) /* 802.11g */
406#define CR_RATE_9M 0x0200 /* 802.11g */ 406#define CR_RATE_9M (1 << 9) /* 802.11g */
407#define CR_RATE_12M 0x0400 /* 802.11g */ 407#define CR_RATE_12M (1 << 10) /* 802.11g */
408#define CR_RATE_18M 0x0800 /* 802.11g */ 408#define CR_RATE_18M (1 << 11) /* 802.11g */
409#define CR_RATE_24M 0x1000 /* 802.11g */ 409#define CR_RATE_24M (1 << 12) /* 802.11g */
410#define CR_RATE_36M 0x2000 /* 802.11g */ 410#define CR_RATE_36M (1 << 13) /* 802.11g */
411#define CR_RATE_48M 0x4000 /* 802.11g */ 411#define CR_RATE_48M (1 << 14) /* 802.11g */
412#define CR_RATE_54M 0x8000 /* 802.11g */ 412#define CR_RATE_54M (1 << 15) /* 802.11g */
413#define CR_RATES_80211G 0xff00 413#define CR_RATES_80211G 0xff00
414#define CR_RATES_80211B 0x000f 414#define CR_RATES_80211B 0x000f
415 415
@@ -426,9 +426,9 @@
426/* register for controlling the LEDS */ 426/* register for controlling the LEDS */
427#define CR_LED CTL_REG(0x0644) 427#define CR_LED CTL_REG(0x0644)
428/* masks for controlling LEDs */ 428/* masks for controlling LEDs */
429#define LED1 0x0100 429#define LED1 (1 << 8)
430#define LED2 0x0200 430#define LED2 (1 << 9)
431#define LED_SW 0x0400 431#define LED_SW (1 << 10)
432 432
433/* Seems to indicate that the configuration is over. 433/* Seems to indicate that the configuration is over.
434 */ 434 */
@@ -455,18 +455,18 @@
455 * registers, so one could argue it is a LOCK bit. But calling it 455 * registers, so one could argue it is a LOCK bit. But calling it
456 * LOCK_PHY_REGS makes it confusing. 456 * LOCK_PHY_REGS makes it confusing.
457 */ 457 */
458#define UNLOCK_PHY_REGS 0x0080 458#define UNLOCK_PHY_REGS (1 << 7)
459 459
460#define CR_DEVICE_STATE CTL_REG(0x0684) 460#define CR_DEVICE_STATE CTL_REG(0x0684)
461#define CR_UNDERRUN_CNT CTL_REG(0x0688) 461#define CR_UNDERRUN_CNT CTL_REG(0x0688)
462 462
463#define CR_RX_FILTER CTL_REG(0x068c) 463#define CR_RX_FILTER CTL_REG(0x068c)
464#define RX_FILTER_ASSOC_RESPONSE 0x0002 464#define RX_FILTER_ASSOC_RESPONSE (1 << 1)
465#define RX_FILTER_REASSOC_RESPONSE 0x0008 465#define RX_FILTER_REASSOC_RESPONSE (1 << 3)
466#define RX_FILTER_PROBE_RESPONSE 0x0020 466#define RX_FILTER_PROBE_RESPONSE (1 << 5)
467#define RX_FILTER_BEACON 0x0100 467#define RX_FILTER_BEACON (1 << 8)
468#define RX_FILTER_DISASSOC 0x0400 468#define RX_FILTER_DISASSOC (1 << 10)
469#define RX_FILTER_AUTH 0x0800 469#define RX_FILTER_AUTH (1 << 11)
470#define AP_RX_FILTER 0x0400feff 470#define AP_RX_FILTER 0x0400feff
471#define STA_RX_FILTER 0x0000ffff 471#define STA_RX_FILTER 0x0000ffff
472 472
diff --git a/drivers/net/wireless/zd1211rw/zd_def.h b/drivers/net/wireless/zd1211rw/zd_def.h
index a13ec72eb304..fb22f62cf1f3 100644
--- a/drivers/net/wireless/zd1211rw/zd_def.h
+++ b/drivers/net/wireless/zd1211rw/zd_def.h
@@ -39,6 +39,7 @@ do { \
39 if (!(x)) { \ 39 if (!(x)) { \
40 pr_debug("%s:%d ASSERT %s VIOLATED!\n", \ 40 pr_debug("%s:%d ASSERT %s VIOLATED!\n", \
41 __FILE__, __LINE__, __stringify(x)); \ 41 __FILE__, __LINE__, __stringify(x)); \
42 dump_stack(); \
42 } \ 43 } \
43} while (0) 44} while (0)
44#else 45#else
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 7845b6dac832..0bb53f0b8bdd 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -295,7 +295,6 @@ static void set_channel(struct net_device *netdev, u8 channel)
295 zd_chip_set_channel(&mac->chip, channel); 295 zd_chip_set_channel(&mac->chip, channel);
296} 296}
297 297
298/* TODO: Should not work in Managed mode. */
299int zd_mac_request_channel(struct zd_mac *mac, u8 channel) 298int zd_mac_request_channel(struct zd_mac *mac, u8 channel)
300{ 299{
301 unsigned long lock_flags; 300 unsigned long lock_flags;
@@ -773,9 +772,11 @@ static int is_data_packet_for_us(struct ieee80211_device *ieee,
773 (netdev->flags & IFF_PROMISC); 772 (netdev->flags & IFF_PROMISC);
774} 773}
775 774
776/* Filters receiving packets. If it returns 1 send it to ieee80211_rx, if 0 775/* Filters received packets. The function returns 1 if the packet should be
777 * return. If an error is detected -EINVAL is returned. ieee80211_rx_mgt() is 776 * forwarded to ieee80211_rx(). If the packet should be ignored the function
778 * called here. 777 * returns 0. If an invalid packet is found the function returns -EINVAL.
778 *
779 * The function calls ieee80211_rx_mgt() directly.
779 * 780 *
780 * It has been based on ieee80211_rx_any. 781 * It has been based on ieee80211_rx_any.
781 */ 782 */
@@ -801,9 +802,9 @@ static int filter_rx(struct ieee80211_device *ieee,
801 ieee80211_rx_mgt(ieee, hdr, stats); 802 ieee80211_rx_mgt(ieee, hdr, stats);
802 return 0; 803 return 0;
803 case IEEE80211_FTYPE_CTL: 804 case IEEE80211_FTYPE_CTL:
804 /* Ignore invalid short buffers */
805 return 0; 805 return 0;
806 case IEEE80211_FTYPE_DATA: 806 case IEEE80211_FTYPE_DATA:
807 /* Ignore invalid short buffers */
807 if (length < sizeof(struct ieee80211_hdr_3addr)) 808 if (length < sizeof(struct ieee80211_hdr_3addr))
808 return -EINVAL; 809 return -EINVAL;
809 return is_data_packet_for_us(ieee, hdr); 810 return is_data_packet_for_us(ieee, hdr);
@@ -1019,66 +1020,6 @@ struct iw_statistics *zd_mac_get_wireless_stats(struct net_device *ndev)
1019 return iw_stats; 1020 return iw_stats;
1020} 1021}
1021 1022
1022#ifdef DEBUG
1023static const char* decryption_types[] = {
1024 [ZD_RX_NO_WEP] = "none",
1025 [ZD_RX_WEP64] = "WEP64",
1026 [ZD_RX_TKIP] = "TKIP",
1027 [ZD_RX_AES] = "AES",
1028 [ZD_RX_WEP128] = "WEP128",
1029 [ZD_RX_WEP256] = "WEP256",
1030};
1031
1032static const char *decryption_type_string(u8 type)
1033{
1034 const char *s;
1035
1036 if (type < ARRAY_SIZE(decryption_types)) {
1037 s = decryption_types[type];
1038 } else {
1039 s = NULL;
1040 }
1041 return s ? s : "unknown";
1042}
1043
1044static int is_ofdm(u8 frame_status)
1045{
1046 return (frame_status & ZD_RX_OFDM);
1047}
1048
1049void zd_dump_rx_status(const struct rx_status *status)
1050{
1051 const char* modulation;
1052 u8 quality;
1053
1054 if (is_ofdm(status->frame_status)) {
1055 modulation = "ofdm";
1056 quality = status->signal_quality_ofdm;
1057 } else {
1058 modulation = "cck";
1059 quality = status->signal_quality_cck;
1060 }
1061 pr_debug("rx status %s strength %#04x qual %#04x decryption %s\n",
1062 modulation, status->signal_strength, quality,
1063 decryption_type_string(status->decryption_type));
1064 if (status->frame_status & ZD_RX_ERROR) {
1065 pr_debug("rx error %s%s%s%s%s%s\n",
1066 (status->frame_status & ZD_RX_TIMEOUT_ERROR) ?
1067 "timeout " : "",
1068 (status->frame_status & ZD_RX_FIFO_OVERRUN_ERROR) ?
1069 "fifo " : "",
1070 (status->frame_status & ZD_RX_DECRYPTION_ERROR) ?
1071 "decryption " : "",
1072 (status->frame_status & ZD_RX_CRC32_ERROR) ?
1073 "crc32 " : "",
1074 (status->frame_status & ZD_RX_NO_ADDR1_MATCH_ERROR) ?
1075 "addr1 " : "",
1076 (status->frame_status & ZD_RX_CRC16_ERROR) ?
1077 "crc16" : "");
1078 }
1079}
1080#endif /* DEBUG */
1081
1082#define LINK_LED_WORK_DELAY HZ 1023#define LINK_LED_WORK_DELAY HZ
1083 1024
1084static void link_led_handler(void *p) 1025static void link_led_handler(void *p)
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
index 34524b73324f..c3449cfae7e8 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.c
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -1116,27 +1116,28 @@ static int __init usb_init(void)
1116{ 1116{
1117 int r; 1117 int r;
1118 1118
1119 pr_debug("usb_init()\n"); 1119 pr_debug("%s usb_init()\n", driver.name);
1120 1120
1121 zd_workqueue = create_singlethread_workqueue(driver.name); 1121 zd_workqueue = create_singlethread_workqueue(driver.name);
1122 if (zd_workqueue == NULL) { 1122 if (zd_workqueue == NULL) {
1123 printk(KERN_ERR "%s: couldn't create workqueue\n", driver.name); 1123 printk(KERN_ERR "%s couldn't create workqueue\n", driver.name);
1124 return -ENOMEM; 1124 return -ENOMEM;
1125 } 1125 }
1126 1126
1127 r = usb_register(&driver); 1127 r = usb_register(&driver);
1128 if (r) { 1128 if (r) {
1129 printk(KERN_ERR "usb_register() failed. Error number %d\n", r); 1129 printk(KERN_ERR "%s usb_register() failed. Error number %d\n",
1130 driver.name, r);
1130 return r; 1131 return r;
1131 } 1132 }
1132 1133
1133 pr_debug("zd1211rw initialized\n"); 1134 pr_debug("%s initialized\n", driver.name);
1134 return 0; 1135 return 0;
1135} 1136}
1136 1137
1137static void __exit usb_exit(void) 1138static void __exit usb_exit(void)
1138{ 1139{
1139 pr_debug("usb_exit()\n"); 1140 pr_debug("%s usb_exit()\n", driver.name);
1140 usb_deregister(&driver); 1141 usb_deregister(&driver);
1141 destroy_workqueue(zd_workqueue); 1142 destroy_workqueue(zd_workqueue);
1142} 1143}