If gpio controller requires waiting for read and write
GPIO values, then we have to use the gpio cansleep api.
Fix the rfkill_gpio_set_power which calls only the
nonsleep version (causing kernel warning).
There is no problem to use the cansleep version here
because we are not in IRQ handler or similar context
(cf rfkill_set_block).
Signed-off-by: Loic Poulain <[email protected]>
---
net/rfkill/rfkill-gpio.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
index bd2a5b9..db6579d 100644
--- a/net/rfkill/rfkill-gpio.c
+++ b/net/rfkill/rfkill-gpio.c
@@ -47,16 +47,24 @@ static int rfkill_gpio_set_power(void *data, bool blocked)
{
struct rfkill_gpio_data *rfkill = data;
+ if (!blocked) {
+ if (!IS_ERR(rfkill->clk) && !rfkill->clk_enabled)
+ clk_enable(rfkill->clk);
+ }
+
+ if (gpiod_cansleep(rfkill->shutdown_gpio))
+ gpiod_set_value_cansleep(rfkill->shutdown_gpio, !blocked);
+ else
+ gpiod_set_value(rfkill->shutdown_gpio, !blocked);
+
+ if (gpiod_cansleep(rfkill->reset_gpio))
+ gpiod_set_value_cansleep(rfkill->reset_gpio, !blocked);
+ else
+ gpiod_set_value(rfkill->reset_gpio, !blocked);
+
if (blocked) {
- gpiod_set_value(rfkill->shutdown_gpio, 0);
- gpiod_set_value(rfkill->reset_gpio, 0);
if (!IS_ERR(rfkill->clk) && rfkill->clk_enabled)
clk_disable(rfkill->clk);
- } else {
- if (!IS_ERR(rfkill->clk) && !rfkill->clk_enabled)
- clk_enable(rfkill->clk);
- gpiod_set_value(rfkill->reset_gpio, 1);
- gpiod_set_value(rfkill->shutdown_gpio, 1);
}
rfkill->clk_enabled = blocked;
--
1.8.3.2
On Tue, 2014-05-06 at 18:14 +0200, Loic Poulain wrote:
> + if (gpiod_cansleep(rfkill->shutdown_gpio))
> + gpiod_set_value_cansleep(rfkill->shutdown_gpio, !blocked);
> + else
> + gpiod_set_value(rfkill->shutdown_gpio, !blocked);
> +
> + if (gpiod_cansleep(rfkill->reset_gpio))
> + gpiod_set_value_cansleep(rfkill->reset_gpio, !blocked);
> + else
> + gpiod_set_value(rfkill->reset_gpio, !blocked);
Really? I mean, there's not even a fallback where the cansleep() API
calls the non-sleeping one if the cansleep isn't support? This is really
ugly.
johannes
On Wed, 2014-05-07 at 11:02 +0200, Johannes Berg wrote:
> On Tue, 2014-05-06 at 18:14 +0200, Loic Poulain wrote:
>
> > + if (gpiod_cansleep(rfkill->shutdown_gpio))
> > + gpiod_set_value_cansleep(rfkill->shutdown_gpio, !blocked);
> > + else
> > + gpiod_set_value(rfkill->shutdown_gpio, !blocked);
> > +
> > + if (gpiod_cansleep(rfkill->reset_gpio))
> > + gpiod_set_value_cansleep(rfkill->reset_gpio, !blocked);
> > + else
> > + gpiod_set_value(rfkill->reset_gpio, !blocked);
>
> Really? I mean, there's not even a fallback where the cansleep() API
> calls the non-sleeping one if the cansleep isn't support? This is really
> ugly.
Actually, it looks like unconditionally using the cansleep API should be
fine since it just calls the same internal helper function. Please
respin.
johannes