Skip to contentSkip to conversation

ath5k: Cleanup after API changes patch

PATCH In review Luis R. Rodriguez 4 participants 18 messages Feb 1, 2008 – Feb 2, 2008 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath5k: Cleanup after API changes patch

Cleanup after API changes patch (checkpatch.pl stuff) and on ath5k_hw_rf5112_channel() make use of the new channel->band and existing ath5k_channel_ok() instead of re-implementing the checks again. This was necessary to make the code cleaner and fit the 80-chars wide limit so sending it within the same patch.

Finally make a note that we should eventually move cap_range stuff to struct wiphy.

This patch applies ontop of Nick's API changes patch.

drivers/net/wireless/ath5k/ath5k.h: Changes-licensed-under: ISC
drivers/net/wireless/ath5k/base.c: Changes-licensed-under: 3-Clause-BSD
drivers/net/wireless/ath5k/initvals.c: Changes-licensed-under: ISC
drivers/net/wireless/ath5k/phy.c: Changes-licensed-under: ISC

---
 drivers/net/wireless/ath5k/ath5k.h    |    8 ++-
 drivers/net/wireless/ath5k/base.c     |  126 +++++++++++++++++++--------------
 drivers/net/wireless/ath5k/initvals.c |    6 +-
 drivers/net/wireless/ath5k/phy.c      |   48 +++++++++----
 4 files changed, 118 insertions(+), 70 deletions(-)
drivers/net/wireless/ath5k/ath5k.h +6 -2
index 3b03600..7b8a1df 100644
@@ -263,8 +263,10 @@ enum ath5k_driver_mode {
 /* adding this flag to rate_code enables short preamble, see ar5212_reg.h */
 #define AR5K_SET_SHORT_PREAMBLE 0x04
 
-#define HAS_SHPREAMBLE(_ix) (rt->rates[_ix].modulation == IEEE80211_RATE_SHORT_PREAMBLE)
-#define SHPREAMBLE_FLAG(_ix) (HAS_SHPREAMBLE(_ix) ? AR5K_SET_SHORT_PREAMBLE : 0)
+#define HAS_SHPREAMBLE(_ix) \
+	(rt->rates[_ix].modulation == IEEE80211_RATE_SHORT_PREAMBLE)
+#define SHPREAMBLE_FLAG(_ix) \
+	(HAS_SHPREAMBLE(_ix) ? AR5K_SET_SHORT_PREAMBLE : 0)
 
 /****************\
   TX DEFINITIONS
@@ -892,6 +894,8 @@ enum ath5k_capability_type {
 	AR5K_CAP_RFSILENT		= 20,	/* Supports RFsilent */
 };
 
