Re: [PATCH 2/2] x86: add macro for_each_setup_data()

From: Thomas Gleixner
Date: Fri Jan 23 2015 - 09:25:28 EST


On Wed, 7 Jan 2015, WANG Chao wrote:

> +#define for_each_setup_data(pa_data, data) \
> + for (pa_data = boot_params.hdr.setup_data; \
> + pa_data && (data = early_memremap(pa_data, sizeof(*data))); \
> + pa_data = data->next, early_iounmap(data, sizeof(*data)))
> +

That makes the code obfuscated not clearer. Brain went into spiral
mode.

struct setup_iter {
u64 pa_data, pa_next;
u32 len, type;
};

....
{
struct setup_iter iter = { .pa_next = boot_params.hdr.setup_data };

while (get_next_setup_data(&iter)) {
switch (iter.type) {
case SETUP_E820_EXT:
parse_e820_ext(iter.pa_data, iter.len);
....

Perhaps?

Thanks,

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