diff options
author | Arend van Spriel <arend@broadcom.com> | 2011-10-21 10:16:35 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-11-08 15:54:26 -0500 |
commit | 028f78d43d80dcb8b1142ea38606067151dd3d51 (patch) | |
tree | 70d6e7bdd7dc177c71cf982d2a082ffca28d53d6 /drivers/net/wireless/brcm80211 | |
parent | d1a5b6fbecc52323acf05fa7881267071933c92e (diff) |
brcm80211: smac: change buffer endianess convert function interface
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>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/brcm80211')
-rw-r--r-- | 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 8f1cf2f733e5..0539a6a831c5 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) | |||
617 | return 0; | 617 | return 0; |
618 | } | 618 | } |
619 | 619 | ||
620 | static inline void le16_to_cpu_buf(u16 *buf, unsigned int size) | 620 | static inline void le16_to_cpu_buf(u16 *buf, uint nwords) |
621 | { | 621 | { |
622 | size /= 2; | 622 | while (nwords--) |
623 | while (size--) | 623 | *(buf + nwords) = le16_to_cpu(*(__le16 *)(buf + nwords)); |
624 | *(buf + size) = le16_to_cpu(*(__le16 *)(buf + size)); | ||
625 | } | 624 | } |
626 | 625 | ||
627 | static inline void cpu_to_le16_buf(u16 *buf, unsigned int size) | 626 | static inline void cpu_to_le16_buf(u16 *buf, uint nwords) |
628 | { | 627 | { |
629 | size /= 2; | 628 | while (nwords--) |
630 | while (size--) | 629 | *(__le16 *)(buf + nwords) = cpu_to_le16(*(buf + nwords)); |
631 | *(__le16 *)(buf + size) = cpu_to_le16(*(buf + size)); | ||
632 | } | 630 | } |
633 | 631 | ||
634 | /* | 632 | /* |
@@ -807,12 +805,12 @@ sprom_read_pci(struct si_pub *sih, u8 __iomem *sprom, uint wordoff, | |||
807 | err = -EIO; | 805 | err = -EIO; |
808 | else | 806 | else |
809 | /* now correct the endianness of the byte array */ | 807 | /* now correct the endianness of the byte array */ |
810 | le16_to_cpu_buf(buf, nbytes); | 808 | le16_to_cpu_buf(buf, nwords); |
811 | 809 | ||
812 | return err; | 810 | return err; |
813 | } | 811 | } |
814 | 812 | ||
815 | static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) | 813 | static int otp_read_pci(struct si_pub *sih, u16 *buf, uint nwords) |
816 | { | 814 | { |
817 | u8 *otp; | 815 | u8 *otp; |
818 | uint sz = OTP_SZ_MAX / 2; /* size in words */ | 816 | 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) | |||
824 | 822 | ||
825 | err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz); | 823 | err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz); |
826 | 824 | ||
827 | memcpy(buf, otp, bufsz); | 825 | sz = min_t(uint, sz, nwords); |
826 | memcpy(buf, otp, sz * 2); | ||
828 | 827 | ||
829 | kfree(otp); | 828 | kfree(otp); |
830 | 829 | ||
@@ -836,14 +835,12 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) | |||
836 | */ | 835 | */ |
837 | return -ENODATA; | 836 | return -ENODATA; |
838 | 837 | ||
839 | /* fixup the endianness so crc8 will pass */ | 838 | if (crc8(brcms_srom_crc8_table, (u8 *) buf, sz * 2, |
840 | cpu_to_le16_buf(buf, bufsz); | ||
841 | if (crc8(brcms_srom_crc8_table, (u8 *) buf, SROM4_WORDS * 2, | ||
842 | CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(brcms_srom_crc8_table)) | 839 | CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(brcms_srom_crc8_table)) |
843 | err = -EIO; | 840 | err = -EIO; |
844 | 841 | else | |
845 | /* now correct the endianness of the byte array */ | 842 | /* now correct the endianness of the byte array */ |
846 | le16_to_cpu_buf(buf, bufsz); | 843 | le16_to_cpu_buf(buf, sz); |
847 | 844 | ||
848 | return err; | 845 | return err; |
849 | } | 846 | } |
@@ -880,7 +877,7 @@ static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap) | |||
880 | sromrev = srom[SROM4_CRCREV] & 0xff; | 877 | sromrev = srom[SROM4_CRCREV] & 0xff; |
881 | } else { | 878 | } else { |
882 | /* Use OTP if SPROM not available */ | 879 | /* Use OTP if SPROM not available */ |
883 | err = otp_read_pci(sih, srom, SROM_MAX); | 880 | err = otp_read_pci(sih, srom, SROM4_WORDS); |
884 | if (err == 0) | 881 | if (err == 0) |
885 | /* OTP only contain SROM rev8/rev9 for now */ | 882 | /* OTP only contain SROM rev8/rev9 for now */ |
886 | sromrev = srom[SROM4_CRCREV] & 0xff; | 883 | sromrev = srom[SROM4_CRCREV] & 0xff; |