+
+/* XXX: move cap_range stuff to struct wiphy, use these helper for now */
 struct ath5k_capabilities {
 	/*
 	 * Supported PHY modes
drivers/net/wireless/ath5k/base.c +73 -53

251 lines not on this page · raw message

drivers/net/wireless/ath5k/initvals.c +4 -2
index a255d8b..cfcb1fe 100644
@@ -1317,8 +1317,10 @@ int ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool change_channel)
 	/* For AR5211 */
 	} else if (ah->ah_version == AR5K_AR5211) {
 
-		if(mode > 2){ /* AR5K_MODE_11B */
-			ATH5K_ERR(ah->ah_sc,"unsupported channel mode: %d\n", mode);
+		/* AR5K_MODE_11B */
+		if (mode > 2) {
+			ATH5K_ERR(ah->ah_sc,
+				"unsupported channel mode: %d\n", mode);
 			return -EINVAL;
 		}
 
drivers/net/wireless/ath5k/phy.c +35 -13

83 lines not on this page · raw message

Signature · 1 line
1.5.2.5
maintainer
#1 lore raw
Quoted 3 lines

Finally make a note that we should eventually move cap_range stuff to struct wiphy.

What is cap_range and why should it be in struct wiphy?

johannes

#2 lore raw
Quoted 5 lines · Johannes Berg
Quoted 3 lines

Finally make a note that we should eventually move cap_range stuff to struct wiphy.

What is cap_range and why should it be in struct wiphy?

Its the device's frequency capability range on the bands.

Luis

maintainer
#3 lore raw
Quoted 4 lines
Quoted 2 lines

What is cap_range and why should it be in struct wiphy?

Its the device's frequency capability range on the bands.

Well since we always need channels I decided to not have such a thing but rather require registering a channels array that is also used for bookkeeping about enabled/disabled channels etc.

I guess you could add a helper function that allocates a channels array based on a frequency range.

johannes

#4 lore raw

2008/2/1 Johannes Berg <[email protected]>:

Quoted 11 lines
Quoted 4 lines
Quoted 2 lines

What is cap_range and why should it be in struct wiphy?

Its the device's frequency capability range on the bands.

Well since we always need channels I decided to not have such a thing but rather require registering a channels array that is also used for bookkeeping about enabled/disabled channels etc.

I guess you could add a helper function that allocates a channels array based on a frequency range.

This is true but also it would be nice as it is the end points which drivers may want
to access every now and then. I think its worth the few bytes.

Luis

maintainer
#5 lore raw
Quoted 7 lines
Quoted 3 lines

I guess you could add a helper function that allocates a channels array based on a frequency range.

This is true but also it would be nice as it is the end points which drivers may want
to access every now and then. I think its worth the few bytes.

I'm not really worried about the space that needs, but I don't see why the wiphy would need that information. Couldn't you keep it in your driver's per-hw structure as it is? Would cfg80211 be required to keep them updated according to regulatory rules when the allowed channels change? I'm much more worried about all the code that would result in :) But since you're not doing that right now anyway I'll just wait and see what you come up with ;)

johannes

#6 lore raw

2008/2/1 Johannes Berg <[email protected]>:

Quoted 10 lines
Quoted 7 lines
Quoted 3 lines

I guess you could add a helper function that allocates a channels array based on a frequency range.

This is true but also it would be nice as it is the end points which drivers may want
to access every now and then. I think its worth the few bytes.

I'm not really worried about the space that needs, but I don't see why the wiphy would need that information.

Export capabilities to userspace would be the main reason. The bands can be iterated but why do iteration when we can just set the upper and lower limits?

Quoted 2 lines

Couldn't you keep it in your
driver's per-hw structure as it is?

Sure, we could. But it seems it would be nice to have this information easily accessible to drivers and to userspace API.

Quoted 3 lines

Would cfg80211 be required to keep
them updated according to regulatory rules when the allowed channels change?

Nope, I'm just thinking in terms of "hw support capabilities".

Quoted 1 line

I'm much more worried about all the code that would result in :)

Yeah, I'm not thinking of it in terms of regulatory now. Just in terms of reasonable capability value accessible to drivers and to userspace.

Quoted 2 lines

But since you're not doing that right now anyway I'll just wait and see what you come up with ;)

Hey man, its tough when you have 2 laptops poop out on you in less than 2 months... this is my excuse this month. Its a new months so I get one.

Luis

#7 lore raw
In reply to Luis R. Rodriguez

2008/2/1, Luis R. Rodriguez <[email protected]>:

Quoted 10 lines

2008/2/1 Johannes Berg <[email protected]>:

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

What is cap_range and why should it be in struct wiphy?

Its the device's frequency capability range on the bands.

Well since we always need channels I decided to not have such a thing but rather require registering a channels array that is also used for bookkeeping about enabled/disabled channels etc.

Quoted 8 lines
Quoted 2 lines

I guess you could add a helper function that allocates a channels array based on a frequency range.

This is true but also it would be nice as it is the end points which drivers may want
to access every now and then. I think its worth the few bytes.

Luis

Why mac80211/cfg80211 has to know about phy's channel range ? I mean driver knows it and that's all we need to create the big (unfiltered) channel array. These caps are set for some chip revisions (eg. 5210 supports only part of 5GHz band while 5111/5112 support much wider range) and only used by channel_ok during channel setup (attach), we don't have any other use for those inside the driver. Other drivers don't even need such caps because channel ranges are standard for all their chip revisions, or they get channels from firmware, or use fixed range/channel table no matter what phy supports etc.

The only use i can imagine for frequency range information on mac80211/cfg80211 is that the whole channel setup is being done during wiphy setup (we provide frequency range and supported bands and mac80211/cfg80211 does the rest) but we'll have (at least for ath5k) to fill channel flags (hw_value) anyway.

About the patch: You are right that we should use channel_ok in hw_channel but there is no need for that switch, channel_ok checks the channel flags (hw_value) and determines the band already (and channel flags are filled per band -CHANNEL_2GHZ/CHANNEL_5GHZ- during setup so checking channel->band or channel->hw_vallue is the same).

Signature · 3 lines
GPG ID: 0xD21DB2DB
As you read this post global entropy rises. Have Fun ;-)
Nick
#8 lore raw
Quoted 19 lines · Nick Kossifidis

