400-mips-multi-machine-update.patch 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. --- a/arch/mips/kernel/mips_machine.c
  2. +++ b/arch/mips/kernel/mips_machine.c
  3. @@ -7,12 +7,13 @@
  4. *
  5. */
  6. #include <linux/mm.h>
  7. +#include <linux/string.h>
  8. #include <asm/mips_machine.h>
  9. -#include <asm/bootinfo.h>
  10. static struct list_head mips_machines __initdata =
  11. LIST_HEAD_INIT(mips_machines);
  12. +static char *mips_machid __initdata;
  13. char *mips_machine_name = "Unknown";
  14. @@ -55,20 +56,65 @@ void __init mips_machine_set_name(char *
  15. }
  16. }
  17. -void __init mips_machine_setup(unsigned long machtype)
  18. +void __init mips_machine_setup(void)
  19. {
  20. struct mips_machine *mach;
  21. - mach = mips_machine_find(machtype);
  22. + mach = mips_machine_find(mips_machtype);
  23. if (!mach) {
  24. - printk(KERN_ALERT "MIPS: no machine registered for "
  25. - "machtype %lu\n", machtype);
  26. + printk(KERN_WARNING "MIPS: no machine registered for "
  27. + "machtype %lu\n", mips_machtype);
  28. return;
  29. }
  30. mips_machine_set_name(mach->mach_name);
  31. - printk(KERN_INFO "MIPS: machine is %s\n", mips_machine_name);
  32. + printk(KERN_NOTICE "MIPS: machine is %s\n", mips_machine_name);
  33. if (mach->mach_setup)
  34. mach->mach_setup();
  35. }
  36. +
  37. +int __init mips_machtype_setup(char *id)
  38. +{
  39. + if (mips_machid == NULL)
  40. + mips_machid = id;
  41. +
  42. + return 1;
  43. +}
  44. +
  45. +__setup("machtype=", mips_machtype_setup);
  46. +
  47. +static int __init mips_machtype_init(void)
  48. +{
  49. + struct list_head *this;
  50. + struct mips_machine *mach;
  51. +
  52. + if (mips_machid == NULL)
  53. + return 0;
  54. +
  55. + list_for_each(this, &mips_machines) {
  56. + mach = list_entry(this, struct mips_machine, list);
  57. + if (mach->mach_id == NULL)
  58. + continue;
  59. +
  60. + if (strcmp(mach->mach_id, mips_machid) == 0) {
  61. + mips_machtype = mach->mach_type;
  62. + return 0;
  63. + }
  64. + }
  65. +
  66. + printk(KERN_WARNING
  67. + "MIPS: no machine found for id: '%s', registered machines:\n",
  68. + mips_machid);
  69. + printk(KERN_WARNING "%32s %s\n", "id", "name");
  70. +
  71. + list_for_each(this, &mips_machines) {
  72. + mach = list_entry(this, struct mips_machine, list);
  73. + printk(KERN_WARNING "%32s %s\n",
  74. + mach->mach_id ? mach->mach_id : "", mach->mach_name);
  75. + }
  76. +
  77. + return 0;
  78. +}
  79. +
  80. +core_initcall(mips_machtype_init);
  81. --- a/arch/mips/include/asm/mips_machine.h
  82. +++ b/arch/mips/include/asm/mips_machine.h
  83. @@ -13,25 +13,33 @@
  84. #include <linux/init.h>
  85. #include <linux/list.h>
  86. +#include <asm/bootinfo.h>
  87. +
  88. struct mips_machine {
  89. unsigned long mach_type;
  90. - void (*mach_setup)(void);
  91. + char *mach_id;
  92. char *mach_name;
  93. + void (*mach_setup)(void);
  94. struct list_head list;
  95. };
  96. void mips_machine_register(struct mips_machine *) __init;
  97. -void mips_machine_setup(unsigned long machtype) __init;
  98. +void mips_machine_setup(void) __init;
  99. +int mips_machtype_setup(char *id) __init;
  100. void mips_machine_set_name(char *name) __init;
  101. extern char *mips_machine_name;
  102. -#define MIPS_MACHINE(_type, _name, _setup) \
  103. -static char machine_name_##_type[] __initdata = _name; \
  104. +#define MIPS_MACHINE(_type, _id, _name, _setup) \
  105. +static const char machine_name_##_type[] __initconst \
  106. + __aligned(1) = _name; \
  107. +static const char machine_id_##_type[] __initconst \
  108. + __aligned(1) = _id; \
  109. static struct mips_machine machine_##_type __initdata = \
  110. { \
  111. .mach_type = _type, \
  112. - .mach_name = machine_name_##_type, \
  113. + .mach_id = (char *) machine_id_##_type, \
  114. + .mach_name = (char *) machine_name_##_type, \
  115. .mach_setup = _setup, \
  116. }; \
  117. \
  118. @@ -44,4 +52,3 @@ static int __init register_machine_##_ty
  119. pure_initcall(register_machine_##_type)
  120. #endif /* __ASM_MIPS_MACHINE_H */
  121. -