[PATCH 7/8] staging: ks7010: factor out check for firmware running into ks7010_is_firmware_running

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

 



This commit extracts process to check if firmware is running
into a new inline function called ks7010_is_firmware_running.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@xxxxxxxxx>
---
 drivers/staging/ks7010/ks7010_sdio.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
index 5b6c7a7..11d5be1 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -639,12 +639,20 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,
 	return ret;
 }
 
+static inline bool ks7010_is_firmware_running(struct ks_wlan_private *priv,
+					      int *ret)
+{
+	unsigned char byte;
+
+	*ret = ks7010_sdio_readb(priv, GCR_A, &byte);
+	return (byte == GCR_A_RUN);
+}
+
 static int ks7010_upload_firmware(struct ks_sdio_card *card)
 {
 	struct ks_wlan_private *priv = card->priv;
 	unsigned int size, offset, n = 0;
 	unsigned char *rom_buf;
-	unsigned char byte = 0;
 	int ret;
 	unsigned int length;
 	const struct firmware *fw_entry = NULL;
@@ -655,9 +663,7 @@ static int ks7010_upload_firmware(struct ks_sdio_card *card)
 
 	sdio_claim_host(card->func);
 
-	/* Firmware running ? */
-	ret = ks7010_sdio_readb(priv, GCR_A, &byte);
-	if (byte == GCR_A_RUN) {
+	if (ks7010_is_firmware_running(priv, &ret)) {
 		netdev_dbg(priv->net_dev, "MAC firmware running ...\n");
 		goto release_host_and_free;
 	}
@@ -706,11 +712,7 @@ static int ks7010_upload_firmware(struct ks_sdio_card *card)
 	/* Firmware running check */
 	for (n = 0; n < 50; ++n) {
 		mdelay(10);	/* wait_ms(10); */
-		ret = ks7010_sdio_readb(priv, GCR_A, &byte);
-		if (ret)
-			goto release_firmware;
-
-		if (byte == GCR_A_RUN)
+		if (ks7010_is_firmware_running(priv, &ret))
 			break;
 	}
 	if ((50) <= n) {
@@ -719,8 +721,6 @@ static int ks7010_upload_firmware(struct ks_sdio_card *card)
 		goto release_firmware;
 	}
 
-	ret = 0;
-
  release_firmware:
 	release_firmware(fw_entry);
  release_host_and_free:
-- 
2.7.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-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