2008/2/1, Luis R. Rodriguez <[email protected]>:

Quoted 17 lines

2008/2/1 Johannes Berg <[email protected]>:

Quoted 11 lines
Quoted 4 lines
Quoted 2 lines

What is cap_range and why should it be in struct wiphy?

Its the device's frequency capability range on the bands.

Well since we always need channels I decided to not have such a thing but rather require registering a channels array that is also used for bookkeeping about enabled/disabled channels etc.

I guess you could add a helper function that allocates a channels array based on a frequency range.

This is true but also it would be nice as it is the end points which drivers may want
to access every now and then. I think its worth the few bytes.

Quoted 5 lines
Quoted 1 line

Luis

Why mac80211/cfg80211 has to know about phy's channel range ? I mean driver knows it and that's all we need to create the big (unfiltered) channel array.

Yes, you are right, from a driver's perspective this is all we need this for. But, for example, say user tries to change to a channel by freq, and we want to see if we support it, wouldn't it be easier to have mac80211 do the check for us against the wiphy's range on the band instead of having the driver do it? mac80211 would do it a lot quicker by just knowing the range for example.

Quoted 4 lines

These caps are set for some chip revisions (eg. 5210 supports only part of 5GHz band while 5111/5112 support much wider range) and only used by channel_ok during channel setup (attach), we don't have any other use for those inside the driver.

Sure.

Quoted 4 lines

Other drivers
don't even need such caps because channel ranges are standard for all their chip revisions, or they get channels from firmware, or use fixed range/channel table no matter what phy supports etc.

I just want to make it available for drivers in central place for those who *could* use it and for mac80211 for a quick short cut. Additionally it seems it would be good to export this to userspace instead of having it iterate over the array to simply get the range.

Quoted 5 lines

The only use i can imagine for frequency range information on mac80211/cfg80211 is that the whole channel setup is being done during wiphy setup (we provide frequency range and supported bands and mac80211/cfg80211 does the rest) but we'll have (at least for ath5k) to fill channel flags (hw_value) anyway.

You are right, we discussed this a while back on the list as well and came to the same conclusion. I am curious -- are there drivers which have the same hw_value as the freq? But disregard this -- this isn't the reason why I brought up the cap. I've mentioned the reasons above and to johill in my last reply. Please let me know what you think.

Quoted 5 lines

About the patch: You are right that we should use channel_ok in hw_channel but there is no need for that switch, channel_ok checks the channel flags (hw_value) and determines the band already (and channel flags are filled per band -CHANNEL_2GHZ/CHANNEL_5GHZ- during setup so checking channel->band or channel->hw_vallue is the same).

OK I think I see your point. I can send a follow up patch if you don't mind.

Luis

#9 lore raw
Quoted 62 lines · Luis R. Rodriguez
Quoted 19 lines · Nick Kossifidis

2008/2/1, Luis R. Rodriguez <[email protected]>:

Quoted 17 lines

2008/2/1 Johannes Berg <[email protected]>:

Quoted 11 lines
Quoted 4 lines
Quoted 2 lines

What is cap_range and why should it be in struct wiphy?

Its the device's frequency capability range on the bands.

Well since we always need channels I decided to not have such a thing but rather require registering a channels array that is also used for bookkeeping about enabled/disabled channels etc.

I guess you could add a helper function that allocates a channels array based on a frequency range.

This is true but also it would be nice as it is the end points which drivers may want
to access every now and then. I think its worth the few bytes.

Quoted 5 lines
Quoted 1 line

Luis

Why mac80211/cfg80211 has to know about phy's channel range ? I mean driver knows it and that's all we need to create the big (unfiltered) channel array.

Yes, you are right, from a driver's perspective this is all we need this for. But, for example, say user tries to change to a channel by freq, and we want to see if we support it, wouldn't it be easier to have mac80211 do the check for us against the wiphy's range on the band instead of having the driver do it? mac80211 would do it a lot quicker by just knowing the range for example.

Quoted 4 lines

