aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlrich Kunitz <kune@deine-taler.de>2006-08-12 13:00:17 -0400
committerJohn W. Linville <linville@tuxdriver.com>2006-08-14 15:43:23 -0400
commitc48cf125146852424bfe8e02033c6065dd0a4021 (patch)
treea6c94c29648f1fe3b16ea5384812947f3e15819c
parent943599ee2c3a018fd09c25d7a9e8703792dd618e (diff)
[PATCH] zd1211rw: cleanups
Add static to 2 internal functions. Thanks goes to Adrian Bunk, who found that. Also made some modifications to the clear functions: After a discussion on the mailing list, I implemented this code to have on the one hand sufficient test in debug mode, but on the other hand reduce the overhead for structure clearing to a minimum. A new macro ZD_MEMCLEAR is introduced, which produces code if DEBUG is set. Locks are not set anymore for structure clearing, but in debug mode, there is a verification, that the locks have not been set. Finally, removed a misleading comment regarding locking in the disconnect path. 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>
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c5
-rw-r--r--drivers/net/wireless/zd1211rw/zd_def.h6
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c6
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.h2
-rw-r--r--drivers/net/wireless/zd1211rw/zd_rf.c2
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c7
6 files changed, 15 insertions, 13 deletions
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index e7e92eccff5e..58419985e00f 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -42,12 +42,11 @@ void zd_chip_init(struct zd_chip *chip,
42 42
43void zd_chip_clear(struct zd_chip *chip) 43void zd_chip_clear(struct zd_chip *chip)
44{ 44{
45 mutex_lock(&chip->mutex); 45 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
46 zd_usb_clear(&chip->usb); 46 zd_usb_clear(&chip->usb);
47 zd_rf_clear(&chip->rf); 47 zd_rf_clear(&chip->rf);
48 mutex_unlock(&chip->mutex);
49 mutex_destroy(&chip->mutex); 48 mutex_destroy(&chip->mutex);
50 memset(chip, 0, sizeof(*chip)); 49 ZD_MEMCLEAR(chip, sizeof(*chip));
51} 50}
52 51
53static int scnprint_mac_oui(const u8 *addr, char *buffer, size_t size) 52static int scnprint_mac_oui(const u8 *addr, char *buffer, size_t size)
diff --git a/drivers/net/wireless/zd1211rw/zd_def.h b/drivers/net/wireless/zd1211rw/zd_def.h
index 465906812fc4..a13ec72eb304 100644
--- a/drivers/net/wireless/zd1211rw/zd_def.h
+++ b/drivers/net/wireless/zd1211rw/zd_def.h
@@ -45,4 +45,10 @@ do { \
45# define ZD_ASSERT(x) do { } while (0) 45# define ZD_ASSERT(x) do { } while (0)
46#endif 46#endif
47 47
48#ifdef DEBUG
49# define ZD_MEMCLEAR(pointer, size) memset((pointer), 0xff, (size))
50#else
51# define ZD_MEMCLEAR(pointer, size) do { } while (0)
52#endif
53
48#endif /* _ZD_DEF_H */ 54#endif /* _ZD_DEF_H */
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index d6f3e02a0b54..0eda534a648c 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -127,11 +127,9 @@ out:
127 127
128void zd_mac_clear(struct zd_mac *mac) 128void zd_mac_clear(struct zd_mac *mac)
129{ 129{
130 /* Aquire the lock. */
131 spin_lock(&mac->lock);
132 spin_unlock(&mac->lock);
133 zd_chip_clear(&mac->chip); 130 zd_chip_clear(&mac->chip);
134 memset(mac, 0, sizeof(*mac)); 131 ZD_ASSERT(!spin_is_locked(&mac->lock));
132 ZD_MEMCLEAR(mac, sizeof(struct zd_mac));
135} 133}
136 134
137static int reset_mode(struct zd_mac *mac) 135static int reset_mode(struct zd_mac *mac)
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h
index 71e382c589ee..082bcf8ec8dc 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.h
+++ b/drivers/net/wireless/zd1211rw/zd_mac.h
@@ -121,9 +121,9 @@ enum mac_flags {
121}; 121};
122 122
123struct zd_mac { 123struct zd_mac {
124 struct net_device *netdev;
125 struct zd_chip chip; 124 struct zd_chip chip;
126 spinlock_t lock; 125 spinlock_t lock;
126 struct net_device *netdev;
127 /* Unlocked reading possible */ 127 /* Unlocked reading possible */
128 struct iw_statistics iw_stats; 128 struct iw_statistics iw_stats;
129 u8 qual_average; 129 u8 qual_average;
diff --git a/drivers/net/wireless/zd1211rw/zd_rf.c b/drivers/net/wireless/zd1211rw/zd_rf.c
index ccf639a398b7..f50cff3db916 100644
--- a/drivers/net/wireless/zd1211rw/zd_rf.c
+++ b/drivers/net/wireless/zd1211rw/zd_rf.c
@@ -56,7 +56,7 @@ void zd_rf_init(struct zd_rf *rf)
56 56
57void zd_rf_clear(struct zd_rf *rf) 57void zd_rf_clear(struct zd_rf *rf)
58{ 58{
59 memset(rf, 0, sizeof(*rf)); 59 ZD_MEMCLEAR(rf, sizeof(*rf));
60} 60}
61 61
62int zd_rf_init_hw(struct zd_rf *rf, u8 type) 62int zd_rf_init_hw(struct zd_rf *rf, u8 type)
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
index f721ea57e213..47489fe8ab52 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.c
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -664,7 +664,7 @@ resubmit:
664 usb_submit_urb(urb, GFP_ATOMIC); 664 usb_submit_urb(urb, GFP_ATOMIC);
665} 665}
666 666
667struct urb *alloc_urb(struct zd_usb *usb) 667static struct urb *alloc_urb(struct zd_usb *usb)
668{ 668{
669 struct usb_device *udev = zd_usb_to_usbdev(usb); 669 struct usb_device *udev = zd_usb_to_usbdev(usb);
670 struct urb *urb; 670 struct urb *urb;
@@ -688,7 +688,7 @@ struct urb *alloc_urb(struct zd_usb *usb)
688 return urb; 688 return urb;
689} 689}
690 690
691void free_urb(struct urb *urb) 691static void free_urb(struct urb *urb)
692{ 692{
693 if (!urb) 693 if (!urb)
694 return; 694 return;
@@ -908,7 +908,7 @@ void zd_usb_clear(struct zd_usb *usb)
908{ 908{
909 usb_set_intfdata(usb->intf, NULL); 909 usb_set_intfdata(usb->intf, NULL);
910 usb_put_intf(usb->intf); 910 usb_put_intf(usb->intf);
911 memset(usb, 0, sizeof(*usb)); 911 ZD_MEMCLEAR(usb, sizeof(*usb));
912 /* FIXME: usb_interrupt, usb_tx, usb_rx? */ 912 /* FIXME: usb_interrupt, usb_tx, usb_rx? */
913} 913}
914 914
@@ -1099,7 +1099,6 @@ static void disconnect(struct usb_interface *intf)
1099 */ 1099 */
1100 usb_reset_device(interface_to_usbdev(intf)); 1100 usb_reset_device(interface_to_usbdev(intf));
1101 1101
1102 /* If somebody still waits on this lock now, this is an error. */
1103 zd_netdev_free(netdev); 1102 zd_netdev_free(netdev);
1104 dev_dbg(&intf->dev, "disconnected\n"); 1103 dev_dbg(&intf->dev, "disconnected\n");
1105} 1104}