aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64
diff options
context:
space:
mode:
authorHorms <horms@verge.net.au>2006-03-23 17:27:12 -0500
committerTony Luck <tony.luck@intel.com>2006-03-23 17:27:12 -0500
commita5b00bb4fe60796c791238cf5653b82110031c93 (patch)
tree05938f68e51ad465e7ff76f05945210523061c1b /arch/ia64
parent39e18de810049e836390830174a248ad241b156a (diff)
IA64: Use early_parm to handle mvec_name and nomca
I'm not sure of the worthiness of this idea, so please consider it an RFC. Its key merits are: * Reuse existing infrastructure * Greatly tightens up the parsing of nomca * Greatly simplifies the parsing of machvec Addition cleanup (moving setup_mvec() to machvec.c) by Ken Chen. Signed-Off-By: Horms <horms@verge.net.au> Signed-Off-By: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'arch/ia64')
-rw-r--r--arch/ia64/kernel/machvec.c19
-rw-r--r--arch/ia64/kernel/setup.c36
2 files changed, 27 insertions, 28 deletions
diff --git a/arch/ia64/kernel/machvec.c b/arch/ia64/kernel/machvec.c
index c3a04ee7f4f6..4b0b71d5aef4 100644
--- a/arch/ia64/kernel/machvec.c
+++ b/arch/ia64/kernel/machvec.c
@@ -14,7 +14,15 @@
14struct ia64_machine_vector ia64_mv; 14struct ia64_machine_vector ia64_mv;
15EXPORT_SYMBOL(ia64_mv); 15EXPORT_SYMBOL(ia64_mv);
16 16
17static struct ia64_machine_vector * 17static __initdata const char *mvec_name;
18static __init int setup_mvec(char *s)
19{
20 mvec_name = s;
21 return 0;
22}
23early_param("machvec", setup_mvec);
24
25static struct ia64_machine_vector * __init
18lookup_machvec (const char *name) 26lookup_machvec (const char *name)
19{ 27{
20 extern struct ia64_machine_vector machvec_start[]; 28 extern struct ia64_machine_vector machvec_start[];
@@ -33,10 +41,13 @@ machvec_init (const char *name)
33{ 41{
34 struct ia64_machine_vector *mv; 42 struct ia64_machine_vector *mv;
35 43
44 if (!name)
45 name = mvec_name ? mvec_name : acpi_get_sysname();
36 mv = lookup_machvec(name); 46 mv = lookup_machvec(name);
37 if (!mv) { 47 if (!mv)
38 panic("generic kernel failed to find machine vector for platform %s!", name); 48 panic("generic kernel failed to find machine vector for"
39 } 49 " platform %s!", name);
50
40 ia64_mv = *mv; 51 ia64_mv = *mv;
41 printk(KERN_INFO "booting generic kernel on platform %s\n", name); 52 printk(KERN_INFO "booting generic kernel on platform %s\n", name);
42} 53}
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index eb0793628b8a..fc860778fa41 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -389,6 +389,14 @@ check_for_logical_procs (void)
389} 389}
390#endif 390#endif
391 391
392static __initdata int nomca;
393static __init int setup_nomca(char *s)
394{
395 nomca = 1;
396 return 0;
397}
398early_param("nomca", setup_nomca);
399
392void __init 400void __init
393setup_arch (char **cmdline_p) 401setup_arch (char **cmdline_p)
394{ 402{
@@ -402,35 +410,15 @@ setup_arch (char **cmdline_p)
402 efi_init(); 410 efi_init();
403 io_port_init(); 411 io_port_init();
404 412
413 parse_early_param();
414
405#ifdef CONFIG_IA64_GENERIC 415#ifdef CONFIG_IA64_GENERIC
406 { 416 machvec_init(NULL);
407 const char *mvec_name = strstr (*cmdline_p, "machvec=");
408 char str[64];
409
410 if (mvec_name) {
411 const char *end;
412 size_t len;
413
414 mvec_name += 8;
415 end = strchr (mvec_name, ' ');
416 if (end)
417 len = end - mvec_name;
418 else
419 len = strlen (mvec_name);
420 len = min(len, sizeof (str) - 1);
421 strncpy (str, mvec_name, len);
422 str[len] = '\0';
423 mvec_name = str;
424 } else
425 mvec_name = acpi_get_sysname();
426 machvec_init(mvec_name);
427 }
428#endif 417#endif
429 418
430 if (early_console_setup(*cmdline_p) == 0) 419 if (early_console_setup(*cmdline_p) == 0)
431 mark_bsp_online(); 420 mark_bsp_online();
432 421
433 parse_early_param();
434#ifdef CONFIG_ACPI 422#ifdef CONFIG_ACPI
435 /* Initialize the ACPI boot-time table parser */ 423 /* Initialize the ACPI boot-time table parser */
436 acpi_table_init(); 424 acpi_table_init();
@@ -493,7 +481,7 @@ setup_arch (char **cmdline_p)
493#endif 481#endif
494 482
495 /* enable IA-64 Machine Check Abort Handling unless disabled */ 483 /* enable IA-64 Machine Check Abort Handling unless disabled */
496 if (!strstr(saved_command_line, "nomca")) 484 if (!nomca)
497 ia64_mca_init(); 485 ia64_mca_init();
498 486
499 platform_setup(cmdline_p); 487 platform_setup(cmdline_p);
lass="hl opt">); } } EXPORT_SYMBOL(input_mt_report_pointer_emulation); /** * input_mt_sync_frame() - synchronize mt frame * @dev: input device with allocated MT slots * * Close the frame and prepare the internal state for a new one. * Depending on the flags, marks unused slots as inactive and performs * pointer emulation. */ void input_mt_sync_frame(struct input_dev *dev) { struct input_mt *mt = dev->mt; struct input_mt_slot *s; if (!mt) return; if (mt->flags & INPUT_MT_DROP_UNUSED) { for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { if (input_mt_is_used(mt, s)) continue; input_mt_slot(dev, s - mt->slots); input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1); } } input_mt_report_pointer_emulation(dev, (mt->flags & INPUT_MT_POINTER)); mt->frame++; } EXPORT_SYMBOL(input_mt_sync_frame); static int adjust_dual(int *begin, int step, int *end, int eq) { int f, *p, s, c; if (begin == end) return 0; f = *begin; p = begin + step; s = p == end ? f + 1 : *p; for (; p != end; p += step) if (*p < f) s = f, f = *p; else if (*p < s) s = *p; c = (f + s + 1) / 2; if (c == 0 || (c > 0 && !eq)) return 0; if (s < 0) c *= 2; for (p = begin; p != end; p += step) *p -= c; return (c < s && s <= 0) || (f >= 0 && f < c); } static void find_reduced_matrix(int *w, int nr, int nc, int nrc) { int i, k, sum; for (k = 0; k < nrc; k++) { for (i = 0; i < nr; i++) adjust_dual(w + i, nr, w + i + nrc, nr <= nc); sum = 0; for (i = 0; i < nrc; i += nr) sum += adjust_dual(w + i, 1, w + i + nr, nc <= nr); if (!sum) break; } } static int input_mt_set_matrix(struct input_mt *mt, const struct input_mt_pos *pos, int num_pos) { const struct input_mt_pos *p; struct input_mt_slot *s; int *w = mt->red; int x, y; for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { if (!input_mt_is_active(s)) continue; x = input_mt_get_value(s, ABS_MT_POSITION_X); y = input_mt_get_value(s, ABS_MT_POSITION_Y); for (p = pos; p != pos + num_pos; p++) { int dx = x - p->x, dy = y - p->y; *w++ = dx * dx + dy * dy; } } return w - mt->red; } static void input_mt_set_slots(struct input_mt *mt, int *slots, int num_pos) { struct input_mt_slot *s; int *w = mt->red, *p; for (p = slots; p != slots + num_pos; p++) *p = -1; for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { if (!input_mt_is_active(s)) continue; for (p = slots; p != slots + num_pos; p++) if (*w++ < 0) *p = s - mt->slots; } for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { if (input_mt_is_active(s)) continue; for (p = slots; p != slots + num_pos; p++) if (*p < 0) { *p = s - mt->slots; break; } } } /** * input_mt_assign_slots() - perform a best-match assignment * @dev: input device with allocated MT slots * @slots: the slot assignment to be filled * @pos: the position array to match * @num_pos: number of positions * * Performs a best match against the current contacts and returns * the slot assignment list. New contacts are assigned to unused * slots. * * Returns zero on success, or negative error in case of failure. */ int input_mt_assign_slots(struct input_dev *dev, int *slots, const struct input_mt_pos *pos, int num_pos) { struct input_mt *mt = dev->mt; int nrc; if (!mt || !mt->red) return -ENXIO; if (num_pos > mt->num_slots) return -EINVAL; if (num_pos < 1) return 0; nrc = input_mt_set_matrix(mt, pos, num_pos); find_reduced_matrix(mt->red, num_pos, nrc / num_pos, nrc); input_mt_set_slots(mt, slots, num_pos); return 0; } EXPORT_SYMBOL(input_mt_assign_slots); /** * input_mt_get_slot_by_key() - return slot matching key * @dev: input device with allocated MT slots * @key: the key of the sought slot * * Returns the slot of the given key, if it exists, otherwise * set the key on the first unused slot and return. * * If no available slot can be found, -1 is returned. */ int input_mt_get_slot_by_key(struct input_dev *dev, int key) { struct input_mt *mt = dev->mt; struct input_mt_slot *s; if (!mt) return -1; for (s = mt->slots; s != mt->slots + mt->num_slots; s++) if (input_mt_is_active(s) && s->key == key) return s - mt->slots; for (s = mt->slots; s != mt->slots + mt->num_slots; s++) if (!input_mt_is_active(s)) { s->key = key; return s - mt->slots; } return -1; } EXPORT_SYMBOL(input_mt_get_slot_by_key);