Re: ioremap return type

Philipp Rumpf (prumpf@parcelfarce.linux.theplanet.co.uk)
Fri, 11 Aug 2000 03:57:32 +0100


On Thu, Aug 10, 2000 at 02:14:13PM +0200, Jamie Lokier wrote:
> Many drivers use a struct to define the offsets in their I/O or iomem
> space. E.g. acenic.c: readl(&regs->CpuCtrl). We know that's not
> portable in the sense that struct layout is not guaranteed. However,
> provided all the fields are suitably padded & aligned, it works in
> practice. (So far..)

Not only does it work in practice, it's used by most drivers and file systems
when they describe on-disk or dma structures. Currently the rules are:

- naturally align everything
- all struct sizes might be aligned to a multiple of four bytes

By now, I believe it is more likely that gcc would be fixed for a new
architecture that violates this assumption, so it's not worth it to go
around and "fix" those drivers.

As for using two arguments to readl, that would break the &regs->RegName
trick, unless people are happy with a global #define Regs ((struct foo *)0)
and read32(regs, &Regs->RegName); maybe it's best to just stop doing that
though.

Philipp Rumpf

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/