|
|
0bae752 |
From 920bc5d0e3a0ffa9142b54c3b6acf253e6e24d64 Mon Sep 17 00:00:00 2001
|
|
|
0bae752 |
From: Hans de Goede <hdegoede@redhat.com>
|
|
|
0bae752 |
Date: Thu, 27 Sep 2018 17:44:30 +0200
|
|
|
0bae752 |
Subject: [PATCH 1/5] brcmfmac: Remove firmware-loading code duplication
|
|
|
0bae752 |
|
|
|
0bae752 |
brcmf_fw_request_next_item and brcmf_fw_request_done both have identical
|
|
|
0bae752 |
code to complete the fw-request depending on the item-type.
|
|
|
0bae752 |
|
|
|
0bae752 |
This commit adds a new brcmf_fw_complete_request helper removing this code
|
|
|
0bae752 |
duplication.
|
|
|
0bae752 |
|
|
|
0bae752 |
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
|
0bae752 |
---
|
|
|
0bae752 |
.../broadcom/brcm80211/brcmfmac/firmware.c | 62 +++++++++----------
|
|
|
0bae752 |
1 file changed, 31 insertions(+), 31 deletions(-)
|
|
|
0bae752 |
|
|
|
0bae752 |
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
|
|
|
0bae752 |
index 2af2251cd8e9..848c3351d107 100644
|
|
|
0bae752 |
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
|
|
|
0bae752 |
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
|
|
|
0bae752 |
@@ -587,6 +587,34 @@ static int brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
|
|
|
0bae752 |
return -ENOENT;
|
|
|
0bae752 |
}
|
|
|
0bae752 |
|
|
|
0bae752 |
+static int brcmf_fw_complete_request(const struct firmware *fw,
|
|
|
0bae752 |
+ struct brcmf_fw *fwctx)
|
|
|
0bae752 |
+{
|
|
|
0bae752 |
+ struct brcmf_fw_item *cur = &fwctx->req->items[fwctx->curpos];
|
|
|
0bae752 |
+ int ret = 0;
|
|
|
0bae752 |
+
|
|
|
0bae752 |
+ brcmf_dbg(TRACE, "firmware %s %sfound\n", cur->path, fw ? "" : "not ");
|
|
|
0bae752 |
+
|
|
|
0bae752 |
+ switch (cur->type) {
|
|
|
0bae752 |
+ case BRCMF_FW_TYPE_NVRAM:
|
|
|
0bae752 |
+ ret = brcmf_fw_request_nvram_done(fw, fwctx);
|
|
|
0bae752 |
+ break;
|
|
|
0bae752 |
+ case BRCMF_FW_TYPE_BINARY:
|
|
|
0bae752 |
+ if (fw)
|
|
|
0bae752 |
+ cur->binary = fw;
|
|
|
0bae752 |
+ else
|
|
|
0bae752 |
+ ret = -ENOENT;
|
|
|
0bae752 |
+ break;
|
|
|
0bae752 |
+ default:
|
|
|
0bae752 |
+ /* something fishy here so bail out early */
|
|
|
0bae752 |
+ brcmf_err("unknown fw type: %d\n", cur->type);
|
|
|
0bae752 |
+ release_firmware(fw);
|
|
|
0bae752 |
+ ret = -EINVAL;
|
|
|
0bae752 |
+ }
|
|
|
0bae752 |
+
|
|
|
0bae752 |
+ return (cur->flags & BRCMF_FW_REQF_OPTIONAL) ? 0 : ret;
|
|
|
0bae752 |
+}
|
|
|
0bae752 |
+
|
|
|
0bae752 |
static int brcmf_fw_request_next_item(struct brcmf_fw *fwctx, bool async)
|
|
|
0bae752 |
{
|
|
|
0bae752 |
struct brcmf_fw_item *cur;
|
|
|
0bae752 |
@@ -608,15 +636,7 @@ static int brcmf_fw_request_next_item(struct brcmf_fw *fwctx, bool async)
|
|
|
0bae752 |
if (ret < 0) {
|
|
|
0bae752 |
brcmf_fw_request_done(NULL, fwctx);
|
|
|
0bae752 |
} else if (!async && fw) {
|
|
|
0bae752 |
- brcmf_dbg(TRACE, "firmware %s %sfound\n", cur->path,
|
|
|
0bae752 |
- fw ? "" : "not ");
|
|
|
0bae752 |
- if (cur->type == BRCMF_FW_TYPE_BINARY)
|
|
|
0bae752 |
- cur->binary = fw;
|
|
|
0bae752 |
- else if (cur->type == BRCMF_FW_TYPE_NVRAM)
|
|
|
0bae752 |
- brcmf_fw_request_nvram_done(fw, fwctx);
|
|
|
0bae752 |
- else
|
|
|
0bae752 |
- release_firmware(fw);
|
|
|
0bae752 |
-
|
|
|
0bae752 |
+ brcmf_fw_complete_request(fw, fwctx);
|
|
|
0bae752 |
return -EAGAIN;
|
|
|
0bae752 |
}
|
|
|
0bae752 |
return 0;
|
|
|
0bae752 |
@@ -630,28 +650,8 @@ static void brcmf_fw_request_done(const struct firmware *fw, void *ctx)
|
|
|
0bae752 |
|
|
|
0bae752 |
cur = &fwctx->req->items[fwctx->curpos];
|
|
|
0bae752 |
|
|
|
0bae752 |
- brcmf_dbg(TRACE, "enter: firmware %s %sfound\n", cur->path,
|
|
|
0bae752 |
- fw ? "" : "not ");
|
|
|
0bae752 |
-
|
|
|
0bae752 |
- if (!fw)
|
|
|
0bae752 |
- ret = -ENOENT;
|
|
|
0bae752 |
-
|
|
|
0bae752 |
- switch (cur->type) {
|
|
|
0bae752 |
- case BRCMF_FW_TYPE_NVRAM:
|
|
|
0bae752 |
- ret = brcmf_fw_request_nvram_done(fw, fwctx);
|
|
|
0bae752 |
- break;
|
|
|
0bae752 |
- case BRCMF_FW_TYPE_BINARY:
|
|
|
0bae752 |
- cur->binary = fw;
|
|
|
0bae752 |
- break;
|
|
|
0bae752 |
- default:
|
|
|
0bae752 |
- /* something fishy here so bail out early */
|
|
|
0bae752 |
- brcmf_err("unknown fw type: %d\n", cur->type);
|
|
|
0bae752 |
- release_firmware(fw);
|
|
|
0bae752 |
- ret = -EINVAL;
|
|
|
0bae752 |
- goto fail;
|
|
|
0bae752 |
- }
|
|
|
0bae752 |
-
|
|
|
0bae752 |
- if (ret < 0 && !(cur->flags & BRCMF_FW_REQF_OPTIONAL))
|
|
|
0bae752 |
+ ret = brcmf_fw_complete_request(fw, fwctx);
|
|
|
0bae752 |
+ if (ret < 0)
|
|
|
0bae752 |
goto fail;
|
|
|
0bae752 |
|
|
|
0bae752 |
do {
|
|
|
0bae752 |
--
|
|
|
0bae752 |
2.19.0
|
|
|
0bae752 |
|