These caps are set for some chip revisions (eg. 5210 supports only part of 5GHz band while 5111/5112 support much wider range) and only used by channel_ok during channel setup (attach), we don't have any other use for those inside the driver.

Sure.

Quoted 4 lines

Other drivers
don't even need such caps because channel ranges are standard for all their chip revisions, or they get channels from firmware, or use fixed range/channel table no matter what phy supports etc.

I just want to make it available for drivers in central place for those who *could* use it and for mac80211 for a quick short cut. Additionally it seems it would be good to export this to userspace instead of having it iterate over the array to simply get the range.

Quoted 5 lines

The only use i can imagine for frequency range information on mac80211/cfg80211 is that the whole channel setup is being done during wiphy setup (we provide frequency range and supported bands and mac80211/cfg80211 does the rest) but we'll have (at least for ath5k) to fill channel flags (hw_value) anyway.

You are right, we discussed this a while back on the list as well and came to the same conclusion. I am curious -- are there drivers which have the same hw_value as the freq? But disregard this -- this isn't the reason why I brought up the cap. I've mentioned the reasons above and to johill in my last reply. Please let me know what you think.

Quoted 7 lines
Quoted 5 lines

About the patch: You are right that we should use channel_ok in hw_channel but there is no need for that switch, channel_ok checks the channel flags (hw_value) and determines the band already (and channel flags are filled per band -CHANNEL_2GHZ/CHANNEL_5GHZ- during setup so checking channel->band or channel->hw_vallue is the same).

OK I think I see your point. I can send a follow up patch if you don't mind.

I'm just going to resend all pending patches. For this stuff I've shifted a bit like this:

        /*
         * Check bounds supported by the PHY (we don't care about regultory
         * restrictions at this point). Note: hw_value already has the band
         * (CHANNEL_2GHZ, or CHANNEL_5GHZ) so we inform ath5k_channel_ok()
         * of the band by that */
        if (!ath5k_channel_ok(ah, channel->center_freq, channel->hw_value)) {
                char bname[5];
                switch (channel->band) {
                case IEEE80211_BAND_2GHZ:
                        strcpy(bname, "2 GHz");
                        break;
                case IEEE80211_BAND_5GHZ:
                        strcpy(bname, "5 GHz");
                        break;
                default:
                        BUG_ON(1);
                        return -EINVAL;
                }
                ATH5K_ERR(ah->ah_sc,
                        "channel frequency (%u MHz) out of supported "
                        "%s band range (%u - %u MHz)\n",
                        channel->center_freq,
                        bname,
                        ah->ah_capabilities.cap_range.range_2ghz_min,
                        ah->ah_capabilities.cap_range.range_2ghz_max);
                        return -EINVAL;
        }
#10 lore raw
Quoted 22 lines

I'm just going to resend all pending patches. For this stuff I've shifted a bit like this:

        /*
         * Check bounds supported by the PHY (we don't care about regultory
         * restrictions at this point). Note: hw_value already has the band
         * (CHANNEL_2GHZ, or CHANNEL_5GHZ) so we inform ath5k_channel_ok()
         * of the band by that */
        if (!ath5k_channel_ok(ah, channel->center_freq, channel->hw_value)) {
                char bname[5];
                switch (channel->band) {
                case IEEE80211_BAND_2GHZ:
                        strcpy(bname, "2 GHz");
                        break;
                case IEEE80211_BAND_5GHZ:
                        strcpy(bname, "5 GHz");
                        break;
                default:
                        BUG_ON(1);
                        return -EINVAL;
                }
                ATH5K_ERR(ah->ah_sc,
Quoted 9 lines
                        "channel frequency (%u MHz) out of supported "
                        "%s band range (%u - %u MHz)\n",
                        channel->center_freq,
                        bname,
                        ah->ah_capabilities.cap_range.range_2ghz_min,
                        ah->ah_capabilities.cap_range.range_2ghz_max);
                        return -EINVAL;
        }

We really don't need all this IMHO, ath5k_channel_ok is a simple working function that's supposed to do all needed checks and print any error msg, if you want to modify something modify ath5k_channel_ok, don't add more stuff on the caller. Also why use strings for the band ??? You can have an int and set it 2 or 5 if you want (i realy think strcpy is baaad).

Signature · 3 lines
GPG ID: 0xD21DB2DB
As you read this post global entropy rises. Have Fun ;-)
Nick
#11 lore raw
Quoted 33 lines · Nick Kossifidis
Quoted 23 lines

