[openchrome-devel] [PATCH v2 1/4] drm/via: drop use of DRM(READ|WRITE) macros

Sam Ravnborg sam at ravnborg.org
Mon Jul 22 18:27:31 UTC 2019


Hi Email.

> > > IMHO a far better idea is to expand these macros as static inline functions.
> > > The extra bonus here is that the pseudo-magical VIA_BASE will also disappear.
> > >
> > > Since all the VIA_READ8 are used for masking, one might as well drop
> > > them in favour of via_mask().

Like this:
static inline u32 via_read(struct drm_via_private *dev_priv, u32 reg)
{
        return readl((void __iomem *)(dev_priv->mmio->handle + reg));
}

static inline void via_write(struct drm_via_private *dev_priv, u32 reg,
                             u32 val)
{
        writel(val, (void __iomem *)(dev_priv->mmio->handle + reg));
}

static inline void via_write8(struct drm_via_private *dev_priv, u32 reg,
                              u32 val)
{
        writeb(val, (void __iomem *)(dev_priv->mmio->handle + reg));
}

static inline void via_write8_mask_or(struct drm_via_private *dev_priv,
                                      u32 reg, u32 mask)
{
        u32 val;

        val = readb((void __iomem *)(dev_priv->mmio->handle + reg));
        writeb(val | mask, (void __iomem *)(dev_priv->mmio->handle + reg));
}

static inline void via_write8_mask_and(struct drm_via_private *dev_priv,
                                       u32 reg, u32 mask)
{
        u32 val;

        val = readb((void __iomem *)(dev_priv->mmio->handle + reg));
        writeb(val & mask, (void __iomem *)(dev_priv->mmio->handle + reg));
}

Patches are almost ready, but if there is any quick feedback let me
know.

	Sam


More information about the openchrome-devel mailing list