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

Emil Velikov emil.l.velikov at gmail.com
Tue Jul 23 11:49:28 UTC 2019


On 2019/07/22, Sam Ravnborg wrote:
> 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.
> 

Don't think I've seen any "mask_and" "mask_or" API in DRM. The common
theme seems to be:

mtk_cec_mask(driver_priv, offset, value, mask)
malidp_write32_mask(driver_priv, offset, mask, value)
nvif_mask(driver_priv, address, mask, value)

HTH
Emil


More information about the dri-devel mailing list