mwifiex: initiate card-specific work atomically

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>
This commit is contained in:
Brian Norris 2017-05-01 12:36:59 -07:00 committed by Kalle Valo
parent 83625a4016
commit 21f569af9a
2 changed files with 8 additions and 17 deletions

View 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)

View 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