All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] brcmfmac: Remove firmware-loading code duplication
@ 2018-10-09 12:47 Hans de Goede
  2018-10-09 12:47 ` [PATCH 2/6] brcmfmac: Remove recursion from firmware load error handling Hans de Goede
                   ` (5 more replies)
  0 siblings, 6 replies; 27+ messages in thread
From: Hans de Goede @ 2018-10-09 12:47 UTC (permalink / raw)
  To: Arend van Spriel, Franky Lin, Hante Meuleman, Kalle Valo,
	Chi-Hsien Lin, Wright Feng
  Cc: Hans de Goede, linux-wireless, brcm80211-dev-list.pdl

brcmf_fw_request_next_item and brcmf_fw_request_done both have identical
code to complete the fw-request depending on the item-type.

This commit adds a new brcmf_fw_complete_request helper removing this code
duplication.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 .../broadcom/brcm80211/brcmfmac/firmware.c    | 62 +++++++++----------
 1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
index 9095b830ae4d..784c84f0e9e7 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
@@ -504,6 +504,34 @@ static int brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
 	return -ENOENT;
 }
 
+static int brcmf_fw_complete_request(const struct firmware *fw,
+				     struct brcmf_fw *fwctx)
+{
+	struct brcmf_fw_item *cur = &fwctx->req->items[fwctx->curpos];
+	int ret = 0;
+
+	brcmf_dbg(TRACE, "firmware %s %sfound\n", cur->path, fw ? "" : "not ");
+
+	switch (cur->type) {
+	case BRCMF_FW_TYPE_NVRAM:
+		ret = brcmf_fw_request_nvram_done(fw, fwctx);
+		break;
+	case BRCMF_FW_TYPE_BINARY:
+		if (fw)
+			cur->binary = fw;
+		else
+			ret = -ENOENT;
+		break;
+	default:
+		/* something fishy here so bail out early */
+		brcmf_err("unknown fw type: %d\n", cur->type);
+		release_firmware(fw);
+		ret = -EINVAL;
+	}
+
+	return (cur->flags & BRCMF_FW_REQF_OPTIONAL) ? 0 : ret;
+}
+
 static int brcmf_fw_request_next_item(struct brcmf_fw *fwctx, bool async)
 {
 	struct brcmf_fw_item *cur;
@@ -525,15 +553,7 @@ static int brcmf_fw_request_next_item(struct brcmf_fw *fwctx, bool async)
 	if (ret < 0) {
 		brcmf_fw_request_done(NULL, fwctx);
 	} else if (!async && fw) {
-		brcmf_dbg(TRACE, "firmware %s %sfound\n", cur->path,
-			  fw ? "" : "not ");
-		if (cur->type == BRCMF_FW_TYPE_BINARY)
-			cur->binary = fw;
-		else if (cur->type == BRCMF_FW_TYPE_NVRAM)
-			brcmf_fw_request_nvram_done(fw, fwctx);
-		else
-			release_firmware(fw);
-
+		brcmf_fw_complete_request(fw, fwctx);
 		return -EAGAIN;
 	}
 	return 0;
@@ -547,28 +567,8 @@ static void brcmf_fw_request_done(const struct firmware *fw, void *ctx)
 
 	cur = &fwctx->req->items[fwctx->curpos];
 
-	brcmf_dbg(TRACE, "enter: firmware %s %sfound\n", cur->path,
-		  fw ? "" : "not ");
-
-	if (!fw)
-		ret = -ENOENT;
-
-	switch (cur->type) {
-	case BRCMF_FW_TYPE_NVRAM:
-		ret = brcmf_fw_request_nvram_done(fw, fwctx);
-		break;
-	case BRCMF_FW_TYPE_BINARY:
-		cur->binary = fw;
-		break;
-	default:
-		/* something fishy here so bail out early */
-		brcmf_err("unknown fw type: %d\n", cur->type);
-		release_firmware(fw);
-		ret = -EINVAL;
-		goto fail;
-	}
-
-	if (ret < 0 && !(cur->flags & BRCMF_FW_REQF_OPTIONAL))
+	ret = brcmf_fw_complete_request(fw, fwctx);
+	if (ret < 0)
 		goto fail;
 
 	do {
-- 
2.19.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2018-11-15 14:24 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-09 12:47 [PATCH 1/6] brcmfmac: Remove firmware-loading code duplication Hans de Goede
2018-10-09 12:47 ` [PATCH 2/6] brcmfmac: Remove recursion from firmware load error handling Hans de Goede
2018-11-05 11:40   ` Arend van Spriel
2018-10-09 12:47 ` [PATCH 3/6] brcmfmac: Add support for first trying to get a board specific nvram file Hans de Goede
2018-11-05 11:41   ` Arend van Spriel
2018-11-05 14:32     ` Hans de Goede
2018-10-09 12:47 ` [PATCH 4/6] brcmfmac: Set board_type used for nvram file selection to machine-compatible Hans de Goede
2018-11-05 11:41   ` Arend van Spriel
2018-10-09 12:47 ` [PATCH 5/6] brcmfmac: Set board_type from DMI on x86 based machines Hans de Goede
2018-10-10  7:09   ` Kalle Valo
2018-10-10  7:28     ` Hans de Goede
2018-10-10  7:40       ` Kalle Valo
2018-10-10  7:52       ` Arend van Spriel
2018-10-10  7:57         ` Kalle Valo
2018-10-10  8:01           ` Hans de Goede
2018-10-10  7:59         ` Hans de Goede
2018-10-10  8:15           ` Arend van Spriel
2018-11-05  9:45             ` Hans de Goede
2018-11-05 11:41   ` Arend van Spriel
2018-11-05 14:42     ` Hans de Goede
2018-10-09 12:47 ` [PATCH 6/6] brcmfmac: Cleanup brcmf_fw_request_done() Hans de Goede
2018-11-05 11:42   ` Arend van Spriel
2018-11-05 14:34     ` Hans de Goede
2018-11-05 11:40 ` [PATCH 1/6] brcmfmac: Remove firmware-loading code duplication Arend van Spriel
2018-11-05 15:05   ` Kalle Valo
2018-11-05 15:10     ` Hans de Goede
2018-11-15 14:24       ` Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.