brcm47xx: BCMA - Consolidate/reduce code in bcma_device_name
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.2 / 230-bcma-find-name-for-non-brcm.patch
1 --- a/drivers/bcma/scan.c
2 +++ b/drivers/bcma/scan.c
3 @@ -19,7 +19,14 @@ struct bcma_device_id_name {
4 u16 id;
5 const char *name;
6 };
7 -struct bcma_device_id_name bcma_device_names[] = {
8 +
9 +static const struct bcma_device_id_name bcma_arm_device_names[] = {
10 + { BCMA_CORE_ARM_1176, "ARM 1176" },
11 + { BCMA_CORE_ARM_7TDMI, "ARM 7TDMI" },
12 + { BCMA_CORE_ARM_CM3, "ARM CM3" },
13 +};
14 +
15 +static const struct bcma_device_id_name bcma_bcm_device_names[] = {
16 { BCMA_CORE_OOB_ROUTER, "OOB Router" },
17 { BCMA_CORE_INVALID, "Invalid" },
18 { BCMA_CORE_CHIPCOMMON, "ChipCommon" },
19 @@ -27,7 +34,6 @@ struct bcma_device_id_name bcma_device_n
20 { BCMA_CORE_SRAM, "SRAM" },
21 { BCMA_CORE_SDRAM, "SDRAM" },
22 { BCMA_CORE_PCI, "PCI" },
23 - { BCMA_CORE_MIPS, "MIPS" },
24 { BCMA_CORE_ETHERNET, "Fast Ethernet" },
25 { BCMA_CORE_V90, "V90" },
26 { BCMA_CORE_USB11_HOSTDEV, "USB 1.1 Hostdev" },
27 @@ -44,7 +50,6 @@ struct bcma_device_id_name bcma_device_n
28 { BCMA_CORE_PHY_A, "PHY A" },
29 { BCMA_CORE_PHY_B, "PHY B" },
30 { BCMA_CORE_PHY_G, "PHY G" },
31 - { BCMA_CORE_MIPS_3302, "MIPS 3302" },
32 { BCMA_CORE_USB11_HOST, "USB 1.1 Host" },
33 { BCMA_CORE_USB11_DEV, "USB 1.1 Device" },
34 { BCMA_CORE_USB20_HOST, "USB 2.0 Host" },
35 @@ -58,15 +63,11 @@ struct bcma_device_id_name bcma_device_n
36 { BCMA_CORE_PHY_N, "PHY N" },
37 { BCMA_CORE_SRAM_CTL, "SRAM Controller" },
38 { BCMA_CORE_MINI_MACPHY, "Mini MACPHY" },
39 - { BCMA_CORE_ARM_1176, "ARM 1176" },
40 - { BCMA_CORE_ARM_7TDMI, "ARM 7TDMI" },
41 { BCMA_CORE_PHY_LP, "PHY LP" },
42 { BCMA_CORE_PMU, "PMU" },
43 { BCMA_CORE_PHY_SSN, "PHY SSN" },
44 { BCMA_CORE_SDIO_DEV, "SDIO Device" },
45 - { BCMA_CORE_ARM_CM3, "ARM CM3" },
46 { BCMA_CORE_PHY_HT, "PHY HT" },
47 - { BCMA_CORE_MIPS_74K, "MIPS 74K" },
48 { BCMA_CORE_MAC_GBIT, "GBit MAC" },
49 { BCMA_CORE_DDR12_MEM_CTL, "DDR1/DDR2 Memory Controller" },
50 { BCMA_CORE_PCIE_RC, "PCIe Root Complex" },
51 @@ -79,16 +80,41 @@ struct bcma_device_id_name bcma_device_n
52 { BCMA_CORE_SHIM, "SHIM" },
53 { BCMA_CORE_DEFAULT, "Default" },
54 };
55 -const char *bcma_device_name(struct bcma_device_id *id)
56 +
57 +static const struct bcma_device_id_name bcma_mips_device_names[] = {
58 + { BCMA_CORE_MIPS, "MIPS" },
59 + { BCMA_CORE_MIPS_3302, "MIPS 3302" },
60 + { BCMA_CORE_MIPS_74K, "MIPS 74K" },
61 +};
62 +
63 +static const char *bcma_device_name(const struct bcma_device_id *id)
64 {
65 - int i;
66 + const struct bcma_device_id_name *names;
67 + int size, i;
68
69 - if (id->manuf == BCMA_MANUF_BCM) {
70 - for (i = 0; i < ARRAY_SIZE(bcma_device_names); i++) {
71 - if (bcma_device_names[i].id == id->id)
72 - return bcma_device_names[i].name;
73 - }
74 + /* search manufacturer specific names */
75 + switch (id->manuf) {
76 + case BCMA_MANUF_ARM:
77 + names = bcma_arm_device_names;
78 + size = ARRAY_SIZE(bcma_arm_device_names);
79 + break;
80 + case BCMA_MANUF_BCM:
81 + names = bcma_bcm_device_names;
82 + size = ARRAY_SIZE(bcma_bcm_device_names);
83 + break;
84 + case BCMA_MANUF_MIPS:
85 + names = bcma_mips_device_names;
86 + size = ARRAY_SIZE(bcma_mips_device_names);
87 + break;
88 + default:
89 + return "UNKNOWN";
90 }
91 +
92 + for (i = 0; i < size; i++) {
93 + if (names[i].id == id->id)
94 + return names[i].name;
95 + }
96 +
97 return "UNKNOWN";
98 }
99