Radeon driver Macro

Egbert Eich eich at pdx.freedesktop.org
Fri May 20 06:33:41 PDT 2005


I just happen to notice that the Macros OUTREGP()
and OUTPLLP() in the RADEON driver are slightly
unsymetric:

#define OUTREGP(addr, val, mask)                                        \
do {                                                                    \
    CARD32 tmp = INREG(addr);                                           \
    tmp &= (mask);                                                      \
    tmp |= (val);                                                       \
    OUTREG(addr, tmp);                                                  \
} while (0)

This would require that val has been & with ~mask.
If this isn't the case a set bit would set a previously
unset bit but a 0 bit would not 0 a previously set
bit.
The correct form should be:
#define OUTREGP(addr, val, mask)                                        \
do {                                                                    \
    CARD32 tmp = INREG(addr);                                           \
    tmp &= (mask);                                                      \
    tmp |= (val & ~(mask));                                             \
    OUTREG(addr, tmp);                                                  \
} while (0)

I'm not really deeply into the Radeon driver therefore I cannot 
estimate the side effects, but if nobody screams I could commit 
this change.

Egbert.



More information about the xorg mailing list