Re: unsigned long ioremap()?

From: Geert Uytterhoeven (geert@linux-m68k.org)
Date: Thu May 03 2001 - 03:26:15 EST


On Thu, 3 May 2001, Jeff Garzik wrote:
> Abramo Bagnara wrote:
> > "David S. Miller" wrote:
> > > There is a school of thought which believes that:
> > >
> > > struct xdev_regs {
> > > u32 reg1;
> > > u32 reg2;
> > > };
> > >
> > > val = readl(&regs->reg2);
> > >
> > > is cleaner than:
> > >
> > > #define REG1 0x00
> > > #define REG2 0x04
> > >
> > > val = readl(regs + REG2);
>
> > The problem I see is that with the former solution nothing prevents from
> > to do:
> >
> > regs->reg2 = 13;
>
> Why should there be something to prevent that?

Because people can't seem to be teached to not do it?

> If a programmer does that to an ioremapped area, that is a bug. Pure
> and simple.
>
> We do not need extra mechanisms simply to guard against programmers
> doing the wrong thing all the time.
>
> > That's indeed the reason to change ioremap prototype for 2.5.
>
> Say what??
>
> I have heard a good argument from rth about creating a pci_ioremap,
> which takes a struct pci_dev argument. But there is no reason to change
> the ioremap prototype.

If ioremap() would return unsigned long, the programmer at least has to cast it
before he can do the buggy thing. But indeed bad programmers probably don't
know that casts are evil (except when used very carefully).

Gr{oetje,eeting}s,

                                                Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds

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



This archive was generated by hypermail 2b29 : Mon May 07 2001 - 21:00:15 EST