Skip to contentSkip to conversation

memory: atmel-ebi: Simplify SMC config code

PATCH New ian.eperson at dedf.co.uk 2 participants 5 messages Aug 30, 2017 – Sep 1, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/7 memory: atmel-ebi: Simplify SMC config code

This patch appears to result in the following code at the end of atmel_ebi_xslate_smc_config() ? lines 265++:

	ret = atmel_ebi_xslate_smc_timings(ebid, np, &conf->smcconf);
	if (ret)
		return -EINVAL;

	if ((ret > 0 && !required) || (!ret && required)) {
		dev_err(ebid->ebi->dev, "missing atmel,smc- properties in %s",
			np->full_name);
		return -EINVAL;
	}

	return required;

My understanding is that atmel_ebi_xslate_smc_timings() returns true (>0), false (0) or error (<0) so the first test here should be:

	if(ret<0)

Otherwise the logic in the second test can be reduced to:

if(required)

and some further changes to atmel_ebi_xslate_smc_timings() are needed

Regards

Ian Eperson
DeDf Co Ltd

#1 lore raw

PATCH v2 2/7 memory: atmel-ebi: Simplify SMC config code

Hello Ian,

Am Mittwoch, 30. August 2017, 13:53:57 schrieb ian.eperson at dedf.co.uk:

Quoted 4 lines

My understanding is that atmel_ebi_xslate_smc_timings() returns true (>0), false (0) or error (<0) so the first test here should be:

	if(ret<0)

I came to the same conclusions in July and sent a patch which was already applied with commit bc9b934b2fbbd51008a1b52c0cd1b457e6440736 on master.

Greets
Alex

#2 lore raw

PATCH v2 2/7 memory: atmel-ebi: Simplify SMC config code

Alex

Apologies, I obviously wasn?t looking close enough to the leading edge.

I notice your patch also picks up on the Copy/Paste typo on line 75 of atmel-ebi.c which I'd just spotted:

	atmel_smc_cs_conf_set_setup -> atmel_smc_cs_conf_set_cycle

I'll go back to getting my head round the smc, ebi, ahb hierarchy in the device tree.

Regards

Ian Eperson
DeDf Co Ltd

#3 lore raw

PATCH v2 2/7 memory: atmel-ebi: Simplify SMC config code

Hei hei,

Am Donnerstag, 31. August 2017, 10:39:49 schrieb ian.eperson at dedf.co.uk:

Quoted 5 lines

Apologies, I obviously wasn?t looking close enough to the leading edge.

I notice your patch also picks up on the Copy/Paste typo on line 75 of atmel-ebi.c which I'd just spotted:

I just wanted to let you know, so you don't have to do the same work again. I'm happy someone else is also having a look on this code. :-)

Alex

#4 lore raw

PATCH v2 2/7 memory: atmel-ebi: Simplify SMC config code

In reply to ian.eperson at dedf.co.uk

Alex

Looking at atmel-ebi.c in a bit more detail, my statement that atmel_ebi_xslate_smc_timings() returns true (>0), false (0) or error (<0) seems to be have been the intention but the code won?t, as it stands, ever return false.

This is the ?no smc-tdf-ns setting in the device tree so no other timings must be present? case. What I think will happen is:

The of_property_read_u32() for "atmel,smc-tdf-ns" will return ?EINVAL and required will stay false.

In the for loop each the of_property_read_u32() will return ?EINVAL and the loop will continue for each entry in the xlate table. Leaving ret = -EINVAL when the loop terminates.

The if (ret) test immediately after the out: will fail producing the error message and returning ret (?EINVAL) rather than required (false).

If you could confirm my logic I can construct a patch to rectify the problem.

Regards

Ian Eperson
DeDf Co Ltd