[PATCH v1 1/4] drm/mga: drop dependency on drm_os_linux.h

Sam Ravnborg sam at ravnborg.org
Tue Jun 11 10:44:35 UTC 2019


Hi Thomas.

> > +#define MGA_READ8(reg) \
> > +	readb(((void __iomem *)dev_priv->mmio->handle) + (reg))
> > +#define MGA_READ(reg) \
> > +	readl(((void __iomem *)dev_priv->mmio->handle) + (reg))
> > +#define MGA_WRITE8(reg, val) \
> > +	writeb(val, ((void __iomem *)dev_priv->mmio->handle) + (reg))
> > +#define MGA_WRITE(reg, val) \
> > +	writel(val, ((void __iomem *)dev_priv->mmio->handle) + (reg))
> 
> Addition is not defined or implementation specific for type void* IIRC.
> Compilers tend to treat it like u8*. Maybe cast mmio->handle to (u8
> __iomem *) instead?
I briefly looked at changing the type of mmio->handle

Today:

	void *handle;            /**< User-space: "Handle" to pass to mmap() */

Proposal:
	void __iomem *handle;            /**< User-space: "Handle" to pass to mmap() */

This would allow me to drop the cast in the code above, that is only
added to make sparse happy.
But the above triggered other sparse warnings and I ended up dropping
this.

As for (void *) versus (u8 *), then (void *) is what we do today.
[What Daniel also says in another mail].

Should we change the type I would prepfer a follow-up patch to do it.

If you could test it I can type the patch, or you could do so when
working with the driver.

	Sam


More information about the dri-devel mailing list