With there being several instances of custom_param() where the handler is just invoking parse_size_and_unit(), it seems to make sense to introduce a simplifying abstraction. Also fix serial_txbufsz not having been guaranteed to be a power of two. Signed-off-by: Jan Beulich <jbeulich@novell.com> --- 2009-08-18.orig/xen/arch/ia64/xen/domain.c 2009-07-03 10:20:56.000000000 +0200 +++ 2009-08-18/xen/arch/ia64/xen/domain.c 2009-08-26 17:06:07.000000000 +0200 @@ -2387,11 +2387,7 @@ arch_do_vcpu_op(int cmd, struct vcpu *v, return rc; } -static void __init parse_dom0_mem(char *s) -{ - dom0_size = parse_size_and_unit(s, NULL); -} -custom_param("dom0_mem", parse_dom0_mem); +size_param("dom0_mem", dom0_size); /* * Helper function for the optimization stuff handling the identity mapping --- 2009-08-18.orig/xen/arch/x86/e820.c 2009-08-18 14:18:24.000000000 +0200 +++ 2009-08-18/xen/arch/x86/e820.c 2009-08-26 17:04:24.000000000 +0200 @@ -11,9 +11,8 @@ #include <asm/msr.h> /* opt_mem: Limit of physical RAM. Any RAM beyond this point is ignored. */ -unsigned long long opt_mem; -static void parse_mem(char *s) { opt_mem = parse_size_and_unit(s, NULL); } -custom_param("mem", parse_mem); +static unsigned long long __initdata opt_mem; +size_param("mem", opt_mem); /* opt_nomtrr_check: Don''t clip ram to highest cacheable MTRR. */ static int __initdata e820_mtrr_clip = -1; --- 2009-08-18.orig/xen/common/kernel.c 2009-06-19 11:11:23.000000000 +0200 +++ 2009-08-18/xen/common/kernel.c 2009-08-26 16:55:59.000000000 +0200 @@ -92,6 +92,19 @@ void cmdline_parse(char *cmdline) bool_assert = !bool_assert; *(int *)param->var = bool_assert; break; + case OPT_SIZE: + switch ( param->len ) + { + case sizeof(uint32_t): + *(uint32_t *)param->var = parse_size_and_unit(optval, NULL); + break; + case sizeof(uint64_t): + *(uint64_t *)param->var = parse_size_and_unit(optval, NULL); + break; + default: + BUG(); + } + break; case OPT_CUSTOM: ((void (*)(const char *))param->var)(optval); break; --- 2009-08-18.orig/xen/drivers/char/console.c 2009-08-26 16:47:56.000000000 +0200 +++ 2009-08-18/xen/drivers/char/console.c 2009-08-26 16:52:54.000000000 +0200 @@ -59,10 +59,8 @@ static int opt_console_timestamps; boolean_param("console_timestamps", opt_console_timestamps); /* conring_size: allows a large console ring than default (16kB). */ -static uint32_t opt_conring_size; -static void parse_conring_size(char *s) -{ opt_conring_size = parse_size_and_unit(s, NULL); } -custom_param("conring_size", parse_conring_size); +static uint32_t __initdata opt_conring_size; +size_param("conring_size", opt_conring_size); #define _CONRING_SIZE 16384 #define CONRING_IDX_MASK(i) ((i)&(conring_size-1)) --- 2009-08-18.orig/xen/drivers/char/serial.c 2009-02-18 17:45:17.000000000 +0100 +++ 2009-08-18/xen/drivers/char/serial.c 2009-08-26 17:00:43.000000000 +0200 @@ -19,11 +19,7 @@ /* #define SERIAL_NEVER_DROP_CHARS 1 */ unsigned int serial_txbufsz = 16384; -static void __init parse_serial_tx_buffer(const char *s) -{ - serial_txbufsz = max((unsigned int)parse_size_and_unit(s, NULL), 512u); -} -custom_param("serial_tx_buffer", parse_serial_tx_buffer); +size_param("serial_tx_buffer", serial_txbufsz); #define mask_serial_rxbuf_idx(_i) ((_i)&(serial_rxbufsz-1)) #define mask_serial_txbuf_idx(_i) ((_i)&(serial_txbufsz-1)) @@ -494,8 +490,14 @@ void serial_async_transmit(struct serial { BUG_ON(!port->driver->tx_empty); if ( port->txbuf == NULL ) + { + if ( serial_txbufsz < 512) + serial_txbufsz = 512; + else while ( serial_txbufsz & (serial_txbufsz - 1) ) + serial_txbufsz &= serial_txbufsz - 1; port->txbuf = alloc_xenheap_pages( get_order_from_bytes(serial_txbufsz), 0); + } } /* --- 2009-08-18.orig/xen/include/xen/init.h 2007-07-10 09:40:06.000000000 +0200 +++ 2009-08-18/xen/include/xen/init.h 2009-08-26 16:51:56.000000000 +0200 @@ -78,7 +78,14 @@ extern initcall_t __initcall_start, __in */ struct kernel_param { const char *name; - enum { OPT_STR, OPT_UINT, OPT_BOOL, OPT_INVBOOL, OPT_CUSTOM } type; + enum { + OPT_STR, + OPT_UINT, + OPT_BOOL, + OPT_INVBOOL, + OPT_SIZE, + OPT_CUSTOM + } type; void *var; unsigned int len; }; @@ -101,6 +108,10 @@ extern struct kernel_param __setup_start static char __setup_str_##_var[] __initdata = _name; \ static struct kernel_param __setup_##_var __attribute_used__ \ __initsetup = { __setup_str_##_var, OPT_UINT, &_var, sizeof(_var) } +#define size_param(_name, _var) \ + static char __setup_str_##_var[] __initdata = _name; \ + static struct kernel_param __setup_##_var __attribute_used__ \ + __initsetup = { __setup_str_##_var, OPT_SIZE, &_var, sizeof(_var) } #define string_param(_name, _var) \ static char __setup_str_##_var[] __initdata = _name; \ static struct kernel_param __setup_##_var __attribute_used__ \ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel