2011-07-16 23:13:31

by Rafał Miłecki

[permalink] [raw]
Subject: [RFC][PATCH] b43: correctly display longer chipsets ids

Some of the newer Broadcom chipsets have longe names like BCM43224,
BCM43225, etc. However Broadcom decided to keep using u16 for storing
them. Use %X or %d depending on chip_id value to avoid BCMA8D8, etc.
---
Is there any nicer way of doing that? Currently I have whole string
duplicated. Can we define part of the format using condition? Like
(chip_id > 0x9999) ? "%d" : "%04X"
?
---
drivers/net/wireless/b43/main.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 22f20e1..549555e 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -5202,7 +5202,9 @@ static struct b43_wl *b43_wireless_init(struct b43_bus_dev *dev)
INIT_WORK(&wl->tx_work, b43_tx_work);
skb_queue_head_init(&wl->tx_queue);

- b43info(wl, "Broadcom %04X WLAN found (core revision %u)\n",
+ b43info(wl, (dev->chip_id > 0x9999) ?
+ "Broadcom %d WLAN found (core revision %u)\n" :
+ "Broadcom %04X WLAN found (core revision %u)\n",
dev->chip_id, dev->core_rev);
return wl;
}
--
1.7.3.4



2011-07-18 16:58:25

by Pavel Roskin

[permalink] [raw]
Subject: Re: [RFC][PATCH] b43: correctly display longer chipsets ids

On 07/16/2011 07:52 PM, Rafał Miłecki wrote:
> Some of the newer Broadcom chipsets have longe names like BCM43224,
> BCM43225, etc. However Broadcom decided to keep using u16 for storing
> them. Use %X or %d depending on chip_id value to avoid BCMA8D8, etc.
> ---
> Is there any nicer way of doing that? Currently I have whole string
> duplicated. Can we define part of the format using condition? Like
> (chip_id> 0x9999) ? "%d" : "%04X"

The standard way is snprintf(). The hacky way would be to convert
numbers over 0x9999 to the numbers that would display in hex as the
original numbers would show in decimal.

If we are only going to use those numbers in one place, I'd use
snprintf(). If there are chances that the number would be used in many
places, perhaps having the hex id representation would be justified.

--
Regards,
Pavel Roskin