Re: unsigned long ioremap()?

From: David S. Miller (davem@redhat.com)
Date: Thu May 03 2001 - 02:08:03 EST


Geert Uytterhoeven writes:
> Since you're not allowed to use direct memory dereferencing on ioremapped
> areas, wouldn't it be more logical to let ioremap() return an unsigned long
> instead of a void *?
>
> Of course we then have to change readb() and friends to take a long as well,
> but at least we'd get compiler warnings when someone tries to do a direct
> dereference.

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);

I'm personally ambivalent and believe that both cases should be allowed.

BTW, current {read,write}{b,w,l}() allow both pointer and unsigned
long arguments. If your implementation isn't casting the port address
arg right now, perhaps you haven't tried to compile very many drivers
which use these interfaces or you're just ignoreing the warnings :-)

Later,
David S. Miller
davem@redhat.com
-
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