mtd: nand: denali: remove unneeded find_valid_banks()
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Tue, 13 Jun 2017 13:45:36 +0000 (22:45 +0900)
committerBoris Brezillon <boris.brezillon@free-electrons.com>
Tue, 20 Jun 2017 07:14:25 +0000 (09:14 +0200)
The function find_valid_banks() issues the Read ID (0x90) command,
then compares the first byte (Manufacturer ID) of each bank with
the one of bank0.

This is equivalent to what nand_scan_ident() does.  The number of
chips is detected there, so this is unneeded.

What is worse for find_valid_banks() is that, if multiple chips are
connected to INTEL_CE4100 platform, it crashes the kernel by BUG().
This is what we should avoid.  This function is just harmful and
unneeded.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
drivers/mtd/nand/denali.c
drivers/mtd/nand/denali.h

index 7133a33b4ad36809d9d38e10f921072637a4c372..122df4c6126d032be7e6bd149f5107d1aa798a94 100644 (file)
@@ -337,51 +337,6 @@ static void get_samsung_nand_para(struct denali_nand_info *denali,
        }
 }
 
-/*
- * determines how many NAND chips are connected to the controller. Note for
- * Intel CE4100 devices we don't support more than one device.
- */
-static void find_valid_banks(struct denali_nand_info *denali)
-{
-       uint32_t id[denali->max_banks];
-       int i;
-
-       denali->total_used_banks = 1;
-       for (i = 0; i < denali->max_banks; i++) {
-               index_addr(denali, MODE_11 | (i << 24) | 0, 0x90);
-               index_addr(denali, MODE_11 | (i << 24) | 1, 0);
-               index_addr_read_data(denali, MODE_11 | (i << 24) | 2, &id[i]);
-
-               dev_dbg(denali->dev,
-                       "Return 1st ID for bank[%d]: %x\n", i, id[i]);
-
-               if (i == 0) {
-                       if (!(id[i] & 0x0ff))
-                               break; /* WTF? */
-               } else {
-                       if ((id[i] & 0x0ff) == (id[0] & 0x0ff))
-                               denali->total_used_banks++;
-                       else
-                               break;
-               }
-       }
-
-       if (denali->platform == INTEL_CE4100) {
-               /*
-                * Platform limitations of the CE4100 device limit
-                * users to a single chip solution for NAND.
-                * Multichip support is not enabled.
-                */
-               if (denali->total_used_banks != 1) {
-                       dev_err(denali->dev,
-                               "Sorry, Intel CE4100 only supports a single NAND device.\n");
-                       BUG();
-               }
-       }
-       dev_dbg(denali->dev,
-               "denali->total_used_banks: %d\n", denali->total_used_banks);
-}
-
 /*
  * Use the configuration feature register to determine the maximum number of
  * banks that the hardware supports.
@@ -439,8 +394,6 @@ static uint16_t denali_nand_timing_set(struct denali_nand_info *denali)
                        ioread32(denali->flash_reg + RDWR_EN_HI_CNT),
                        ioread32(denali->flash_reg + CS_SETUP_CNT));
 
-       find_valid_banks(denali);
-
        /*
         * If the user specified to override the default timings
         * with a specific ONFI mode, we apply those changes here.
index 352d8328b94af98faf02d336fe8047faf86a1532..0e4a8965f6f1d5469587e02abbabd189ce6a9195 100644 (file)
@@ -326,7 +326,6 @@ struct denali_nand_info {
        int platform;
        struct nand_buf buf;
        struct device *dev;
-       int total_used_banks;
        int page;
        void __iomem *flash_reg;        /* Register Interface */
        void __iomem *flash_mem;        /* Host Data/Command Interface */