Re: [PATCH 1/1] edac x38: new MC driver module

From: H. Peter Anvin
Date: Sun Nov 23 2008 - 18:56:20 EST


Hitoshi Mitake wrote:
> --- a/arch/x86/include/asm/io.h
> +++ b/arch/x86/include/asm/io.h
> @@ -57,6 +57,14 @@ build_mmio_write(__writeq, "q", unsigned long, "r", )
> /* Let people know we have them */
> #define readq readq
> #define writeq writeq
> +
> +#else /* CONFIG_X86_32 */
> +
> +static inline unsigned long readq(const volatile void __iomem *addr)
> +{
> + return readl(addr) | (((u64)readl(addr + 4)) << 32);
> +}
> +
> #endif
>

Let's see:

* undefined ordering of operations (at least on x86, they really should
be performed in LSB first order.)

* Using "unsigned long" for a 64-bit number on a 32-bit architecture.

* Arithmetic on a void pointer.


Try something like:

static inline u64 readq(const volative void __iomem *addr)
{
volatile u32 __iomem *__p = addr;
u32 __l, __h;

__l = readl(p);
__h = readl(p+1);

return __l + ((u64)__h << 32);
}

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