On Monday 15 December 2008, Felipe Balbi wrote:
> From: Felipe Balbi <[email protected]>
> 
> It's easier to follow and to maintain.
> 
> ...
> +static void davinci_mmc_read_fifo(struct mmc_davinci_host *host,
> +             u16 len, u8 *dest)
> +{
> +     void __iomem *fifo = host->base + DAVINCI_MMCDRR;
> +     u16 index = 0;
> +
> +     dev_dbg(mmc_dev(host->mmc), "RX fifo %p count %d buf %p\n",
> +                     fifo, len, dest);
> +
> +     if (likely((0x03 & (unsigned long) dest) == 0)) {
> +             if (len >= 4) {
> +                     readsl(fifo, dest, len >> 2);

Actually I think the new way to spell readsl() is ioread32_rep().
More portable, more clear.


> +                     index = len & ~0x03;
> +             }
> +             if (len & 0x02) {
> +                     *(u16 *)&dest[index] = __raw_readw(fifo);

... ioread16() ...

> +                     index += 2;
> +             }

Isnt there a "if (len & 1)" branch missing here?

> +     } else if ((0x01 & (unsigned long) dest) == 0) {
> +             if (len >= 2) {
> +                     readsw(fifo, dest, len >> 1);
> +                     index = len & ~0x01;
> +             }
> +             if (len & 0x01)
> +                     dest[index] = __raw_readb(fifo);

... ioread8() ...

> +     } else {
> +             readsb(fifo, dest, len);

... ioread8_rep()

> +     }
> +}
> +
> +static void davinci_mmc_write_fifo(struct mmc_davinci_host *host,
> +             u16 len, const u8 *src)
> +{
> +     void __iomem *fifo = host->base + DAVINCI_MMCDXR;
> +     u16 index = 0;
> +
> +     dev_dbg(mmc_dev(host->mmc), "TX fifo %p count %d buf %p\n",
> +                     fifo, len, src);
> +
> +     if (likely((0x03 & (unsigned long) src) == 0)) {
> +             if (len >= 4) {
> +                     writesl(fifo, src + index, len >> 2);

... iowrite32_rep() ... etc

> +                     index = len & ~0x03;
> +             }
> +             if (len & 0x02) {
> +                     __raw_writew(*(u16 *)&src[index], fifo);
> +                     index += 2;
> +             }

Missing "if (len & 1)" here too.


> +     } else if ((0x01 & (unsigned long) src) == 0) {
> +             if (len >= 2) {
> +                     writesw(fifo, src + index, len >> 1);
> +                     index = len & ~0x01;
> +             }
> +             if (len & 0x01)
> +                     __raw_writeb(src[index], fifo);
> +     } else {
> +             writesb(fifo, src, len);
> +     }
> +}
>  
>  /* PIO only */
>  static void mmc_davinci_sg_to_buf(struct mmc_davinci_host *host)


_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to