Re: [RFC/patch] macro_removal_agp_mtrr.diff

From: Arjan van de Ven
Date: Sat Sep 04 2004 - 05:17:29 EST


On Sat, 2004-09-04 at 12:02, Dave Airlie wrote:
> This patch is the first in the drmfntbl-0-0-2-branch of macro removals
>
> This dumps __REALLY_HAVE_AGP and __REALLY_HAVE_MTRR and replaces them with
> a bitmask of driver features that is checked...
>
> I've had to introduce __OS_HAS_AGP and __OS_HAS_MTRR, on Linux these map
> simply to (CONFIG_AGP || CONFIG_AGP_MODULE) and CONFIG_MTRR, however I
> can't remove them completely as we need to build on architectures that
> don't have the AGP or MTRR interfces... but they are much cleaner than the
> old code...


it looks you can nuke most of those.
> -#if __REALLY_HAVE_AGP
> +#if __OS_HAS_AGP
> drm_agp_head_t *agp; /**< AGP data */
> #endif

for example does this extra pointer really hurt in the *really* unlikely
case you don't have AGP ?

> +static __inline__ int drm_core_check_feature(struct drm_device *dev, int feature)
> +{
> + return ((dev->driver_features & feature) ? 1 : 0);
> +}

if you make a drm_core_has_AGP and drm_core_has_MTRR wrapper around
these then...


> +#if __OS_HAS_MTRR
> + if (drm_core_check_feature(dev, DRIVER_USE_MTRR)) {
> + if ( map->type == _DRM_FRAME_BUFFER ||
> + (map->flags & _DRM_WRITE_COMBINING) ) {
> + map->mtrr = mtrr_add( map->offset, map->size,
> + MTRR_TYPE_WRCOMB, 1 );
> + }
> }

...this would NOT need an ifdef because drm_core_has_MTRR would be a
define to 0 for non-OS_HAS_MTRR machines at which point the compiler
removes the entire code. Eg no ifdef needed and the code gets more
readable.



Attachment: signature.asc
Description: This is a digitally signed message part