[PATCH 06/25] libertas: don't use [delayed_]work_pending()

From: Tejun Heo
Date: Fri Dec 21 2012 - 21:03:13 EST


* delayed_work_pending() test in lbs_cfg_scan() is spurious as
priv->scan_req can't be NULL w/ scan_work pending; otherwise,
lbs_scan_worker() will segfault. Drop it. BTW, the synchronization
around scan_work seems racy. There's nothing synchronizing accesses
to scan related fields in lbs_private.

* Drop work_pending() test from if_sdio_reset_card(). As
work_pending() becomes %false before if_sdio_reset_card_worker()
starts executing, it doesn't really protect anything. reset_host
may change between mmc_remove_host() and mmc_add_host(). Make
if_sdio_reset_card_worker() cache the target mmc_host so that it
isn't affected by if_sdio_reset_card() racing with it.

Only compile tested.

Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
Cc: Dan Williams <dcbw@xxxxxxxxxx>
Cc: libertas-dev@xxxxxxxxxxxxxxxxxxx
Cc: linux-wireless@xxxxxxxxxxxxxxx
---
Please let me know how this patch should be routed. I can take it
through the workqueue tree if necessary.

Thanks.

drivers/net/wireless/libertas/cfg.c | 2 +-
drivers/net/wireless/libertas/if_sdio.c | 9 ++++-----
2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c
index ec6d5d6..ec30cd1 100644
--- a/drivers/net/wireless/libertas/cfg.c
+++ b/drivers/net/wireless/libertas/cfg.c
@@ -814,7 +814,7 @@ static int lbs_cfg_scan(struct wiphy *wiphy,

lbs_deb_enter(LBS_DEB_CFG80211);

- if (priv->scan_req || delayed_work_pending(&priv->scan_work)) {
+ if (priv->scan_req) {
/* old scan request not yet processed */
ret = -EAGAIN;
goto out;
diff --git a/drivers/net/wireless/libertas/if_sdio.c b/drivers/net/wireless/libertas/if_sdio.c
index 739309e..8c53c17 100644
--- a/drivers/net/wireless/libertas/if_sdio.c
+++ b/drivers/net/wireless/libertas/if_sdio.c
@@ -1074,6 +1074,8 @@ static struct mmc_host *reset_host;

static void if_sdio_reset_card_worker(struct work_struct *work)
{
+ struct mmc_host *target = reset_host;
+
/*
* The actual reset operation must be run outside of lbs_thread. This
* is because mmc_remove_host() will cause the device to be instantly
@@ -1085,8 +1087,8 @@ static void if_sdio_reset_card_worker(struct work_struct *work)
*/

pr_info("Resetting card...");
- mmc_remove_host(reset_host);
- mmc_add_host(reset_host);
+ mmc_remove_host(target);
+ mmc_add_host(target);
}
static DECLARE_WORK(card_reset_work, if_sdio_reset_card_worker);

@@ -1094,9 +1096,6 @@ static void if_sdio_reset_card(struct lbs_private *priv)
{
struct if_sdio_card *card = priv->card;

- if (work_pending(&card_reset_work))
- return;
-
reset_host = card->func->card->host;
schedule_work(&card_reset_work);
}
--
1.8.0.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/