diff mbox

[2/4] brcmutil: add helper function to format board revision

Message ID 1416518822-29585-3-git-send-email-arend@broadcom.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Arend van Spriel Nov. 20, 2014, 9:27 p.m. UTC
The board revision that is available in hardware can be translated
so it matches the labelling on the board. This is accomplished by
this helper function.

Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
---
 drivers/net/wireless/brcm80211/brcmutil/utils.c      | 16 ++++++++++++++++
 drivers/net/wireless/brcm80211/include/brcmu_utils.h |  2 ++
 2 files changed, 18 insertions(+)

Comments

John W. Linville Nov. 24, 2014, 9:53 p.m. UTC | #1
I am holding patches 2-4 until we resolve the brcmu_boardrev_str
build thing...

On Thu, Nov 20, 2014 at 10:27:00PM +0100, Arend van Spriel wrote:
> The board revision that is available in hardware can be translated
> so it matches the labelling on the board. This is accomplished by
> this helper function.
> 
> Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
> Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
> Signed-off-by: Arend van Spriel <arend@broadcom.com>
> ---
>  drivers/net/wireless/brcm80211/brcmutil/utils.c      | 16 ++++++++++++++++
>  drivers/net/wireless/brcm80211/include/brcmu_utils.h |  2 ++
>  2 files changed, 18 insertions(+)
> 
> diff --git a/drivers/net/wireless/brcm80211/brcmutil/utils.c b/drivers/net/wireless/brcm80211/brcmutil/utils.c
> index 0f7e1c7..af97f8b 100644
> --- a/drivers/net/wireless/brcm80211/brcmutil/utils.c
> +++ b/drivers/net/wireless/brcm80211/brcmutil/utils.c
> @@ -292,4 +292,20 @@ void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...)
>  	print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, data, size);
>  }
>  EXPORT_SYMBOL(brcmu_dbg_hex_dump);
> +
> +/* Produce a human-readable string for boardrev */
> +char *brcmu_boardrev_str(u32 brev, char *buf)
> +{
> +	char c;
> +
> +	if (brev < 0x100) {
> +		snprintf(buf, 8, "%d.%d", (brev & 0xf0) >> 4, brev & 0xf);
> +	} else {
> +		c = (brev & 0xf000) == 0x1000 ? 'P' : 'A';
> +		snprintf(buf, 8, "%c%03x", c, brev & 0xfff);
> +	}
> +	return buf;
> +}
> +EXPORT_SYMBOL(brcmu_boardrev_str);
> +
>  #endif				/* defined(DEBUG) */
> diff --git a/drivers/net/wireless/brcm80211/include/brcmu_utils.h b/drivers/net/wireless/brcm80211/include/brcmu_utils.h
> index 8ba445b..a043e29 100644
> --- a/drivers/net/wireless/brcm80211/include/brcmu_utils.h
> +++ b/drivers/net/wireless/brcm80211/include/brcmu_utils.h
> @@ -218,4 +218,6 @@ void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...)
>  }
>  #endif
>  
> +char *brcmu_boardrev_str(u32 brev, char *buf);
> +
>  #endif				/* _BRCMU_UTILS_H_ */
> -- 
> 1.9.1
> 
>
Arend van Spriel Nov. 25, 2014, 10:01 a.m. UTC | #2
On 11/24/14 22:53, John W. Linville wrote:
> I am holding patches 2-4 until we resolve the brcmu_boardrev_str
> build thing...

Actually, only patch 2 and 3 are related to the build thing. If that is 
what this is.

Regards,
Arend

