Re: [PATCH 05/27] asm-generic: add generic io.h

Arnd Bergmann
2009-05-04T10:48:56Z

io.h is more or less a straight copy from the mn10300 code,
so maybe David Howells is interested in this as well.

On Monday 04 May 2009, Geert Uytterhoeven wrote:
> On Thu, Nov 6, 2008 at 15:38, Arnd Bergmann <arnd@arndb.de> wrote:
> > +static inline void outsw(unsigned long addr, const void *buffer, int count)
> > +{
> > +       if (count) {
> > +               const u16 *buf = buffer;
> > +               do {
> > +                       outw(*buf++, addr);
> > +               } while (--count);
> > +       }
> > +}
> > +
> > +static inline void outsl(unsigned long addr, const void *buffer, int count)
> > +{
> > +       if (count) {
> > +               const u32 *buf = buffer;
> > +               do {
> > +                       outl(*buf++, addr);
> > +               } while (--count);
> > +       }
> > +}
>
> Do we ever call these with count == 0?

I don't think it can, but code is still more correct if it can handle it.
It could of course be written as

const u32 *buf;
for (buf = buffer; count; count--)
outl(*buf++, addr);

> > +/*
> > + * Change "struct page" to physical address.
> > + */
>
> Which `struct page'?

I can change the comment to what avr32 and m32r have:

arch/avr32/include/asm/io.h-/*
arch/avr32/include/asm/io.h: * ioremap - map bus memory into CPU space
arch/avr32/include/asm/io.h- * @offset bus address of the memory
arch/avr32/include/asm/io.h- * @size size of the resource to map
arch/avr32/include/asm/io.h- *
arch/avr32/include/asm/io.h: * ioremap performs a platform specific sequence of operations to make
arch/avr32/include/asm/io.h- * bus memory CPU accessible via the readb/.../writel functions and
arch/avr32/include/asm/io.h- * the other mmio helpers. The returned address is not guaranteed to
arch/avr32/include/asm/io.h- * be usable directly as a virtual address.
arch/avr32/include/asm/io.h- */