From: Arend van Spriel <arend@broadcom.com>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: Kalle Valo <kvalo@codeaurora.org>,
<linux-wireless@vger.kernel.org>,
Brett Rudley <brudley@broadcom.com>,
"Franky (Zhenhui) Lin" <frankyl@broadcom.com>,
Hante Meuleman <meuleman@broadcom.com>,
<brcm80211-dev-list@broadcom.com>
Subject: Re: [PATCH] brcmfmac: simplify check stripping v2 NVRAM
Date: Wed, 20 May 2015 10:42:10 +0200 [thread overview]
Message-ID: <555C48E2.3050300@broadcom.com> (raw)
In-Reply-To: <1432107261-7350-1-git-send-email-zajec5@gmail.com>
On 05/20/15 09:34, Rafał Miłecki wrote:
> Comparing NVRAM entry with a full filtering string is simpler than
> comparing it with a short prefix and then checking random chars at magic
> offsets. The cost of snprintf relatively low, we execute it just once.
> Tested on BCM43602 with NVRAM hacked to use V2 format.
Acked-by: Arend van Spriel <arend@broadcom.com>
> Signed-off-by: Rafał Miłecki<zajec5@gmail.com>
> ---
> drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
> index 8ff31ff..181a0e8 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
> @@ -25,7 +25,7 @@
>
> #define BRCMF_FW_MAX_NVRAM_SIZE 64000
> #define BRCMF_FW_NVRAM_DEVPATH_LEN 19 /* devpath0=pcie/1/4/ */
> -#define BRCMF_FW_NVRAM_PCIEDEV_LEN 9 /* pcie/1/4/ */
> +#define BRCMF_FW_NVRAM_PCIEDEV_LEN 10 /* pcie/1/4/ + \0 */
>
> char brcmf_firmware_path[BRCMF_FW_PATH_LEN];
> module_param_string(firmware_path, brcmf_firmware_path,
> @@ -297,6 +297,8 @@ fail:
> static void brcmf_fw_strip_multi_v2(struct nvram_parser *nvp, u16 domain_nr,
> u16 bus_nr)
> {
> + char prefix[BRCMF_FW_NVRAM_PCIEDEV_LEN];
> + size_t len;
> u32 i, j;
> u8 *nvram;
>
> @@ -308,14 +310,13 @@ static void brcmf_fw_strip_multi_v2(struct nvram_parser *nvp, u16 domain_nr,
> * Valid entries are of type pcie/X/Y/ where X = domain_nr and
> * Y = bus_nr.
> */
> + snprintf(prefix, sizeof(prefix), "pcie/%d/%d/", domain_nr, bus_nr);
> + len = strlen(prefix);
> i = 0;
> j = 0;
> - while (i< nvp->nvram_len - BRCMF_FW_NVRAM_PCIEDEV_LEN) {
> - if ((strncmp(&nvp->nvram[i], "pcie/", 5) == 0)&&
> - (nvp->nvram[i + 6] == '/')&& (nvp->nvram[i + 8] == '/')&&
> - ((nvp->nvram[i + 5] - '0') == domain_nr)&&
> - ((nvp->nvram[i + 7] - '0') == bus_nr)) {
> - i += BRCMF_FW_NVRAM_PCIEDEV_LEN;
> + while (i< nvp->nvram_len - len) {
> + if (strncmp(&nvp->nvram[i], prefix, len) == 0) {
> + i += len;
> while (nvp->nvram[i] != 0) {
> nvram[j] = nvp->nvram[i];
> i++;
next prev parent reply other threads:[~2015-05-20 8:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-20 7:34 [PATCH] brcmfmac: simplify check stripping v2 NVRAM Rafał Miłecki
2015-05-20 8:42 ` Arend van Spriel [this message]
2015-05-28 8:49 ` Kalle Valo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=555C48E2.3050300@broadcom.com \
--to=arend@broadcom.com \
--cc=brcm80211-dev-list@broadcom.com \
--cc=brudley@broadcom.com \
--cc=frankyl@broadcom.com \
--cc=kvalo@codeaurora.org \
--cc=linux-wireless@vger.kernel.org \
--cc=meuleman@broadcom.com \
--cc=zajec5@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.