I'm just going to resend all pending patches. For this stuff I've shifted a bit like this:

        /*
         * Check bounds supported by the PHY (we don't care about regultory
         * restrictions at this point). Note: hw_value already has the band
         * (CHANNEL_2GHZ, or CHANNEL_5GHZ) so we inform ath5k_channel_ok()
         * of the band by that */
        if (!ath5k_channel_ok(ah, channel->center_freq, channel->hw_value)) {
                char bname[5];
                switch (channel->band) {
                case IEEE80211_BAND_2GHZ:
                        strcpy(bname, "2 GHz");
                        break;
                case IEEE80211_BAND_5GHZ:
                        strcpy(bname, "5 GHz");
                        break;
                default:
                        BUG_ON(1);
                        return -EINVAL;
                }
                ATH5K_ERR(ah->ah_sc,
Quoted 9 lines
                        "channel frequency (%u MHz) out of supported "
                        "%s band range (%u - %u MHz)\n",
                        channel->center_freq,
                        bname,
                        ah->ah_capabilities.cap_range.range_2ghz_min,
                        ah->ah_capabilities.cap_range.range_2ghz_max);
                        return -EINVAL;
        }
Quoted 6 lines

We really don't need all this IMHO, ath5k_channel_ok is a simple working function that's supposed to do all needed checks and print any error msg, if you want to modify something modify ath5k_channel_ok, don't add more stuff on the caller. Also why use strings for the band ??? You can have an int and set it 2 or 5 if you want (i realy think strcpy is baaad).

OK fine, I'll edit ath5k_channel_ok in a later patch, for now I'll just keep the code to match what was there to finish the cleanup.

Luis

#12 lore raw
In reply to Luis R. Rodriguez
Quoted 24 lines · Luis R. Rodriguez

Cleanup after API changes patch (checkpatch.pl stuff) and on ath5k_hw_rf5112_channel() make use of the new channel->band and existing ath5k_channel_ok() instead of re-implementing the checks again. This was necessary to make the code cleaner and fit the 80-chars wide limit so sending it within the same patch.

Finally make a note that we should eventually move cap_range stuff to struct wiphy.

This patch applies ontop of Nick's API changes patch.

drivers/net/wireless/ath5k/ath5k.h: Changes-licensed-under: ISC
drivers/net/wireless/ath5k/base.c: Changes-licensed-under: 3-Clause-BSD
drivers/net/wireless/ath5k/initvals.c: Changes-licensed-under: ISC
drivers/net/wireless/ath5k/phy.c: Changes-licensed-under: ISC

---
 drivers/net/wireless/ath5k/ath5k.h    |    8 ++-
 drivers/net/wireless/ath5k/base.c     |  126 +++++++++++++++++++--------------
 drivers/net/wireless/ath5k/initvals.c |    6 +-
 drivers/net/wireless/ath5k/phy.c      |   48 +++++++++----
 4 files changed, 118 insertions(+), 70 deletions(-)

[...]

Quoted 4 lines
drivers/net/wireless/ath5k/base.c +0 -0
index 8ddac36..bd9c9a8 100644

[...]

Quoted 10 lines
drivers/net/wireless/ath5k/base.c +0 -6
@@ -889,13 +900,15 @@ ath5k_copy_channels(struct ath5k_hw *ah,
 		/* Write channel info and increment counter */
 		channels[count].center_freq = freq;
 
-		if((mode == AR5K_MODE_11A) ||
-		(mode == AR5K_MODE_11G)){
-			channels[count].hw_value = chfreq|CHANNEL_OFDM;
-		} else if((mode == AR5K_MODE_11A_TURBO) ||
-		(mode == AR5K_MODE_11G_TURBO)){
-			channels[count].hw_value = chfreq|CHANNEL_OFDM|CHANNEL_TURBO;

drivers/net/wireless/ath5k/base.c ath5k_copy_channels(struct ath5k_hw *ah, · line 911

Quoted 10 lines
drivers/net/wireless/ath5k/base.c +9 -1
-		}if(mode == AR5K_MODE_11B) {
+		if ((mode == AR5K_MODE_11A) ||
+			(mode == AR5K_MODE_11G)) {
+			channels[count].hw_value =
+				chfreq | CHANNEL_OFDM;
+		} else if ((mode == AR5K_MODE_11A_TURBO) ||
+			(mode == AR5K_MODE_11G_TURBO)) {
+			channels[count].hw_value =
+				chfreq | CHANNEL_OFDM|CHANNEL_TURBO;
+		} if (mode == AR5K_MODE_11B) {

'else' or '\n' before the if, please

Quoted 3 lines
drivers/net/wireless/ath5k/base.c +0 -0
 			channels[count].hw_value = CHANNEL_B;
 		}
 
#13 lore raw
Quoted 45 lines · Jiri Slaby
Quoted 24 lines · Luis R. Rodriguez

Cleanup after API changes patch (checkpatch.pl stuff) and on ath5k_hw_rf5112_channel() make use of the new channel->band and existing ath5k_channel_ok() instead of re-implementing the checks again. This was necessary to make the code cleaner and fit the 80-chars wide limit so sending it within the same patch.

Finally make a note that we should eventually move cap_range stuff to struct wiphy.

This patch applies ontop of Nick's API changes patch.

drivers/net/wireless/ath5k/ath5k.h: Changes-licensed-under: ISC
drivers/net/wireless/ath5k/base.c: Changes-licensed-under: 3-Clause-BSD
drivers/net/wireless/ath5k/initvals.c: Changes-licensed-under: ISC
drivers/net/wireless/ath5k/phy.c: Changes-licensed-under: ISC

---
 drivers/net/wireless/ath5k/ath5k.h    |    8 ++-
 drivers/net/wireless/ath5k/base.c     |  126 +++++++++++++++++++--------------
 drivers/net/wireless/ath5k/initvals.c |    6 +-
 drivers/net/wireless/ath5k/phy.c      |   48 +++++++++----
 4 files changed, 118 insertions(+), 70 deletions(-)

[...]

Quoted 4 lines
drivers/net/wireless/ath5k/base.c +0 -0
index 8ddac36..bd9c9a8 100644

[...]

Quoted 14 lines
drivers/net/wireless/ath5k/base.c +3 -7
@@ -889,13 +900,15 @@ ath5k_copy_channels(struct ath5k_hw *ah,
              /* Write channel info and increment counter */
              channels[count].center_freq = freq;
 
-             if((mode == AR5K_MODE_11A) ||
-             (mode == AR5K_MODE_11G)){
-                     channels[count].hw_value = chfreq|CHANNEL_OFDM;
-             } else if((mode == AR5K_MODE_11A_TURBO) ||
-             (mode == AR5K_MODE_11G_TURBO)){
-                     channels[count].hw_value = chfreq|CHANNEL_OFDM|CHANNEL_TURBO;
-             }if(mode == AR5K_MODE_11B) {
+             if ((mode == AR5K_MODE_11A) ||
+                     (mode == AR5K_MODE_11G)) {
+                     channels[count].hw_value =
Quoted 8 lines

drivers/net/wireless/ath5k/base.c ath5k_copy_channels(struct ath5k_hw *ah, · line 911

Quoted 6 lines
drivers/net/wireless/ath5k/base.c +6 -0
+                             chfreq | CHANNEL_OFDM;
+             } else if ((mode == AR5K_MODE_11A_TURBO) ||
+                     (mode == AR5K_MODE_11G_TURBO)) {
+                     channels[count].hw_value =
+                             chfreq | CHANNEL_OFDM|CHANNEL_TURBO;
+             } if (mode == AR5K_MODE_11B) {

'else' or '\n' before the if, please

Good catch, that should have been an "else if" there. Will repost all pending patches in a series addressing all posted comments.

Luis

#14 lore raw
Quoted 56 lines · Luis R. Rodriguez
Quoted 45 lines · Jiri Slaby
Quoted 24 lines · Luis R. Rodriguez

Cleanup after API changes patch (checkpatch.pl stuff) and on ath5k_hw_rf5112_channel() make use of the new channel->band and existing ath5k_channel_ok() instead of re-implementing the checks again. This was necessary to make the code cleaner and fit the 80-chars wide limit so sending it within the same patch.

Finally make a note that we should eventually move cap_range stuff to struct wiphy.

This patch applies ontop of Nick's API changes patch.

drivers/net/wireless/ath5k/ath5k.h: Changes-licensed-under: ISC
drivers/net/wireless/ath5k/base.c: Changes-licensed-under: 3-Clause-BSD
drivers/net/wireless/ath5k/initvals.c: Changes-licensed-under: ISC
drivers/net/wireless/ath5k/phy.c: Changes-licensed-under: ISC

---
 drivers/net/wireless/ath5k/ath5k.h    |    8 ++-
 drivers/net/wireless/ath5k/base.c     |  126 +++++++++++++++++++--------------
 drivers/net/wireless/ath5k/initvals.c |    6 +-
 drivers/net/wireless/ath5k/phy.c      |   48 +++++++++----
 4 files changed, 118 insertions(+), 70 deletions(-)

[...]

Quoted 4 lines
drivers/net/wireless/ath5k/base.c +0 -0
index 8ddac36..bd9c9a8 100644

[...]

Quoted 14 lines
drivers/net/wireless/ath5k/base.c +3 -7
@@ -889,13 +900,15 @@ ath5k_copy_channels(struct ath5k_hw *ah,
              /* Write channel info and increment counter */
              channels[count].center_freq = freq;
 
-             if((mode == AR5K_MODE_11A) ||
-             (mode == AR5K_MODE_11G)){
-                     channels[count].hw_value = chfreq|CHANNEL_OFDM;
-             } else if((mode == AR5K_MODE_11A_TURBO) ||
-             (mode == AR5K_MODE_11G_TURBO)){
-                     channels[count].hw_value = chfreq|CHANNEL_OFDM|CHANNEL_TURBO;
-             }if(mode == AR5K_MODE_11B) {
+             if ((mode == AR5K_MODE_11A) ||
+                     (mode == AR5K_MODE_11G)) {
+                     channels[count].hw_value =
Quoted 8 lines

drivers/net/wireless/ath5k/base.c ath5k_copy_channels(struct ath5k_hw *ah, · line 911

Quoted 6 lines
drivers/net/wireless/ath5k/base.c +6 -0
+                             chfreq | CHANNEL_OFDM;
+             } else if ((mode == AR5K_MODE_11A_TURBO) ||
+                     (mode == AR5K_MODE_11G_TURBO)) {
+                     channels[count].hw_value =
+                             chfreq | CHANNEL_OFDM|CHANNEL_TURBO;
+             } if (mode == AR5K_MODE_11B) {

'else' or '\n' before the if, please

Quoted 2 lines

Good catch, that should have been an "else if" there. Will repost all pending patches in a series addressing all posted comments.

Going to move this to a switch, its much more legible.

Luis

#15 lore raw
Quoted 24 lines · Luis R. Rodriguez
Quoted 23 lines · Luis R. Rodriguez
Quoted 22 lines · Jiri Slaby
Quoted 10 lines · Luis R. Rodriguez
drivers/net/wireless/ath5k/base.c +0 -6
@@ -889,13 +900,15 @@ ath5k_copy_channels(struct ath5k_hw *ah,
              /* Write channel info and increment counter */
              channels[count].center_freq = freq;
 
-             if((mode == AR5K_MODE_11A) ||
-             (mode == AR5K_MODE_11G)){
-                     channels[count].hw_value = chfreq|CHANNEL_OFDM;
-             } else if((mode == AR5K_MODE_11A_TURBO) ||
-             (mode == AR5K_MODE_11G_TURBO)){
-                     channels[count].hw_value = chfreq|CHANNEL_OFDM|CHANNEL_TURBO;

drivers/net/wireless/ath5k/base.c ath5k_copy_channels(struct ath5k_hw *ah, · line 911

Quoted 10 lines
drivers/net/wireless/ath5k/base.c +9 -1
-             }if(mode == AR5K_MODE_11B) {
+             if ((mode == AR5K_MODE_11A) ||
+                     (mode == AR5K_MODE_11G)) {
+                     channels[count].hw_value =
+                             chfreq | CHANNEL_OFDM;
+             } else if ((mode == AR5K_MODE_11A_TURBO) ||
+                     (mode == AR5K_MODE_11G_TURBO)) {
+                     channels[count].hw_value =
+                             chfreq | CHANNEL_OFDM|CHANNEL_TURBO;
+             } if (mode == AR5K_MODE_11B) {

'else' or '\n' before the if, please

Quoted 4 lines
Quoted 2 lines

Good catch, that should have been an "else if" there. Will repost all pending patches in a series addressing all posted comments.

Going to move this to a switch, its much more legible.

There was switch IIRC, I think either sparse or -W don't like it too much (enum <-> int)? Please could you check? (-W doesn't bother us.)

#16 lore raw
Quoted 25 lines · Jiri Slaby
Quoted 24 lines · Luis R. Rodriguez
Quoted 23 lines · Luis R. Rodriguez
Quoted 22 lines · Jiri Slaby
Quoted 10 lines · Luis R. Rodriguez
drivers/net/wireless/ath5k/base.c +0 -6
@@ -889,13 +900,15 @@ ath5k_copy_channels(struct ath5k_hw *ah,
              /* Write channel info and increment counter */
              channels[count].center_freq = freq;
 
-             if((mode == AR5K_MODE_11A) ||
-             (mode == AR5K_MODE_11G)){
-                     channels[count].hw_value = chfreq|CHANNEL_OFDM;
-             } else if((mode == AR5K_MODE_11A_TURBO) ||
-             (mode == AR5K_MODE_11G_TURBO)){
-                     channels[count].hw_value = chfreq|CHANNEL_OFDM|CHANNEL_TURBO;

drivers/net/wireless/ath5k/base.c ath5k_copy_channels(struct ath5k_hw *ah, · line 911

Quoted 10 lines
drivers/net/wireless/ath5k/base.c +9 -1
-             }if(mode == AR5K_MODE_11B) {
+             if ((mode == AR5K_MODE_11A) ||
+                     (mode == AR5K_MODE_11G)) {
+                     channels[count].hw_value =
+                             chfreq | CHANNEL_OFDM;
+             } else if ((mode == AR5K_MODE_11A_TURBO) ||
+                     (mode == AR5K_MODE_11G_TURBO)) {
+                     channels[count].hw_value =
+                             chfreq | CHANNEL_OFDM|CHANNEL_TURBO;
+             } if (mode == AR5K_MODE_11B) {

'else' or '\n' before the if, please

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Good catch, that should have been an "else if" there. Will repost all pending patches in a series addressing all posted comments.

Going to move this to a switch, its much more legible.

There was switch IIRC, I think either sparse or -W don't like it too much (enum <-> int)? Please could you check? (-W doesn't bother us.)

Thanks for the heads up, will do.

Luis

#17 lore raw
Quoted 30 lines · Luis R. Rodriguez
Quoted 28 lines · Jiri Slaby
Quoted 27 lines · Luis R. Rodriguez
Quoted 25 lines · Luis R. Rodriguez
Quoted 14 lines · Jiri Slaby
Quoted 13 lines · Luis R. Rodriguez
drivers/net/wireless/ath5k/base.c +2 -7
@@ -889,13 +900,15 @@ ath5k_copy_channels(struct ath5k_hw *ah,
              /* Write channel info and increment counter */
              channels[count].center_freq = freq;
 
-             if((mode == AR5K_MODE_11A) ||
-             (mode == AR5K_MODE_11G)){
-                     channels[count].hw_value = chfreq|CHANNEL_OFDM;
-             } else if((mode == AR5K_MODE_11A_TURBO) ||
-             (mode == AR5K_MODE_11G_TURBO)){
-                     channels[count].hw_value = chfreq|CHANNEL_OFDM|CHANNEL_TURBO;
-             }if(mode == AR5K_MODE_11B) {
+             if ((mode == AR5K_MODE_11A) ||
+                     (mode == AR5K_MODE_11G)) {
Quoted 8 lines

drivers/net/wireless/ath5k/base.c ath5k_copy_channels(struct ath5k_hw *ah, · line 911

Quoted 7 lines
drivers/net/wireless/ath5k/base.c +7 -0
+                     channels[count].hw_value =
+                             chfreq | CHANNEL_OFDM;
+             } else if ((mode == AR5K_MODE_11A_TURBO) ||
+                     (mode == AR5K_MODE_11G_TURBO)) {
+                     channels[count].hw_value =
+                             chfreq | CHANNEL_OFDM|CHANNEL_TURBO;
+             } if (mode == AR5K_MODE_11B) {

'else' or '\n' before the if, please

Good catch, that should have been an "else if" there. Will repost all pending patches in a series addressing all posted comments.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Going to move this to a switch, its much more legible.

There was switch IIRC, I think either sparse or -W don't like it too much (enum <-> int)? Please could you check? (-W doesn't bother us.)

Thanks for the heads up, will do.

Tested with sparse from git, no complaints.

Luis