memory: atmel-ebi: Fix smc timing return value evaluation
authorAlexander Dahl <ada@thorsis.com>
Tue, 25 Jul 2017 12:00:22 +0000 (14:00 +0200)
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>
Wed, 26 Jul 2017 20:37:30 +0000 (22:37 +0200)
commitbc9b934b2fbbd51008a1b52c0cd1b457e6440736
treefb7356b0a71c459ebd80dd98f9ba5b8d12a4e8f4
parent5771a8c08880cdca3bfb4a3fc6d309d6bba20877
memory: atmel-ebi: Fix smc timing return value evaluation

Setting optional EBI/SMC properties through device tree always fails due
to wrong evaluation of the return value of
atmel_ebi_xslate_smc_timings().

If you put some of those properties in your dts file, but not
'atmel,smc-tdf-ns' the local variable 'required' in
atmel_ebi_xslate_smc_timings() stays on 'false' after the first 'if'
block. This leads to setting 'ret' to -EINVAL in the first run of the
following 'for' loop which is then the return value of this function.

However if you set 'atmel,smc-tdf-ns' in the dts file and everything in
atmel_ebi_xslate_smc_timings() works well, it returns the content of
'required' which is 'true' then.

So the function atmel_ebi_xslate_smc_timings() always returns non-zero
which lets its call in atmel_ebi_xslate_smc_config() always fail and
thus returning -EINVAL, so the EBI configuration for this node fails.

Judging from the following code evaluating the local 'required' variable
in atmel_ebi_xslate_smc_config() and the call of caps->xlate_config in
atmel_ebi_dev_setup() it's probably right to only let the call fail if a
negative error code is returned.

Signed-off-by: Alexander Dahl <ada@thorsis.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
drivers/memory/atmel-ebi.c