提交 c48cf125 编写于 作者: U Ulrich Kunitz 提交者: John W. Linville

[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: NUlrich Kunitz <kune@deine-taler.de>
Signed-off-by: NDaniel Drake <dsd@gentoo.org>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 943599ee
......@@ -42,12 +42,11 @@ void zd_chip_init(struct zd_chip *chip,
void zd_chip_clear(struct zd_chip *chip)
{
mutex_lock(&chip->mutex);
ZD_ASSERT(!mutex_is_locked(&chip->mutex));
zd_usb_clear(&chip->usb);
zd_rf_clear(&chip->rf);
mutex_unlock(&chip->mutex);
mutex_destroy(&chip->mutex);
memset(chip, 0, sizeof(*chip));
ZD_MEMCLEAR(chip, sizeof(*chip));
}
static int scnprint_mac_oui(const u8 *addr, char *buffer, size_t size)
......
......@@ -45,4 +45,10 @@ do { \
# define ZD_ASSERT(x) do { } while (0)
#endif
#ifdef DEBUG
# define ZD_MEMCLEAR(pointer, size) memset((pointer), 0xff, (size))
#else
# define ZD_MEMCLEAR(pointer, size) do { } while (0)
#endif
#endif /* _ZD_DEF_H */
......@@ -127,11 +127,9 @@ int zd_mac_init_hw(struct zd_mac *mac, u8 device_type)
void zd_mac_clear(struct zd_mac *mac)
{
/* Aquire the lock. */
spin_lock(&mac->lock);
spin_unlock(&mac->lock);
zd_chip_clear(&mac->chip);
memset(mac, 0, sizeof(*mac));
ZD_ASSERT(!spin_is_locked(&mac->lock));
ZD_MEMCLEAR(mac, sizeof(struct zd_mac));
}
static int reset_mode(struct zd_mac *mac)
......
......@@ -121,9 +121,9 @@ enum mac_flags {
};
struct zd_mac {
struct net_device *netdev;
struct zd_chip chip;
spinlock_t lock;
struct net_device *netdev;
/* Unlocked reading possible */
struct iw_statistics iw_stats;
u8 qual_average;
......
......@@ -56,7 +56,7 @@ void zd_rf_init(struct zd_rf *rf)
void zd_rf_clear(struct zd_rf *rf)
{
memset(rf, 0, sizeof(*rf));
ZD_MEMCLEAR(rf, sizeof(*rf));
}
int zd_rf_init_hw(struct zd_rf *rf, u8 type)
......
......@@ -664,7 +664,7 @@ static void rx_urb_complete(struct urb *urb, struct pt_regs *pt_regs)
usb_submit_urb(urb, GFP_ATOMIC);
}
struct urb *alloc_urb(struct zd_usb *usb)
static struct urb *alloc_urb(struct zd_usb *usb)
{
struct usb_device *udev = zd_usb_to_usbdev(usb);
struct urb *urb;
......@@ -688,7 +688,7 @@ struct urb *alloc_urb(struct zd_usb *usb)
return urb;
}
void free_urb(struct urb *urb)
static void free_urb(struct urb *urb)
{
if (!urb)
return;
......@@ -908,7 +908,7 @@ void zd_usb_clear(struct zd_usb *usb)
{
usb_set_intfdata(usb->intf, NULL);
usb_put_intf(usb->intf);
memset(usb, 0, sizeof(*usb));
ZD_MEMCLEAR(usb, sizeof(*usb));
/* FIXME: usb_interrupt, usb_tx, usb_rx? */
}
......@@ -1099,7 +1099,6 @@ static void disconnect(struct usb_interface *intf)
*/
usb_reset_device(interface_to_usbdev(intf));
/* If somebody still waits on this lock now, this is an error. */
zd_netdev_free(netdev);
dev_dbg(&intf->dev, "disconnected\n");
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册