]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mwifiex: initiate card-specific work atomically
authorBrian Norris <briannorris@chromium.org>
Mon, 1 May 2017 19:36:59 +0000 (12:36 -0700)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 18 May 2017 13:39:36 +0000 (16:39 +0300)
The non-atomic test + set is a little awkward here, and it technically
means we might double-schedule work unnecessarily. AFAICT, this is not
really a problem, since the extra "work" will be a no-op (the flag(s)
will be cleared by then), but it's still an anti-pattern.

Rewrite this to use the atomic test_and_set_bit() helper instead.

Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/marvell/mwifiex/pcie.c
drivers/net/wireless/marvell/mwifiex/sdio.c

index ac62bce50e964b900135cdc600dcdb9032928a3f..5f56e8e6d61264a0d6f7fc28a4e382729a841e16 100644 (file)
@@ -2837,12 +2837,9 @@ static void mwifiex_pcie_device_dump(struct mwifiex_adapter *adapter)
 {
        struct pcie_service_card *card = adapter->card;
 
-       if (test_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags))
-               return;
-
-       set_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags);
-
-       schedule_work(&card->work);
+       if (!test_and_set_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP,
+                             &card->work_flags))
+               schedule_work(&card->work);
 }
 
 static void mwifiex_pcie_free_buffers(struct mwifiex_adapter *adapter)
index 0af1c6733c9257e64fbecd81e11fb76ec871452a..d38d31bb9b792bfaa283ac82401ba4a05fcab0b4 100644 (file)
@@ -2533,12 +2533,8 @@ static void mwifiex_sdio_card_reset(struct mwifiex_adapter *adapter)
 {
        struct sdio_mmc_card *card = adapter->card;
 
-       if (test_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags))
-               return;
-
-       set_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags);
-
-       schedule_work(&card->work);
+       if (!test_and_set_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags))
+               schedule_work(&card->work);
 }
 
 /* This function dumps FW information */
@@ -2546,11 +2542,9 @@ static void mwifiex_sdio_device_dump(struct mwifiex_adapter *adapter)
 {
        struct sdio_mmc_card *card = adapter->card;
 
-       if (test_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags))
-               return;
-
-       set_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags);
-       schedule_work(&card->work);
+       if (!test_and_set_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP,
+                             &card->work_flags))
+               schedule_work(&card->work);
 }
 
 /* Function to dump SDIO function registers and SDIO scratch registers in case