[PATCH 12/30] staging: brcm80211: replaced fullmac BRCMF_PM_RESUME_WAIT macro with function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Code cleanup. Advantage is more readable code and better type checking.

Reported-by: Johannes Berg <johannes@xxxxxxxxxxxxxxxx>
Signed-off-by: Roland Vossen <rvossen@xxxxxxxxxxxx>
Reviewed-by: Franky Lin <frankyl@xxxxxxxxxxxx>
Reviewed-by: Arend van Spriel <arend@xxxxxxxxxxxx>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@xxxxxxxxxxxx>
---
 drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c |   26 +++++++++++---------
 1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c
index d3d3890..be022d2 100644
--- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c
+++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c
@@ -84,14 +84,6 @@ DECLARE_WAIT_QUEUE_HEAD(sdioh_request_byte_wait);
 DECLARE_WAIT_QUEUE_HEAD(sdioh_request_word_wait);
 DECLARE_WAIT_QUEUE_HEAD(sdioh_request_packet_wait);
 DECLARE_WAIT_QUEUE_HEAD(sdioh_request_buffer_wait);
-#define BRCMF_PM_RESUME_WAIT(a, b) do { \
-		int retry = 0; \
-		while (atomic_read(&b->suspend) && retry++ != 30) { \
-			wait_event_timeout(a, false, HZ/100); \
-		} \
-	}	while (0)
-#else
-#define BRCMF_PM_RESUME_WAIT(a, b)
 #endif		/* CONFIG_PM_SLEEP */
 
 static int
@@ -108,6 +100,16 @@ brcmf_pm_resume_error(struct brcmf_sdio_dev *sdiodev)
 	return is_err;
 }
 
+static void
+brcmf_pm_resume_wait(struct brcmf_sdio_dev *sdiodev, wait_queue_head_t wq)
+{
+#ifdef CONFIG_PM_SLEEP
+	int retry = 0;
+	while (atomic_read(&sdiodev->suspend) && retry++ != 30)
+		wait_event_timeout(wq, false, HZ/100);
+#endif
+}
+
 static int brcmf_sdioh_enablefuncs(struct brcmf_sdio_dev *sdiodev)
 {
 	int err_ret;
@@ -255,7 +257,7 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func,
 
 	brcmf_dbg(INFO, "rw=%d, func=%d, addr=0x%05x\n", rw, func, regaddr);
 
-	BRCMF_PM_RESUME_WAIT(sdioh_request_byte_wait, sdiodev);
+	brcmf_pm_resume_wait(sdiodev, sdioh_request_byte_wait);
 	if (brcmf_pm_resume_error(sdiodev))
 		return -EIO;
 	if (rw) {		/* CMD52 Write */
@@ -358,7 +360,7 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw,
 	brcmf_dbg(INFO, "cmd_type=%d, rw=%d, func=%d, addr=0x%05x, nbytes=%d\n",
 		  cmd_type, rw, func, addr, nbytes);
 
-	BRCMF_PM_RESUME_WAIT(sdioh_request_word_wait, sdiodev);
+	brcmf_pm_resume_wait(sdiodev, sdioh_request_word_wait);
 	if (brcmf_pm_resume_error(sdiodev))
 		return -EIO;
 	/* Claim host controller */
@@ -408,7 +410,7 @@ brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc,
 
 	brcmf_dbg(TRACE, "Enter\n");
 
-	BRCMF_PM_RESUME_WAIT(sdioh_request_packet_wait, sdiodev);
+	brcmf_pm_resume_wait(sdiodev, sdioh_request_packet_wait);
 	if (brcmf_pm_resume_error(sdiodev))
 		return -EIO;
 
@@ -486,7 +488,7 @@ brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint pio_dma,
 
 	brcmf_dbg(TRACE, "Enter\n");
 
-	BRCMF_PM_RESUME_WAIT(sdioh_request_buffer_wait, sdiodev);
+	brcmf_pm_resume_wait(sdiodev, sdioh_request_buffer_wait);
 	if (brcmf_pm_resume_error(sdiodev))
 		return -EIO;
 	/* Case 1: we don't have a packet. */
-- 
1.7.4.1


_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux