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/
|