All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] wiphy: fix wiphy_contrain_freq_set skipping last channel
@ 2023-09-19 16:59 James Prestwood
  2023-09-19 16:59 ` [PATCH 2/2] unit: include frequency 7115 in test-band James Prestwood
  2023-09-25 14:30 ` [PATCH 1/2] wiphy: fix wiphy_contrain_freq_set skipping last channel Denis Kenzior
  0 siblings, 2 replies; 3+ messages in thread
From: James Prestwood @ 2023-09-19 16:59 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

The loop iterating the frequency attributes list was not including
the entire channel set since it was stopping at i < band->freqs_len.
The freq_attrs array is allocated to include the last channel:

band->freq_attrs = l_new(struct band_freq_attrs, num_channels + 1);
band->freqs_len = num_channels;

So instead the for loop should use i <= band->freqs_len. (I also
changed this to start the loop at 1 since channel zero is invalid).
---
 src/wiphy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/wiphy.c b/src/wiphy.c
index 77ed2acf..ccff701e 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -843,7 +843,7 @@ bool wiphy_constrain_freq_set(const struct wiphy *wiphy,
 		if (!band)
 			continue;
 
-		for (i = 0; i < band->freqs_len; i++) {
+		for (i = 1; i <= band->freqs_len; i++) {
 			uint32_t freq;
 
 			if (!band->freq_attrs[i].supported)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] unit: include frequency 7115 in test-band
  2023-09-19 16:59 [PATCH 1/2] wiphy: fix wiphy_contrain_freq_set skipping last channel James Prestwood
@ 2023-09-19 16:59 ` James Prestwood
  2023-09-25 14:30 ` [PATCH 1/2] wiphy: fix wiphy_contrain_freq_set skipping last channel Denis Kenzior
  1 sibling, 0 replies; 3+ messages in thread
From: James Prestwood @ 2023-09-19 16:59 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

The test was not including the last frequency in the 6ghz spectrum.
---
 unit/test-band.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/unit/test-band.c b/unit/test-band.c
index caddbcdd..e27531f7 100644
--- a/unit/test-band.c
+++ b/unit/test-band.c
@@ -644,7 +644,7 @@ static void test_6ghz_freqs(const void *data)
 	uint32_t i;
 	enum band_freq band;
 
-	for (i = 5955; i < 7115; i += 20) {
+	for (i = 5955; i <= 7115; i += 20) {
 		assert(band_freq_to_channel(i, &band) != 0);
 		assert(band == BAND_FREQ_6_GHZ);
 	}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] wiphy: fix wiphy_contrain_freq_set skipping last channel
  2023-09-19 16:59 [PATCH 1/2] wiphy: fix wiphy_contrain_freq_set skipping last channel James Prestwood
  2023-09-19 16:59 ` [PATCH 2/2] unit: include frequency 7115 in test-band James Prestwood
@ 2023-09-25 14:30 ` Denis Kenzior
  1 sibling, 0 replies; 3+ messages in thread
From: Denis Kenzior @ 2023-09-25 14:30 UTC (permalink / raw)
  To: James Prestwood, iwd

Hi James,

On 9/19/23 11:59, James Prestwood wrote:
> The loop iterating the frequency attributes list was not including
> the entire channel set since it was stopping at i < band->freqs_len.
> The freq_attrs array is allocated to include the last channel:
> 
> band->freq_attrs = l_new(struct band_freq_attrs, num_channels + 1);
> band->freqs_len = num_channels;
> 
> So instead the for loop should use i <= band->freqs_len. (I also
> changed this to start the loop at 1 since channel zero is invalid).
> ---
>   src/wiphy.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Both applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-25 14:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-19 16:59 [PATCH 1/2] wiphy: fix wiphy_contrain_freq_set skipping last channel James Prestwood
2023-09-19 16:59 ` [PATCH 2/2] unit: include frequency 7115 in test-band James Prestwood
2023-09-25 14:30 ` [PATCH 1/2] wiphy: fix wiphy_contrain_freq_set skipping last channel Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.