]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
spi: bfin_spi: Remove unnecessary test for bus and pins[bus]
authorAxel Lin <axel.lin@ingics.com>
Mon, 2 Dec 2013 04:57:33 +0000 (12:57 +0800)
committerSonic Zhang <sonic.zhang@analog.com>
Fri, 6 Dec 2013 08:06:51 +0000 (16:06 +0800)
For invalid bus number, current code returns NULL in the default case of
switch-case statements. In additional, pins[bus] is always not NULL because
it is the address of specific row of the two-dimensional array.
Thus this patch removes these unnecessary test.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
drivers/spi/bfin_spi.c

index bb88f3008a8b5ad899da0a0d0c037f05d912284d..aa89d89a32afa3c9e2710ff0214f50050a23f60e 100644 (file)
@@ -162,21 +162,22 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
        if (!spi_cs_is_valid(bus, cs))
                return NULL;
 
-       if (bus >= ARRAY_SIZE(pins) || pins[bus] == NULL) {
-               debug("%s: invalid bus %u\n", __func__, bus);
-               return NULL;
-       }
        switch (bus) {
 #ifdef SPI0_CTL
-               case 0: mmr_base = SPI0_CTL; break;
+       case 0:
+               mmr_base = SPI0_CTL; break;
 #endif
 #ifdef SPI1_CTL
-               case 1: mmr_base = SPI1_CTL; break;
+       case 1:
+               mmr_base = SPI1_CTL; break;
 #endif
 #ifdef SPI2_CTL
-               case 2: mmr_base = SPI2_CTL; break;
+       case 2:
+               mmr_base = SPI2_CTL; break;
 #endif
-               default: return NULL;
+       default:
+               debug("%s: invalid bus %u\n", __func__, bus);
+               return NULL;
        }
 
        bss = spi_alloc_slave(struct bfin_spi_slave, bus, cs);