Commit f64009a7 authored by David Brownell's avatar David Brownell Committed by Russell King

[ARM PATCH] 1712/1: pxa2xx_udc (1/5) add INIT_MACHINE

Patch from David Brownell

This adds a mechanism for a per-machine initcall, one that's
guaranteed to run only to initialize a kernel running on that
specific hardware.  It's not strictly necessary, but it does
eliminate the need for certain boilerplate in machine-specific
support, to ensure it's only running on the right hardware:

      /* in arch/arm/mach-xxx/MYMACHINE.c */
      ...
      static int __init init_MYMACHINE(void)
      {
           if (!mach_is_MYMACHINE())       // often forgotten!!
                return -EINVAL;
           ... declare and customize platform devices
           ...
           return 0;
      }
      arch_initcall(init_MYMACHINE);

An init_MYMACHINE() call still exists, but it'd be declared
as part of the machine definition.
parent 4576b4fa
...@@ -654,6 +654,17 @@ static struct init_tags { ...@@ -654,6 +654,17 @@ static struct init_tags {
{ 0, ATAG_NONE } { 0, ATAG_NONE }
}; };
static void (*init_machine)(void) __initdata;
static int __init customize_machine(void)
{
/* customizes platform devices, or adds new ones */
if (init_machine)
init_machine();
return 0;
}
arch_initcall(customize_machine);
void __init setup_arch(char **cmdline_p) void __init setup_arch(char **cmdline_p)
{ {
struct tag *tags = (struct tag *)&init_tags; struct tag *tags = (struct tag *)&init_tags;
...@@ -704,6 +715,7 @@ void __init setup_arch(char **cmdline_p) ...@@ -704,6 +715,7 @@ void __init setup_arch(char **cmdline_p)
* Set up various architecture-specific pointers * Set up various architecture-specific pointers
*/ */
init_arch_irq = mdesc->init_irq; init_arch_irq = mdesc->init_irq;
init_machine = mdesc->init_machine;
#ifdef CONFIG_VT #ifdef CONFIG_VT
#if defined(CONFIG_VGA_CONSOLE) #if defined(CONFIG_VGA_CONSOLE)
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* The size of struct machine_desc * The size of struct machine_desc
* (for assembler code) * (for assembler code)
*/ */
#define SIZEOF_MACHINE_DESC 48 #define SIZEOF_MACHINE_DESC 52
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
...@@ -45,6 +45,7 @@ struct machine_desc { ...@@ -45,6 +45,7 @@ struct machine_desc {
struct meminfo *); struct meminfo *);
void (*map_io)(void);/* IO mapping function */ void (*map_io)(void);/* IO mapping function */
void (*init_irq)(void); void (*init_irq)(void);
void (*init_machine)(void);
}; };
/* /*
...@@ -86,6 +87,9 @@ const struct machine_desc __mach_desc_##_type \ ...@@ -86,6 +87,9 @@ const struct machine_desc __mach_desc_##_type \
#define INITIRQ(_func) \ #define INITIRQ(_func) \
.init_irq = _func, .init_irq = _func,
#define INIT_MACHINE(_func) \
.init_machine = _func,
#define MACHINE_END \ #define MACHINE_END \
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment