diff mbox

ath9k: fix ath9k_hw_gpio_get() to return 0 or 1 on success

Message ID 44116a7bca8524a187083916bdea535145e7a23a.1479232041.git.mschiffer@universe-factory.net (mailing list archive)
State Accepted
Commit 91851cc7a939039bd401adb6ca3da4402bec1d0c
Delegated to: Kalle Valo
Headers show

Commit Message

Matthias Schiffer Nov. 15, 2016, 5:47 p.m. UTC
Commit b2d70d4944c1 ("ath9k: make GPIO API to support both of WMAC and
SOC") refactored ath9k_hw_gpio_get() to support both WMAC and SOC GPIOs,
changing the return on success from 1 to BIT(gpio). This broke some callers
like ath_is_rfkill_set().

Instead of fixing all callers, change ath9k_hw_gpio_get() back to only
return 0 or 1.

Fixes: b2d70d4944c1 ("ath9k: make GPIO API to support both of WMAC and SOC")
Cc: <stable@vger.kernel.org> # v4.7+
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
---
 drivers/net/wireless/ath/ath9k/hw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kalle Valo Nov. 16, 2016, 2:08 p.m. UTC | #1
Matthias Schiffer <mschiffer@universe-factory.net> writes:

> Commit b2d70d4944c1 ("ath9k: make GPIO API to support both of WMAC and
> SOC") refactored ath9k_hw_gpio_get() to support both WMAC and SOC GPIOs,
> changing the return on success from 1 to BIT(gpio). This broke some callers
> like ath_is_rfkill_set().
>
> Instead of fixing all callers, change ath9k_hw_gpio_get() back to only
> return 0 or 1.
>
> Fixes: b2d70d4944c1 ("ath9k: make GPIO API to support both of WMAC and SOC")
> Cc: <stable@vger.kernel.org> # v4.7+
> Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>

Can you describe more about the symptoms, how did this break from user's
point of view? I can add that to the commit log.
Matthias Schiffer Nov. 16, 2016, 2:40 p.m. UTC | #2
On 11/16/2016 03:08 PM, Kalle Valo wrote:
> Matthias Schiffer <mschiffer@universe-factory.net> writes:
> 
>> Commit b2d70d4944c1 ("ath9k: make GPIO API to support both of WMAC and
>> SOC") refactored ath9k_hw_gpio_get() to support both WMAC and SOC GPIOs,
>> changing the return on success from 1 to BIT(gpio). This broke some callers
>> like ath_is_rfkill_set().
>>
>> Instead of fixing all callers, change ath9k_hw_gpio_get() back to only
>> return 0 or 1.
>>
>> Fixes: b2d70d4944c1 ("ath9k: make GPIO API to support both of WMAC and SOC")
>> Cc: <stable@vger.kernel.org> # v4.7+
>> Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
> 
> Can you describe more about the symptoms, how did this break from user's
> point of view? I can add that to the commit log.
> 

I did actually not experience an issue myself with a mainline kernel.

Looking at the functions ath_is_rfkill_set() and ath9k_rfkill_poll_state()
in gpio.c, this issue causes wiphy_rfkill_set_hw_state() always to be
passed false when ah->rfkill_polarity==1, breaking rfkill. I don't know how
common devices with ah->rfkill_polarity==1 are.

I became aware of this issue when rebasing an out-of-tree patch in LEDE
which uses the WMAC GPIOs to configure some kind of bandpass filter found
in Ubiquiti hardware. (I hope to find time to get this patch upsteam at
some point...)

Matthias
Kalle Valo Nov. 16, 2016, 3:59 p.m. UTC | #3
Matthias Schiffer <mschiffer@universe-factory.net> writes:

> On 11/16/2016 03:08 PM, Kalle Valo wrote:
>> Matthias Schiffer <mschiffer@universe-factory.net> writes:
>> 
>>> Commit b2d70d4944c1 ("ath9k: make GPIO API to support both of WMAC and
>>> SOC") refactored ath9k_hw_gpio_get() to support both WMAC and SOC GPIOs,
>>> changing the return on success from 1 to BIT(gpio). This broke some callers
>>> like ath_is_rfkill_set().
>>>
>>> Instead of fixing all callers, change ath9k_hw_gpio_get() back to only
>>> return 0 or 1.
>>>
>>> Fixes: b2d70d4944c1 ("ath9k: make GPIO API to support both of WMAC and SOC")
>>> Cc: <stable@vger.kernel.org> # v4.7+
>>> Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
>> 
>> Can you describe more about the symptoms, how did this break from user's
>> point of view? I can add that to the commit log.
>> 
>
> I did actually not experience an issue myself with a mainline kernel.
>
> Looking at the functions ath_is_rfkill_set() and ath9k_rfkill_poll_state()
> in gpio.c, this issue causes wiphy_rfkill_set_hw_state() always to be
> passed false when ah->rfkill_polarity==1, breaking rfkill. I don't know how
> common devices with ah->rfkill_polarity==1 are.
>
> I became aware of this issue when rebasing an out-of-tree patch in LEDE
> which uses the WMAC GPIOs to configure some kind of bandpass filter found
> in Ubiquiti hardware. (I hope to find time to get this patch upsteam at
> some point...)

Thanks, this kind of information is good to have in the commit log. That
way maintainers, like me or stable tree folks, can prioritise the fix to
various releases. And I guess Linux distros also like to know this as
well as some of the normal users when trying to solve problems.

I'll mention in the commit log that this doesn't fix any known bug. And
I'll push this to 4.10, I don't think this is important enough for 4.9.
Kalle Valo Nov. 23, 2016, 1:58 p.m. UTC | #4
Matthias Schiffer <mschiffer@universe-factory.net> wrote:
> Commit b2d70d4944c1 ("ath9k: make GPIO API to support both of WMAC and
> SOC") refactored ath9k_hw_gpio_get() to support both WMAC and SOC GPIOs,
> changing the return on success from 1 to BIT(gpio). This broke some callers
> like ath_is_rfkill_set().
> 
> Instead of fixing all callers, change ath9k_hw_gpio_get() back to only
> return 0 or 1.
> 
> Fixes: b2d70d4944c1 ("ath9k: make GPIO API to support both of WMAC and SOC")
> Cc: <stable@vger.kernel.org> # v4.7+
> Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>

Patch applied to ath-next branch of ath.git, thanks.

91851cc7a939 ath9k: fix ath9k_hw_gpio_get() to return 0 or 1 on success
diff mbox

Patch

diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 14b13f0..a35f78b 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -2792,7 +2792,7 @@  u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio)
 		WARN_ON(1);
 	}
 
-	return val;
+	return !!val;
 }
 EXPORT_SYMBOL(ath9k_hw_gpio_get);