Re: [PATCH] backlight: pwm_bl: Fix GPIO out for unimplemented .get_direction()

2017-03-23 Thread Peter Ujfalusi

On 03/22/2017 07:21 PM, Geert Uytterhoeven wrote:

Commit 7613c922315e308a ("backlight: pwm_bl: Move the checks for initial
power state to a separate function") not just moved some code, but made
slight changes in semantics.

If a gpiochip doesn't implement the optional .get_direction() callback,
gpiod_get_direction always returns -EINVAL, which is never equal to
GPIOF_DIR_IN, leading to the GPIO not being configured for output.


The platforms I have tested the gpio drivers do implement the get_direction() 
callback and I was not aware of this behaviour.



To avoid this, invert the test and check for not GPIOF_DIR_OUT instead,
like the original code did.

This restores the display on r8a7740/armadillo.

Fixes: 7613c922315e308a ("backlight: pwm_bl: Move the checks for initial power state 
to a separate function")
Signed-off-by: Geert Uytterhoeven <geert+rene...@glider.be>


Reviewed-by: Peter Ujfalusi <peter.ujfal...@ti.com>


---
 drivers/video/backlight/pwm_bl.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index d7efcb632f7d9dde..002f1ce22bd02032 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -297,14 +297,15 @@ static int pwm_backlight_probe(struct platform_device 
*pdev)
}

/*
-* If the GPIO is configured as input, change the direction to output
-* and set the GPIO as active.
+* If the GPIO is not known to be already configured as output, that
+* is, if gpiod_get_direction returns either GPIOF_DIR_IN or -EINVAL,
+* change the direction to output and set the GPIO as active.
 * Do not force the GPIO to active when it was already output as it
 * could cause backlight flickering or we would enable the backlight too
 * early. Leave the decision of the initial backlight state for later.
 */
if (pb->enable_gpio &&
-   gpiod_get_direction(pb->enable_gpio) == GPIOF_DIR_IN)
+   gpiod_get_direction(pb->enable_gpio) != GPIOF_DIR_OUT)
gpiod_direction_output(pb->enable_gpio, 1);

pb->power_supply = devm_regulator_get(>dev, "power");




--
Péter


Re: BUG since "ASoC: simple-card: Add pm callbacks to platform driver"

2016-05-17 Thread Peter Ujfalusi
On 05/17/16 14:02, Geert Uytterhoeven wrote:
> On Tue, May 17, 2016 at 12:55 PM, Geert Uytterhoeven
>  wrote:
>> With today's sound-asoc/for-next, I'm seeing on r8a7791/koelsch and
>> sh73a0/kzm9g:
>>
>> kernel BUG at drivers/base/regmap/regcache.c:347!
>> Internal error: Oops - BUG: 0 [#1] SMP ARM
>> Modules linked in:
>> CPU: 0 PID: 20 Comm: kworker/0:1 Not tainted
>> 4.6.0-koelsch-07135-g1481dd77fa7d01cb #2621
>> Hardware name: Generic R8A7791 (Flattened Device Tree)
>> Workqueue: events soc_resume_deferred
>> task: ef512100 ti: ef5a6000 task.ti: ef5a6000
>> PC is at regcache_sync+0xc/0x118
>> LR is at ak4642_resume+0x20/0x28
> 
> This is during resume from s2ram.

if you revert the patch does the ak4642_resume() is called at all, I think not.
But in the driver does not implement the .suspend callback, probably this
never worked correctly in ak4642?

-- 
Péter