[PATCH 06/16] ehca: common include files

Kyle Moffett mrmacman_g4 at mac.com
Fri Apr 28 15:11:11 EST 2006


On Apr 27, 2006, at 06:48:35, Heiko J Schick wrote:
> +#define EHCA_EDEB_TRACE_MASK_SIZE 32
> +extern u8 ehca_edeb_mask[EHCA_EDEB_TRACE_MASK_SIZE];
> +#define EDEB_ID_TO_U32(str4) (str4[3] | (str4[2] << 8) | (str4[1]  
> << 16) | \
> +			      (str4[0] << 24))
> +
> +inline static u64 ehca_edeb_filter(const u32 level,
> +				   const u32 id, const u32 line)
> +{
> +	u64 ret = 0;
> +	u32 filenr = 0;
> +	u32 filter_level = 9;
> +	u32 dynamic_level = 0;
> +
> +	/* This is code written for the gcc -O2 optimizer which should  
> colapse
> +	 * to two single ints filter_level is the first level kicked out by
> +	 * compiler means trace everythin below 6. */
> +	if (id == EDEB_ID_TO_U32("ehav")) {
> +		filenr = 0x01;
> +		filter_level = 8;
> +	}
> [...]

This whole mess should be a simpler with a table and a loop

struct edeb_filter_entry {
	u32 filenr;
	u32 filter_level;
};

# define EDEB_FILTER_ENTRY(name,nr,level) { .id = name, .filenr =  
nr, .filter_level = level }
static const struct edeb_filter_entry edeb_filter_table[] = {
	EDEB_FILTER_ENTRY("clas", 0x02, 8),
	[...]
};

Then just iterate over that table in a loop.  The end result is much  
smaller code and data, and much clearer as to intent as well.

Cheers,
Kyle Moffett




More information about the Linuxppc-dev mailing list