031-10-MIPS-BCM47xx-Keep-ID-entries-for-non-standard-device.patch 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. From 7515c6f1da334184c3ece06e6f61461086d8e2b1 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  3. Date: Wed, 1 Apr 2015 18:18:01 +0200
  4. Subject: [PATCH] MIPS: BCM47xx: Keep ID entries for non-standard devices
  5. together
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  10. Cc: linux-mips@linux-mips.org
  11. Cc: Hauke Mehrtens <hauke@hauke-m.de>
  12. Patchwork: https://patchwork.linux-mips.org/patch/9655/
  13. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  14. ---
  15. arch/mips/bcm47xx/board.c | 48 ++++++++++++++++++++---------------------------
  16. 1 file changed, 20 insertions(+), 28 deletions(-)
  17. --- a/arch/mips/bcm47xx/board.c
  18. +++ b/arch/mips/bcm47xx/board.c
  19. @@ -40,20 +40,6 @@ struct bcm47xx_board_type_list1 bcm47xx_
  20. { {0}, NULL},
  21. };
  22. -/* model_no */
  23. -static const
  24. -struct bcm47xx_board_type_list1 bcm47xx_board_list_model_no[] __initconst = {
  25. - {{BCM47XX_BOARD_ASUS_WL700GE, "Asus WL700"}, "WL700"},
  26. - { {0}, NULL},
  27. -};
  28. -
  29. -/* machine_name */
  30. -static const
  31. -struct bcm47xx_board_type_list1 bcm47xx_board_list_machine_name[] __initconst = {
  32. - {{BCM47XX_BOARD_LINKSYS_WRTSL54GS, "Linksys WRTSL54GS"}, "WRTSL54GS"},
  33. - { {0}, NULL},
  34. -};
  35. -
  36. /* hardware_version */
  37. static const
  38. struct bcm47xx_board_type_list1 bcm47xx_board_list_hardware_version[] __initconst = {
  39. @@ -202,6 +188,18 @@ struct bcm47xx_board_type_list2 bcm47xx_
  40. { {0}, NULL},
  41. };
  42. +/*
  43. + * Some devices don't use any common NVRAM entry for identification and they
  44. + * have only one model specific variable.
  45. + * They don't deserve own arrays, let's group them there using key-value array.
  46. + */
  47. +static const
  48. +struct bcm47xx_board_type_list2 bcm47xx_board_list_key_value[] __initconst = {
  49. + {{BCM47XX_BOARD_ASUS_WL700GE, "Asus WL700"}, "model_no", "WL700"},
  50. + {{BCM47XX_BOARD_LINKSYS_WRTSL54GS, "Linksys WRTSL54GS"}, "machine_name", "WRTSL54GS"},
  51. + { {0}, NULL},
  52. +};
  53. +
  54. static const
  55. struct bcm47xx_board_type bcm47xx_board_unknown[] __initconst = {
  56. {BCM47XX_BOARD_UNKNOWN, "Unknown Board"},
  57. @@ -225,20 +223,6 @@ static __init const struct bcm47xx_board
  58. }
  59. }
  60. - if (bcm47xx_nvram_getenv("model_no", buf1, sizeof(buf1)) >= 0) {
  61. - for (e1 = bcm47xx_board_list_model_no; e1->value1; e1++) {
  62. - if (strstarts(buf1, e1->value1))
  63. - return &e1->board;
  64. - }
  65. - }
  66. -
  67. - if (bcm47xx_nvram_getenv("machine_name", buf1, sizeof(buf1)) >= 0) {
  68. - for (e1 = bcm47xx_board_list_machine_name; e1->value1; e1++) {
  69. - if (strstarts(buf1, e1->value1))
  70. - return &e1->board;
  71. - }
  72. - }
  73. -
  74. if (bcm47xx_nvram_getenv("hardware_version", buf1, sizeof(buf1)) >= 0) {
  75. for (e1 = bcm47xx_board_list_hardware_version; e1->value1; e1++) {
  76. if (strstarts(buf1, e1->value1))
  77. @@ -314,6 +298,14 @@ static __init const struct bcm47xx_board
  78. return &e2->board;
  79. }
  80. }
  81. +
  82. + for (e2 = bcm47xx_board_list_key_value; e2->value1; e2++) {
  83. + if (bcm47xx_nvram_getenv(e2->value1, buf1, sizeof(buf1)) >= 0) {
  84. + if (!strcmp(buf1, e2->value2))
  85. + return &e2->board;
  86. + }
  87. + }
  88. +
  89. return bcm47xx_board_unknown;
  90. }