diff mbox series

[1/3] wiphy: make wiphy_band_is_disabled return more descriptive

Message ID 20230929161959.3840935-1-prestwoj@gmail.com (mailing list archive)
State New
Headers show
Series [1/3] wiphy: make wiphy_band_is_disabled return more descriptive | expand

Checks

Context Check Description
tedd_an/pre-ci_am fail error: patch failed: src/station.c:1450 error: src/station.c: patch does not apply error: patch failed: src/wiphy.c:570 error: src/wiphy.c: patch does not apply error: patch failed: src/wiphy.h:111 error: src/wiphy.h: patch does not apply hint: Use 'git am --show-current-patch' to see the failed patch

Commit Message

James Prestwood Sept. 29, 2023, 4:19 p.m. UTC
The function wiphy_band_is_disabled() return was a bit misleading
because if the band was not supported it would return true which
could be misunderstood as the band is supported, but disabled.
There was only one call site and because of this behavior
wiphy_band_is_disabled needed to be paired with checking if the
band was supported.

To be more descriptive to the called, wiphy_band_is_disabled() now
returns an int and if the band isn't supported -ENOTSUP will be
returned, otherwise true/false.
---
 src/station.c | 4 +---
 src/wiphy.c   | 4 ++--
 src/wiphy.h   | 2 +-
 3 files changed, 4 insertions(+), 6 deletions(-)

Comments

Denis Kenzior Sept. 30, 2023, 2:59 a.m. UTC | #1
Hi James,

On 9/29/23 11:19, James Prestwood wrote:
> The function wiphy_band_is_disabled() return was a bit misleading
> because if the band was not supported it would return true which
> could be misunderstood as the band is supported, but disabled.
> There was only one call site and because of this behavior
> wiphy_band_is_disabled needed to be paired with checking if the
> band was supported.
> 
> To be more descriptive to the called, wiphy_band_is_disabled() now
> returns an int and if the band isn't supported -ENOTSUP will be
> returned, otherwise true/false.

Returning true/false and -errno isn't a pattern we use.  I changed this patch to 
return -errno on error, 1 if disabled, and 0 otherwise.  Also fixed up patch 2 
as a result.  Please double check that I didn't screw anything up.

> ---
>   src/station.c | 4 +---
>   src/wiphy.c   | 4 ++--
>   src/wiphy.h   | 2 +-
>   3 files changed, 4 insertions(+), 6 deletions(-)
> 


All applied, thanks.

Regards,
-Denis
diff mbox series

Patch

diff --git a/src/station.c b/src/station.c
index 12823142..7d182e9b 100644
--- a/src/station.c
+++ b/src/station.c
@@ -1450,9 +1450,7 @@  static int station_quick_scan_trigger(struct station *station)
 	 * this since its so limited, so return an error which will fall back to
 	 * full autoconnect.
 	 */
-	if (wiphy_get_supported_bands(station->wiphy) & BAND_FREQ_6_GHZ &&
-			wiphy_band_is_disabled(station->wiphy,
-						BAND_FREQ_6_GHZ) &&
+	if (wiphy_band_is_disabled(station->wiphy, BAND_FREQ_6_GHZ) == true &&
 			wiphy_country_is_unknown(station->wiphy) &&
 			known_6ghz)
 		return -ENOTSUP;
diff --git a/src/wiphy.c b/src/wiphy.c
index dcd9e210..fd22f013 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -570,7 +570,7 @@  const struct band_freq_attrs *wiphy_get_frequency_info_list(
 	return bandp->freq_attrs;
 }
 
-bool wiphy_band_is_disabled(const struct wiphy *wiphy, enum band_freq band)
+int wiphy_band_is_disabled(const struct wiphy *wiphy, enum band_freq band)
 {
 	struct band_freq_attrs attr;
 	unsigned int i;
@@ -578,7 +578,7 @@  bool wiphy_band_is_disabled(const struct wiphy *wiphy, enum band_freq band)
 
 	bandp = wiphy_get_band(wiphy, band);
 	if (!bandp)
-		return true;
+		return -ENOTSUP;
 
 	for (i = 0; i < bandp->freqs_len; i++) {
 		attr = bandp->freq_attrs[i];
diff --git a/src/wiphy.h b/src/wiphy.h
index cabb21c4..d61516d5 100644
--- a/src/wiphy.h
+++ b/src/wiphy.h
@@ -111,7 +111,7 @@  const struct band_freq_attrs *wiphy_get_frequency_info_list(
 						enum band_freq band,
 						size_t *size);
 
-bool wiphy_band_is_disabled(const struct wiphy *wiphy, enum band_freq band);
+int wiphy_band_is_disabled(const struct wiphy *wiphy, enum band_freq band);
 
 bool wiphy_supports_probe_resp_offload(struct wiphy *wiphy);
 bool wiphy_can_transition_disable(struct wiphy *wiphy);