Re: unsigned long ioremap()?

Abramo Bagnara
2001-05-04T11:08:28Z

"David S. Miller" wrote:
>
> Abramo Bagnara writes:
> > it's perfectly fine to have:
> >
> > regs = (struct reg *) ioremap(addr, size);
> > foo = readl((unsigned long)&regs->bar);
> >
>
> I don't see how one can find this valid compared to my preference of
> just plain readl(&regs->bar); You're telling me it's nicer to have the
> butt ugly cast there which serves no purpose?

It's right API a bit misused (to allow your request to use fields by
name)

i.e. foo = readl((unsigned long)&regs->bar);

vs a wrong API that need a cast to be used correctly

i.e. rme9652->iobase = (unsigned long) ioremap(rme9652->port,
RME9652_IO_EXTENT);

Taken in account that the main point is to not have fake pointers here
and there, my choice would be obvious.

> One could argue btw that structure offsets are less error prone to
> code than register offset defines out the wazoo.

offset defines are never correct on some architecture while being
incorrect on some other, that's the whole point: a wrong #define is
likely squashed during the very first phase of driver development.

--
Abramo Bagnara mailto:abramo@alsa-project.org

Opera Unica Phone: +39.546.656023
Via Emilia Interna, 140
48014 Castel Bolognese (RA) - Italy

ALSA project http://www.alsa-project.org
It sounds good!