ts-7000
[Top] [All Lists]

Re: [ts-7000] Spi driver bug in linux-2.6.27.4-matt-3

To:
Subject: Re: [ts-7000] Spi driver bug in linux-2.6.27.4-matt-3
From: Matthieu Crapet <>
Date: Wed, 14 Jan 2009 13:59:30 +0100
Hi.

Fixed it in linux-2.6.27.4-matt-4
Regards,
Matthieu

greywolf9923 wrote:
>
> There's a bug in the spi_speed_set function:
>
> static int spi_speed_set(struct ep93xx_spi *drv_data, unsigned speed_hz)
> {
> ........
> for (cpsdvr = 2; cpsdvr <= 254; cpsdvr+=2) {
> scr = DIV_ROUND_UP(mainclk_hz / speed_hz, cpsdvr);
> /* now we have SCR+1 in scr, so count with that */
> if (scr == 0) { /* speed_hz too big */
> return -EINVAL;
> }
> if (scr <= (255 + 1))
> break; /* we have valid scr and cpsdvr */
> }
> if (cpsdvr > 254) { <------BUG HERE
> /* speed_hz is too small, set to minimum speed */
> scr = cpsdvr + 1;
> cpsdvr--;
> }
> scr--;
> ..........
> }
>
> If cpsdvr is greater than 254 will be 256 because of the for
> (cpsdvr+=2), so scr will be 257 and cpsdvr 255 out of if, then scr
> will finally be 256, but it's not possible because the range for scr
> is 0-255 and 2-254 for cpsdvr. I think it'd be better:
>
> if (cpsdvr == 256) {
> return -EINVAL;
> }
>
> or modify the if:
>
> if (cpsdvr == 256) {
> /* speed_hz is too small, set to minimum speed */
> scr = 256;
> cpsdvr = 254;
> }
> scr--;
>
>  


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
     
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU