source: trunk/target/linux/brcm47xx/patches-3.2/230-bcma-find-name-for-non-brcm.patch @ 31120

Last change on this file since 31120 was 31120, checked in by hauke, 5 years ago

brcm47xx: BCMA - Consolidate/reduce code in bcma_device_name

Eliminate unneeded procedure by incorporating code into bcma_device_name

Signed-off-by: Nathan Hintz <nlhintz@…>

File size: 3.0 KB
  • drivers/bcma/scan.c

    a b struct bcma_device_id_name { 
    1919        u16 id; 
    2020        const char *name; 
    2121}; 
    22 struct bcma_device_id_name bcma_device_names[] = { 
     22 
     23static const struct bcma_device_id_name bcma_arm_device_names[] = { 
     24        { BCMA_CORE_ARM_1176, "ARM 1176" }, 
     25        { BCMA_CORE_ARM_7TDMI, "ARM 7TDMI" }, 
     26        { BCMA_CORE_ARM_CM3, "ARM CM3" }, 
     27}; 
     28 
     29static const struct bcma_device_id_name bcma_bcm_device_names[] = { 
    2330        { BCMA_CORE_OOB_ROUTER, "OOB Router" }, 
    2431        { BCMA_CORE_INVALID, "Invalid" }, 
    2532        { BCMA_CORE_CHIPCOMMON, "ChipCommon" }, 
    struct bcma_device_id_name bcma_device_n 
    2734        { BCMA_CORE_SRAM, "SRAM" }, 
    2835        { BCMA_CORE_SDRAM, "SDRAM" }, 
    2936        { BCMA_CORE_PCI, "PCI" }, 
    30         { BCMA_CORE_MIPS, "MIPS" }, 
    3137        { BCMA_CORE_ETHERNET, "Fast Ethernet" }, 
    3238        { BCMA_CORE_V90, "V90" }, 
    3339        { BCMA_CORE_USB11_HOSTDEV, "USB 1.1 Hostdev" }, 
    struct bcma_device_id_name bcma_device_n 
    4450        { BCMA_CORE_PHY_A, "PHY A" }, 
    4551        { BCMA_CORE_PHY_B, "PHY B" }, 
    4652        { BCMA_CORE_PHY_G, "PHY G" }, 
    47         { BCMA_CORE_MIPS_3302, "MIPS 3302" }, 
    4853        { BCMA_CORE_USB11_HOST, "USB 1.1 Host" }, 
    4954        { BCMA_CORE_USB11_DEV, "USB 1.1 Device" }, 
    5055        { BCMA_CORE_USB20_HOST, "USB 2.0 Host" }, 
    struct bcma_device_id_name bcma_device_n 
    5863        { BCMA_CORE_PHY_N, "PHY N" }, 
    5964        { BCMA_CORE_SRAM_CTL, "SRAM Controller" }, 
    6065        { BCMA_CORE_MINI_MACPHY, "Mini MACPHY" }, 
    61         { BCMA_CORE_ARM_1176, "ARM 1176" }, 
    62         { BCMA_CORE_ARM_7TDMI, "ARM 7TDMI" }, 
    6366        { BCMA_CORE_PHY_LP, "PHY LP" }, 
    6467        { BCMA_CORE_PMU, "PMU" }, 
    6568        { BCMA_CORE_PHY_SSN, "PHY SSN" }, 
    6669        { BCMA_CORE_SDIO_DEV, "SDIO Device" }, 
    67         { BCMA_CORE_ARM_CM3, "ARM CM3" }, 
    6870        { BCMA_CORE_PHY_HT, "PHY HT" }, 
    69         { BCMA_CORE_MIPS_74K, "MIPS 74K" }, 
    7071        { BCMA_CORE_MAC_GBIT, "GBit MAC" }, 
    7172        { BCMA_CORE_DDR12_MEM_CTL, "DDR1/DDR2 Memory Controller" }, 
    7273        { BCMA_CORE_PCIE_RC, "PCIe Root Complex" }, 
    struct bcma_device_id_name bcma_device_n 
    7980        { BCMA_CORE_SHIM, "SHIM" }, 
    8081        { BCMA_CORE_DEFAULT, "Default" }, 
    8182}; 
    82 const char *bcma_device_name(struct bcma_device_id *id) 
     83 
     84static const struct bcma_device_id_name bcma_mips_device_names[] = { 
     85        { BCMA_CORE_MIPS, "MIPS" }, 
     86        { BCMA_CORE_MIPS_3302, "MIPS 3302" }, 
     87        { BCMA_CORE_MIPS_74K, "MIPS 74K" }, 
     88}; 
     89 
     90static const char *bcma_device_name(const struct bcma_device_id *id) 
    8391{ 
    84         int i; 
     92        const struct bcma_device_id_name *names; 
     93        int size, i; 
    8594 
    86         if (id->manuf == BCMA_MANUF_BCM) { 
    87                 for (i = 0; i < ARRAY_SIZE(bcma_device_names); i++) { 
    88                         if (bcma_device_names[i].id == id->id) 
    89                                 return bcma_device_names[i].name; 
    90                 } 
     95        /* search manufacturer specific names */ 
     96        switch (id->manuf) { 
     97        case BCMA_MANUF_ARM: 
     98                names = bcma_arm_device_names; 
     99                size = ARRAY_SIZE(bcma_arm_device_names); 
     100                break; 
     101        case BCMA_MANUF_BCM: 
     102                names = bcma_bcm_device_names; 
     103                size = ARRAY_SIZE(bcma_bcm_device_names); 
     104                break; 
     105        case BCMA_MANUF_MIPS: 
     106                names = bcma_mips_device_names; 
     107                size = ARRAY_SIZE(bcma_mips_device_names); 
     108                break; 
     109        default: 
     110                return "UNKNOWN"; 
    91111        } 
     112 
     113        for (i = 0; i < size; i++) { 
     114                if (names[i].id == id->id) 
     115                        return names[i].name; 
     116        } 
     117 
    92118        return "UNKNOWN"; 
    93119} 
    94120 
Note: See TracBrowser for help on using the repository browser.