1 From a1a3b762163868ad07a4499a73df324f40d5ab0b Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Wed, 10 Oct 2018 13:00:58 +0200
4 Subject: [PATCH] brcmfmac: Remove firmware-loading code duplication
6 brcmf_fw_request_next_item and brcmf_fw_request_done both have identical
7 code to complete the fw-request depending on the item-type.
9 This commit adds a new brcmf_fw_complete_request helper removing this code
12 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
13 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
15 .../broadcom/brcm80211/brcmfmac/firmware.c | 62 +++++++++++-----------
16 1 file changed, 31 insertions(+), 31 deletions(-)
18 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
19 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
20 @@ -504,6 +504,34 @@ fail:
24 +static int brcmf_fw_complete_request(const struct firmware *fw,
25 + struct brcmf_fw *fwctx)
27 + struct brcmf_fw_item *cur = &fwctx->req->items[fwctx->curpos];
30 + brcmf_dbg(TRACE, "firmware %s %sfound\n", cur->path, fw ? "" : "not ");
32 + switch (cur->type) {
33 + case BRCMF_FW_TYPE_NVRAM:
34 + ret = brcmf_fw_request_nvram_done(fw, fwctx);
36 + case BRCMF_FW_TYPE_BINARY:
43 + /* something fishy here so bail out early */
44 + brcmf_err("unknown fw type: %d\n", cur->type);
45 + release_firmware(fw);
49 + return (cur->flags & BRCMF_FW_REQF_OPTIONAL) ? 0 : ret;
52 static int brcmf_fw_request_next_item(struct brcmf_fw *fwctx, bool async)
54 struct brcmf_fw_item *cur;
55 @@ -525,15 +553,7 @@ static int brcmf_fw_request_next_item(st
57 brcmf_fw_request_done(NULL, fwctx);
58 } else if (!async && fw) {
59 - brcmf_dbg(TRACE, "firmware %s %sfound\n", cur->path,
61 - if (cur->type == BRCMF_FW_TYPE_BINARY)
63 - else if (cur->type == BRCMF_FW_TYPE_NVRAM)
64 - brcmf_fw_request_nvram_done(fw, fwctx);
66 - release_firmware(fw);
68 + brcmf_fw_complete_request(fw, fwctx);
72 @@ -547,28 +567,8 @@ static void brcmf_fw_request_done(const
74 cur = &fwctx->req->items[fwctx->curpos];
76 - brcmf_dbg(TRACE, "enter: firmware %s %sfound\n", cur->path,
82 - switch (cur->type) {
83 - case BRCMF_FW_TYPE_NVRAM:
84 - ret = brcmf_fw_request_nvram_done(fw, fwctx);
86 - case BRCMF_FW_TYPE_BINARY:
90 - /* something fishy here so bail out early */
91 - brcmf_err("unknown fw type: %d\n", cur->type);
92 - release_firmware(fw);
97 - if (ret < 0 && !(cur->flags & BRCMF_FW_REQF_OPTIONAL))
98 + ret = brcmf_fw_complete_request(fw, fwctx);