> On Thu, Nov 20, 2014 at 10:27:00PM +0100, Arend van Spriel wrote:
>> The board revision that is available in hardware can be translated
>> so it matches the labelling on the board. This is accomplished by
>> this helper function.
>>
>> Reviewed-by: Hante Meuleman<meuleman@broadcom.com>
>> Reviewed-by: Pieter-Paul Giesberts<pieterpg@broadcom.com>
>> Signed-off-by: Arend van Spriel<arend@broadcom.com>
>> ---
>>   drivers/net/wireless/brcm80211/brcmutil/utils.c      | 16 ++++++++++++++++
>>   drivers/net/wireless/brcm80211/include/brcmu_utils.h |  2 ++
>>   2 files changed, 18 insertions(+)
>>
>> diff --git a/drivers/net/wireless/brcm80211/brcmutil/utils.c b/drivers/net/wireless/brcm80211/brcmutil/utils.c
>> index 0f7e1c7..af97f8b 100644
>> --- a/drivers/net/wireless/brcm80211/brcmutil/utils.c
>> +++ b/drivers/net/wireless/brcm80211/brcmutil/utils.c
>> @@ -292,4 +292,20 @@ void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...)
>>   	print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, data, size);
>>   }
>>   EXPORT_SYMBOL(brcmu_dbg_hex_dump);
>> +
>> +/* Produce a human-readable string for boardrev */
>> +char *brcmu_boardrev_str(u32 brev, char *buf)
>> +{
>> +	char c;
>> +
>> +	if (brev<  0x100) {
>> +		snprintf(buf, 8, "%d.%d", (brev&  0xf0)>>  4, brev&  0xf);
>> +	} else {
>> +		c = (brev&  0xf000) == 0x1000 ? 'P' : 'A';
>> +		snprintf(buf, 8, "%c%03x", c, brev&  0xfff);
>> +	}
>> +	return buf;
>> +}
>> +EXPORT_SYMBOL(brcmu_boardrev_str);
>> +
>>   #endif				/* defined(DEBUG) */
>> diff --git a/drivers/net/wireless/brcm80211/include/brcmu_utils.h b/drivers/net/wireless/brcm80211/include/brcmu_utils.h
>> index 8ba445b..a043e29 100644
>> --- a/drivers/net/wireless/brcm80211/include/brcmu_utils.h
>> +++ b/drivers/net/wireless/brcm80211/include/brcmu_utils.h
>> @@ -218,4 +218,6 @@ void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...)
>>   }
>>   #endif
>>
>> +char *brcmu_boardrev_str(u32 brev, char *buf);
>> +
>>   #endif				/* _BRCMU_UTILS_H_ */
>> --
>> 1.9.1
>>
>>
>

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
John W. Linville Nov. 25, 2014, 6:51 p.m. UTC | #3
On Tue, Nov 25, 2014 at 11:01:47AM +0100, Arend van Spriel wrote:
> On 11/24/14 22:53, John W. Linville wrote:
> >I am holding patches 2-4 until we resolve the brcmu_boardrev_str
> >build thing...
> 
> Actually, only patch 2 and 3 are related to the build thing. If that is what
> this is.
 
OK, I won't hold-up #4...
diff mbox

Patch

diff --git a/drivers/net/wireless/brcm80211/brcmutil/utils.c b/drivers/net/wireless/brcm80211/brcmutil/utils.c
index 0f7e1c7..af97f8b 100644
--- a/drivers/net/wireless/brcm80211/brcmutil/utils.c
+++ b/drivers/net/wireless/brcm80211/brcmutil/utils.c
@@ -292,4 +292,20 @@  void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...)
 	print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, data, size);
 }
 EXPORT_SYMBOL(brcmu_dbg_hex_dump);
+
+/* Produce a human-readable string for boardrev */
+char *brcmu_boardrev_str(u32 brev, char *buf)
+{
+	char c;
+
+	if (brev < 0x100) {
+		snprintf(buf, 8, "%d.%d", (brev & 0xf0) >> 4, brev & 0xf);
+	} else {
+		c = (brev & 0xf000) == 0x1000 ? 'P' : 'A';
+		snprintf(buf, 8, "%c%03x", c, brev & 0xfff);
+	}
+	return buf;
+}
+EXPORT_SYMBOL(brcmu_boardrev_str);
+
 #endif				/* defined(DEBUG) */
diff --git a/drivers/net/wireless/brcm80211/include/brcmu_utils.h b/drivers/net/wireless/brcm80211/include/brcmu_utils.h
index 8ba445b..a043e29 100644
--- a/drivers/net/wireless/brcm80211/include/brcmu_utils.h
+++ b/drivers/net/wireless/brcm80211/include/brcmu_utils.h
@@ -218,4 +218,6 @@  void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...)
 }
 #endif
 
+char *brcmu_boardrev_str(u32 brev, char *buf);
+
 #endif				/* _BRCMU_UTILS_H_ */