Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c48cf125 authored by Ulrich Kunitz's avatar Ulrich Kunitz Committed by John W. Linville
Browse files

[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: default avatarUlrich Kunitz <kune@deine-taler.de>
Signed-off-by: default avatarDaniel Drake <dsd@gentoo.org>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 943599ee
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -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)
+6 −0
Original line number Diff line number Diff line
@@ -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 */
+2 −4
Original line number Diff line number Diff line
@@ -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)
+1 −1
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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)
Loading