From: "Arend van Spriel" <arend@broadcom.com>
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org, "Arend van Spriel" <arend@broadcom.com>
Subject: [PATCH v2 17/17] brcm80211: smac: change buffer endianess convert function interface
Date: Fri, 21 Oct 2011 16:16:35 +0200 [thread overview]
Message-ID: <1319206595-17138-18-git-send-email-arend@broadcom.com> (raw)
In-Reply-To: <1319206595-17138-1-git-send-email-arend@broadcom.com>
The buffer endianess conversion functions in srom.c had a size
argument giving number of bytes but the function converts words.
Providing the number of words to the function is more sensible
so that is done in this patch.
Reported-by: Pavel Roskin <proski@gnu.org>
Reported-by: Larry Finger <Larry.Finger@lwfinger.net>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Reviewed-by: Alwin Beukers <alwin@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
---
drivers/net/wireless/brcm80211/brcmsmac/srom.c | 33 +++++++++++-------------
1 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/srom.c b/drivers/net/wireless/brcm80211/brcmsmac/srom.c
index 8f1cf2f..0539a6a 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/srom.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/srom.c
@@ -617,18 +617,16 @@ static uint mask_width(u16 mask)
return 0;
}
-static inline void le16_to_cpu_buf(u16 *buf, unsigned int size)
+static inline void le16_to_cpu_buf(u16 *buf, uint nwords)
{
- size /= 2;
- while (size--)
- *(buf + size) = le16_to_cpu(*(__le16 *)(buf + size));
+ while (nwords--)
+ *(buf + nwords) = le16_to_cpu(*(__le16 *)(buf + nwords));
}
-static inline void cpu_to_le16_buf(u16 *buf, unsigned int size)
+static inline void cpu_to_le16_buf(u16 *buf, uint nwords)
{
- size /= 2;
- while (size--)
- *(__le16 *)(buf + size) = cpu_to_le16(*(buf + size));
+ while (nwords--)
+ *(__le16 *)(buf + nwords) = cpu_to_le16(*(buf + nwords));
}
/*
@@ -807,12 +805,12 @@ sprom_read_pci(struct si_pub *sih, u8 __iomem *sprom, uint wordoff,
err = -EIO;
else
/* now correct the endianness of the byte array */
- le16_to_cpu_buf(buf, nbytes);
+ le16_to_cpu_buf(buf, nwords);
return err;
}
-static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz)
+static int otp_read_pci(struct si_pub *sih, u16 *buf, uint nwords)
{
u8 *otp;
uint sz = OTP_SZ_MAX / 2; /* size in words */
@@ -824,7 +822,8 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz)
err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz);
- memcpy(buf, otp, bufsz);
+ sz = min_t(uint, sz, nwords);
+ memcpy(buf, otp, sz * 2);
kfree(otp);
@@ -836,14 +835,12 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz)
*/
return -ENODATA;
- /* fixup the endianness so crc8 will pass */
- cpu_to_le16_buf(buf, bufsz);
- if (crc8(brcms_srom_crc8_table, (u8 *) buf, SROM4_WORDS * 2,
+ if (crc8(brcms_srom_crc8_table, (u8 *) buf, sz * 2,
CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(brcms_srom_crc8_table))
err = -EIO;
-
- /* now correct the endianness of the byte array */
- le16_to_cpu_buf(buf, bufsz);
+ else
+ /* now correct the endianness of the byte array */
+ le16_to_cpu_buf(buf, sz);
return err;
}
@@ -880,7 +877,7 @@ static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap)
sromrev = srom[SROM4_CRCREV] & 0xff;
} else {
/* Use OTP if SPROM not available */
- err = otp_read_pci(sih, srom, SROM_MAX);
+ err = otp_read_pci(sih, srom, SROM4_WORDS);
if (err == 0)
/* OTP only contain SROM rev8/rev9 for now */
sromrev = srom[SROM4_CRCREV] & 0xff;
--
1.7.4.1
prev parent reply other threads:[~2011-10-21 14:16 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-21 14:16 [PATCH v2 00/17] fix mac80211 callback in brcmsmac and brcmfmac refactor Arend van Spriel
2011-10-21 14:16 ` [PATCH v2 01/17] brcm80211: fmac: allow wd timer to be disabled when bus down Arend van Spriel
2011-10-21 14:16 ` [PATCH v2 02/17] brcm80211: fmac: use brcmf_del_if for all net devices Arend van Spriel
2011-10-21 14:16 ` [PATCH v2 03/17] brcm80211: smac: removed MPC related code Arend van Spriel
2011-10-21 14:16 ` [PATCH v2 04/17] brcm80211: smac: removed MPC related variables Arend van Spriel
2011-10-21 14:16 ` [PATCH v2 05/17] brcm80211: smac: removed down-on-watchdog MPC functionality Arend van Spriel
2011-10-21 14:16 ` [PATCH v2 06/17] brcm80211: smac: removed down-on-rf-kill functionality Arend van Spriel
2011-10-21 14:16 ` [PATCH v2 07/17] brcm80211: smac: bugfix for tx mute in brcms_b_init() Arend van Spriel
2011-10-21 14:16 ` [PATCH v2 08/17] brcm80211: smac: fixed inconsistency in transmit mute Arend van Spriel
2011-10-21 14:16 ` [PATCH v2 09/17] brcm80211: smac: modified Mac80211 callback interface Arend van Spriel
2011-10-21 14:16 ` [PATCH v2 10/17] brcm80211: smac: mute transmit on ops_start Arend van Spriel
2011-10-21 14:16 ` [PATCH v2 11/17] brcm80211: smac: changed check to confirm STA only support Arend van Spriel
2011-10-21 14:16 ` [PATCH v2 12/17] brcm80211: smac: rename buffer endianess conversion functions Arend van Spriel
2011-10-21 14:16 ` [PATCH v2 13/17] brcm80211: smac: use sk_buff list for handling frames in receive path Arend van Spriel
2011-10-21 14:16 ` [PATCH v2 14/17] brcm80211: fmac: use brcmf_add_if for all net devices Arend van Spriel
2011-10-21 14:16 ` [PATCH v2 15/17] brcm80211: fmac: store brcmf_if in net device private data Arend van Spriel
2011-10-21 14:16 ` [PATCH v2 16/17] brcm80211: fmac: remove state from brcmf_if in fullmac Arend van Spriel
2011-10-21 14:16 ` Arend van Spriel [this message]
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=1319206595-17138-18-git-send-email-arend@broadcom.com \
--to=arend@broadcom.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).