b43: be more user friendly with PHY info
PATCH v2 1/1 b43: be more user friendly with PHY info
First of all, use PHY names instead of magic numbers. It should make configuring kernel easier in case of not enabled PHY type support. Secondly, always print info about PHY. This is really basic info about hardware and quite important for the support level.
---
V2: add new PHYTYPEs
--- drivers/net/wireless/b43/b43.h | 2 + drivers/net/wireless/b43/main.c | 40 ++++++++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 5 deletions(-)
drivers/net/wireless/b43/b43.h +2 -0
@@ -415,6 +415,8 @@ enum {#define B43_PHYTYPE_HT 0x07#define B43_PHYTYPE_LCN 0x08#define B43_PHYTYPE_LCNXN 0x09 +#define B43_PHYTYPE_LCN40 0x0a +#define B43_PHYTYPE_AC 0x0b/* PHYRegisters */ #define B43_PHY_ILT_A_CTRL 0x0072
drivers/net/wireless/b43/main.c +35 -5
@@ -4277,6 +4277,37 @@ out:return err; } +static char *b43_phy_name (struct b43_wldev *dev,u8 phy_type) +{ +switch (phy_type) { +case B43_PHYTYPE_A : +return "A" ; +case B43_PHYTYPE_B : +return "B" ; +case B43_PHYTYPE_G : +return "G" ; +case B43_PHYTYPE_N : +return "N" ; +case B43_PHYTYPE_LP : +return "LP" ; +case B43_PHYTYPE_SSLPN : +return "SSLPN" ; +case B43_PHYTYPE_HT : +return "HT" ; +case B43_PHYTYPE_LCN : +return "LCN" ; +case B43_PHYTYPE_LCNXN : +return "LCNXN" ; +case B43_PHYTYPE_LCN40 : +return "LCN40" ; +case B43_PHYTYPE_AC : +return "AC" ; + } + +b43err (dev->wl,"Unknown PHY Type: %d\n" , phy_type); +return "UNKNOWN" ; +} +/* Get PHY and RADIO versioning numbers */ static int b43_phy_versioning (struct b43_wldev *dev) {
@@ -4337,13 +4368,12 @@ static int b43_phy_versioning(struct b43_wldev *dev) unsupported =1 ; }if (unsupported) { -b43err (dev->wl,"FOUND UNSUPPORTED PHY " -"(Analog %u, Type %u, Revision %u)\n" , - analog_type, phy_type, phy_rev); +b43err (dev->wl,"FOUND UNSUPPORTED PHY (Analog %u, Type %s, Revision %u)\n" , + analog_type,b43_phy_name (dev, phy_type), phy_rev);return -EOPNOTSUPP ; } -b43dbg (dev->wl,"Found PHY: Analog %u, Type %u, Revision %u\n" , - analog_type, phy_type, phy_rev); +b43info (dev->wl,"Found PHY: Analog %u, Type %s, Revision %u\n" , + analog_type,b43_phy_name (dev, phy_type), phy_rev);/* Get RADIO versioning */ if (dev->dev->core_rev >=24 ) {
Signature · 1 line
1.7.7
PATCH v2 1/1 b43: be more user friendly with PHY info
Quoted 1 line · Rafa? Mi?ecki
use PHY names instead of magic numbers.
[]
drivers/net/wireless/b43/main.c
Quoted 1 line
drivers/net/wireless/b43/main.c +0
-0
[]
drivers/net/wireless/b43/main.c out:
Quoted 1 line
drivers/net/wireless/b43/main.c +0
-0@@ -4277,6 +4277,37 @@ out:
[]
drivers/net/wireless/b43/main.c out: · line 4284
Quoted 5 lines
drivers/net/wireless/b43/main.c +5
-0+static char *b43_phy_name (struct b43_wldev *dev,u8 phy_type) +{ +switch (phy_type) { +case B43_PHYTYPE_A : +return "A" ;
[]
drivers/net/wireless/b43/main.c out: · line 4308
Quoted 4 lines
drivers/net/wireless/b43/main.c +4
-0+ } + +b43err (dev->wl,"Unknown PHY Type: %d\n" , phy_type); +return "UNKNOWN" ;
In general, it's a bad idea to emit error messages in a generic call like this.
drivers/net/wireless/b43/main.c static int b43_phy_versioning(struct b43_wldev *dev) · line 4372
Quoted 9 lines
drivers/net/wireless/b43/main.c +2
-3@@ -4337,13 +4368,12 @@ static int b43_phy_versioning(struct b43_wldev *dev) unsupported =1 ; }if (unsupported) { -b43err (dev->wl,"FOUND UNSUPPORTED PHY " -"(Analog %u, Type %u, Revision %u)\n" , - analog_type, phy_type, phy_rev); +b43err (dev->wl,"FOUND UNSUPPORTED PHY (Analog %u, Type %s, Revision %u)\n" , + analog_type,b43_phy_name (dev, phy_type), phy_rev);
The extra message doesn't add much useful info
and can also cause errors in continued messages.
PATCH v2 1/1 b43: be more user friendly with PHY info
2012/7/25 Joe Perches <[email protected]>:
Quoted 13 lines · Rafa? Mi?ecki
Quoted 1 line
use PHY names instead of magic numbers.
[]
drivers/net/wireless/b43/main.c
Quoted 1 line
drivers/net/wireless/b43/main.c +0
-0[]
drivers/net/wireless/b43/main.c out:
Quoted 1 line
drivers/net/wireless/b43/main.c +0
-0@@ -4277,6 +4277,37 @@ out:[]
drivers/net/wireless/b43/main.c out: · line 4284
Quoted 5 lines
drivers/net/wireless/b43/main.c +5
-0+static char *b43_phy_name (struct b43_wldev *dev,u8 phy_type) +{ +switch (phy_type) { +case B43_PHYTYPE_A : +return "A" ;[]
Quoted 7 lines
drivers/net/wireless/b43/main.c out: · line 4308
Quoted 4 lines
drivers/net/wireless/b43/main.c +4
-0+ } + +b43err (dev->wl,"Unknown PHY Type: %d\n" , phy_type); +return "UNKNOWN" ;In general, it's a bad idea to emit error messages in a generic call like this.
This function is not supposed to be called anywhere else, it's only for a single user-friendly message.
Quoted 4 lines
Quoted 4 lines
drivers/net/wireless/b43/main.c +0
-0@@ -4337,13 +4368,12 @@ static int b43_phy_versioning(struct b43_wldev *dev) unsupported =1 ; }if (unsupported) {
Quoted 8 lines
drivers/net/wireless/b43/main.c static int b43_phy_versioning(struct b43_wldev *dev) · line 4372
Quoted 5 lines
drivers/net/wireless/b43/main.c +2
-3-b43err (dev->wl,"FOUND UNSUPPORTED PHY " -"(Analog %u, Type %u, Revision %u)\n" , - analog_type, phy_type, phy_rev); +b43err (dev->wl,"FOUND UNSUPPORTED PHY (Analog %u, Type %s, Revision %u)\n" , + analog_type,b43_phy_name (dev, phy_type), phy_rev);The extra message doesn't add much useful info
and can also cause errors in continued messages.
By "extra message" do you mean the one from b43_phy_name? I wanted to print PHY type as digit somewhere (in case it is not recognized). I can't use simple
return ("UNKNOWN %d", phy_type);
, such a solution would require allocating memory for string and freeing it. It would complicate the function.
Do you have any suggestion for better handling this?
Signature · 1 line
Rafa?
PATCH v2 1/1 b43: be more user friendly with PHY info
Quoted 39 lines · Rafa? Mi?ecki
2012/7/25 Joe Perches <[email protected]>:
Quoted 13 lines · Rafa? Mi?ecki
Quoted 1 line
use PHY names instead of magic numbers.
[]
drivers/net/wireless/b43/main.c
Quoted 1 line
drivers/net/wireless/b43/main.c +0
-0[]
drivers/net/wireless/b43/main.c out:
Quoted 1 line
drivers/net/wireless/b43/main.c +0
-0@@ -4277,6 +4277,37 @@ out:[]
drivers/net/wireless/b43/main.c out: · line 4284
Quoted 5 lines
drivers/net/wireless/b43/main.c +5
-0+static char *b43_phy_name (struct b43_wldev *dev,u8 phy_type) +{ +switch (phy_type) { +case B43_PHYTYPE_A : +return "A" ;[]
Quoted 7 lines
drivers/net/wireless/b43/main.c out: · line 4308
Quoted 4 lines
drivers/net/wireless/b43/main.c +4
-0+ } + +b43err (dev->wl,"Unknown PHY Type: %d\n" , phy_type); +return "UNKNOWN" ;In general, it's a bad idea to emit error messages in a generic call like this.
This function is not supposed to be called anywhere else, it's only for a single user-friendly message.
Quoted 4 lines
Quoted 4 lines
drivers/net/wireless/b43/main.c +0
-0@@ -4337,13 +4368,12 @@ static int b43_phy_versioning(struct b43_wldev *dev) unsupported =1 ; }if (unsupported) {Quoted 8 lines
drivers/net/wireless/b43/main.c static int b43_phy_versioning(struct b43_wldev *dev) · line 4372
Quoted 5 lines
drivers/net/wireless/b43/main.c +2
-3-b43err (dev->wl,"FOUND UNSUPPORTED PHY " -"(Analog %u, Type %u, Revision %u)\n" , - analog_type, phy_type, phy_rev); +b43err (dev->wl,"FOUND UNSUPPORTED PHY (Analog %u, Type %s, Revision %u)\n" , + analog_type,b43_phy_name (dev, phy_type), phy_rev);The extra message doesn't add much useful info
and can also cause errors in continued messages.
Quoted 9 lines
By "extra message" do you mean the one from
b43_phy_name? I wanted to print PHY type as digit somewhere (in case it is not recognized). I can't use simple
return ("UNKNOWN %d",phy_type);
, such a solution would require allocating memory for string and freeing it. It would complicate the function.Do you have any suggestion for better handling this?
Change the UNSUPPORTED PHY message to
"...Type: %d:(%s)...", ..., phy_type, b43_phy_name(dev, phy_type), ...
PATCH v2 1/1 b43: be more user friendly with PHY info
2012/7/25 Joe Perches <[email protected]>:
Quoted 47 lines · Rafa? Mi?ecki
Quoted 46 lines
2012/7/25 Joe Perches <[email protected]>:
Quoted 13 lines · Rafa? Mi?ecki
Quoted 1 line
use PHY names instead of magic numbers.
[]
drivers/net/wireless/b43/main.c
Quoted 1 line
drivers/net/wireless/b43/main.c +0
-0[]
drivers/net/wireless/b43/main.c out:
Quoted 1 line
drivers/net/wireless/b43/main.c +0
-0@@ -4277,6 +4277,37 @@ out:[]
drivers/net/wireless/b43/main.c out: · line 4284
Quoted 5 lines
drivers/net/wireless/b43/main.c +5
-0+static char *b43_phy_name (struct b43_wldev *dev,u8 phy_type) +{ +switch (phy_type) { +case B43_PHYTYPE_A : +return "A" ;[]
Quoted 7 lines
drivers/net/wireless/b43/main.c out: · line 4308
Quoted 4 lines
drivers/net/wireless/b43/main.c +4
-0+ } + +b43err (dev->wl,"Unknown PHY Type: %d\n" , phy_type); +return "UNKNOWN" ;In general, it's a bad idea to emit error messages in a generic call like this.
This function is not supposed to be called anywhere else, it's only for a single user-friendly message.
Quoted 4 lines
Quoted 4 lines
drivers/net/wireless/b43/main.c +0
-0@@ -4337,13 +4368,12 @@ static int b43_phy_versioning(struct b43_wldev *dev) unsupported =1 ; }if (unsupported) {Quoted 8 lines
drivers/net/wireless/b43/main.c static int b43_phy_versioning(struct b43_wldev *dev) · line 4372
Quoted 5 lines
drivers/net/wireless/b43/main.c +2
-3-b43err (dev->wl,"FOUND UNSUPPORTED PHY " -"(Analog %u, Type %u, Revision %u)\n" , - analog_type, phy_type, phy_rev); +b43err (dev->wl,"FOUND UNSUPPORTED PHY (Analog %u, Type %s, Revision %u)\n" , + analog_type,b43_phy_name (dev, phy_type), phy_rev);The extra message doesn't add much useful info
and can also cause errors in continued messages.By "extra message" do you mean the one from
b43_phy_name? I wanted to print PHY type as digit somewhere (in case it is not recognized). I can't use simple
return ("UNKNOWN %d",phy_type);
, such a solution would require allocating memory for string and freeing it. It would complicate the function.
Quoted 7 lines
Quoted 2 lines
Do you have any suggestion for better handling this?
Change the UNSUPPORTED PHY message to
"...Type: %d:(%s)...", ..., phy_type, b43_phy_name(dev, phy_type), ...
I think it should be fine :)
Signature · 1 line
Rafa?