On Tue, 19 Jun 2007 14:37:06 -0700 "Keshavamurthy, Anil S" <[EMAIL PROTECTED]> 
wrote:

> +/*
> + * Decoding Capability Register
> + */
> +#define cap_read_drain(c)    (((c) >> 55) & 1)
> +#define cap_write_drain(c)   (((c) >> 54) & 1)
> +#define cap_max_amask_val(c) (((c) >> 48) & 0x3f)
> +#define cap_num_fault_regs(c)        ((((c) >> 40) & 0xff) + 1)
> +#define cap_pgsel_inv(c)     (((c) >> 39) & 1)
> +
> +#define cap_super_page_val(c)        (((c) >> 34) & 0xf)
> +#define cap_super_offset(c)  (((find_first_bit(&cap_super_page_val(c), 4)) \
> +                                     * OFFSET_STRIDE) + 21)
> +
> +#define cap_fault_reg_offset(c)      ((((c) >> 24) & 0x3ff) * 16)
> +#define cap_max_fault_reg_offset(c) \
> +     (cap_fault_reg_offset(c) + cap_num_fault_regs(c) * 16)
> +
> +#define cap_zlr(c)           (((c) >> 22) & 1)
> +#define cap_isoch(c)         (((c) >> 23) & 1)
> +#define cap_mgaw(c)          ((((c) >> 16) & 0x3f) + 1)
> +#define cap_sagaw(c)         (((c) >> 8) & 0x1f)
> +#define cap_caching_mode(c)  (((c) >> 7) & 1)
> +#define cap_phmr(c)          (((c) >> 6) & 1)
> +#define cap_plmr(c)          (((c) >> 5) & 1)
> +#define cap_rwbf(c)          (((c) >> 4) & 1)
> +#define cap_afl(c)           (((c) >> 3) & 1)
> +#define cap_ndoms(c)         (((unsigned long)1) << (4 + 2 * ((c) & 0x7)))
> +/*
> + * Extended Capability Register
> + */
> +
> +#define ecap_niotlb_iunits(e)        ((((e) >> 24) & 0xff) + 1)
> +#define ecap_iotlb_offset(e)         ((((e) >> 8) & 0x3ff) * 16)
> +#define ecap_max_iotlb_offset(e) \
> +     (ecap_iotlb_offset(e) + ecap_niotlb_iunits(e) * 16)
> +#define ecap_coherent(e)     ((e) & 0x1)

None of these actually _need_ to be macros and it would be better to 
implement them in C.  That way things are more self-documenting, more
pleasant to read, more likely to get commented and you'll fix the
two bugs wherein the argument to a macro is evaluated more than once.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to