2013-02-24 15:41:44

by Hauke Mehrtens

[permalink] [raw]
Subject: [PATCH] brcmsmac: export firmware version to ethtool

This exports the firmware version in use to userspace through ethtool.

root@OpenWrt:/# ethtool -i wlan0
firmware-version: 610.812

Signed-off-by: Hauke Mehrtens <[email protected]>
---
drivers/net/wireless/brcm80211/brcmsmac/main.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
index d723e15..abd6eab 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
@@ -7957,9 +7957,14 @@ void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx)

/* read the ucode version if we have not yet done so */
if (wlc->ucode_rev == 0) {
- wlc->ucode_rev =
- brcms_b_read_shm(wlc->hw, M_BOM_REV_MAJOR) << NBITS(u16);
- wlc->ucode_rev |= brcms_b_read_shm(wlc->hw, M_BOM_REV_MINOR);
+ u16 rev;
+ u16 patch;
+
+ rev = brcms_b_read_shm(wlc->hw, M_BOM_REV_MAJOR);
+ patch = brcms_b_read_shm(wlc->hw, M_BOM_REV_MINOR);
+ wlc->ucode_rev = (rev << NBITS(u16)) | patch;
+ snprintf(wlc->wiphy->fw_version,
+ sizeof(wlc->wiphy->fw_version), "%u.%u", rev, patch);
}

/* ..now really unleash hell (allow the MAC out of suspend) */
--
1.7.10.4



2013-02-25 14:18:53

by Arend van Spriel

[permalink] [raw]
Subject: Re: [PATCH] brcmsmac: export firmware version to ethtool

On 02/24/13 16:41, Hauke Mehrtens wrote:
> This exports the firmware version in use to userspace through ethtool.
>
> root@OpenWrt:/# ethtool -i wlan0
> firmware-version: 610.812

This info is already available under debugfs although I prefer your
formatting :-) :

$ sudo cat hardware
board vendor: 1028
board type: e
board revision: 2203
board flags: 200
board flags2: 1000
firmware revision: 262032c

Gr. AvS


2013-02-25 19:05:45

by Hauke Mehrtens

[permalink] [raw]
Subject: Re: [PATCH] brcmsmac: export firmware version to ethtool

On 02/25/2013 03:18 PM, Arend van Spriel wrote:
> On 02/24/13 16:41, Hauke Mehrtens wrote:
>> This exports the firmware version in use to userspace through ethtool.
>>
>> root@OpenWrt:/# ethtool -i wlan0
>> firmware-version: 610.812
>
> This info is already available under debugfs although I prefer your
> formatting :-) :

I used the same formating b43 uses, I do not know what's the official
formating for this firmware version number.

Writing the firmware version to wiphy->fw_version is the official way to
do this and many drivers already are exporting their firmware version in
this way.

I would prefer export the firmware version this way and also add it to
the hardware info in debugfs, where it already is.

Hauke