Re: [PATCH] spi: pl022: Fix calculate_effective_freq()
On Thu, 26 Apr 2012 10:29:19 +0200, Linus Walleij wrote: > On Thu, Apr 19, 2012 at 11:14 AM, Viresh Kumar wrote: > > > calculate_effective_freq() was still not optimized and there were cases > > when it > > returned without error and with values of cpsr and scr as zero. > > > > Also, the variable named found is not used well. > > > > This patch targets to optimize and correct this routine. Tested for SPEAr. > > > > Signed-off-by: Viresh Kumar > > Tested-by: Vinit Kamalaksha Shenoy > > Looks good to me. > Acked-by: Linus Walleij > > Yours, > Linus Walleij Applied, thanks. g. -- Grant Likely, B.Sc, P.Eng. Secret Lab Technologies, Ltd. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ spi-devel-general mailing list spi-devel-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spi-devel-general
Re: [PATCH] spi: pl022: Fix calculate_effective_freq()
On Thu, Apr 19, 2012 at 11:14 AM, Viresh Kumar wrote: > calculate_effective_freq() was still not optimized and there were cases when > it > returned without error and with values of cpsr and scr as zero. > > Also, the variable named found is not used well. > > This patch targets to optimize and correct this routine. Tested for SPEAr. > > Signed-off-by: Viresh Kumar > Tested-by: Vinit Kamalaksha Shenoy Looks good to me. Acked-by: Linus Walleij Yours, Linus Walleij -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ spi-devel-general mailing list spi-devel-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spi-devel-general
Re: [PATCH] spi: pl022: Fix calculate_effective_freq()
On 4/19/2012 2:44 PM, Viresh KUMAR wrote: > calculate_effective_freq() was still not optimized and there were cases when > it > returned without error and with values of cpsr and scr as zero. > > Also, the variable named found is not used well. > > This patch targets to optimize and correct this routine. Tested for SPEAr. > > Signed-off-by: Viresh Kumar > Tested-by: Vinit Kamalaksha Shenoy You forgot to review this :) -- viresh -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ spi-devel-general mailing list spi-devel-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spi-devel-general
[PATCH] spi: pl022: Fix calculate_effective_freq()
calculate_effective_freq() was still not optimized and there were cases when it returned without error and with values of cpsr and scr as zero. Also, the variable named found is not used well. This patch targets to optimize and correct this routine. Tested for SPEAr. Signed-off-by: Viresh Kumar Tested-by: Vinit Kamalaksha Shenoy --- drivers/spi/spi-pl022.c | 23 +-- 1 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index 99d5f6d..490be03 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -1687,26 +1687,37 @@ static int calculate_effective_freq(struct pl022 *pl022, int freq, struct while (scr <= SCR_MAX) { tmp = spi_rate(rate, cpsdvsr, scr); - if (tmp > freq) + if (tmp > freq) { + /* we need lower freq */ scr++; + continue; + } + /* -* If found exact value, update and break. -* If found more closer value, update and continue. +* If found exact value, mark found and break. +* If found more closer value, update and break. */ - else if ((tmp == freq) || (tmp > best_freq)) { + if (tmp > best_freq) { best_freq = tmp; best_cpsdvsr = cpsdvsr; best_scr = scr; if (tmp == freq) - break; + found = 1; } - scr++; + /* +* increased scr will give lower rates, which are not +* required +*/ + break; } cpsdvsr += 2; scr = SCR_MIN; } + WARN(!best_freq, "pl022: Matching cpsdvsr and scr not found for %d Hz rate \n", + freq); + clk_freq->cpsdvsr = (u8) (best_cpsdvsr & 0xFF); clk_freq->scr = (u8) (best_scr & 0xFF); dev_dbg(&pl022->adev->dev, -- 1.7.9 -- For Developers, A Lot Can Happen In A Second. Boundary is the first to Know...and Tell You. Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! http://p.sf.net/sfu/Boundary-d2dvs2 ___ spi-devel-general mailing list spi-devel-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spi-devel-general