Merge tag 'for-linus-3.3' of git://git.infradead.org/~dwmw2/mtd-3.3
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 4 Feb 2012 15:17:47 +0000 (07:17 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 4 Feb 2012 15:17:47 +0000 (07:17 -0800)
 - Fix a regression in 16-bit Atmel NAND flash which was introduced in 3.1
 - Fix breakage with MTD suspend caused by the API rework
 - Fix a problem with resetting the MX28 BCH module
 - A couple of other trivial fixes

* tag 'for-linus-3.3-20120204' of git://git.infradead.org/~dwmw2/mtd-3.3:
  Revert "mtd: atmel_nand: optimize read/write buffer functions"
  mtd: fix MTD suspend
  jffs2: do not initialize variable unnecessarily
  mtd: gpmi-nand bugfix: reset the BCH module when it is not MX23
  mtd: nand: fix typo in comment

1  2 
drivers/mtd/nand/gpmi-nand/gpmi-lib.c
include/linux/mtd/mtd.h

@@@ -69,17 -69,19 +69,19 @@@ static int clear_poll_bit(void __iomem 
   *  [1] enable the module.
   *  [2] reset the module.
   *
-  * In most of the cases, it's ok. But there is a hardware bug in the BCH block.
+  * In most of the cases, it's ok.
+  * But in MX23, there is a hardware bug in the BCH block (see erratum #2847).
   * If you try to soft reset the BCH block, it becomes unusable until
   * the next hard reset. This case occurs in the NAND boot mode. When the board
   * boots by NAND, the ROM of the chip will initialize the BCH blocks itself.
   * So If the driver tries to reset the BCH again, the BCH will not work anymore.
-  * You will see a DMA timeout in this case.
+  * You will see a DMA timeout in this case. The bug has been fixed
+  * in the following chips, such as MX28.
   *
   * To avoid this bug, just add a new parameter `just_enable` for
   * the mxs_reset_block(), and rewrite it here.
   */
- int gpmi_reset_block(void __iomem *reset_addr, bool just_enable)
static int gpmi_reset_block(void __iomem *reset_addr, bool just_enable)
  {
        int ret;
        int timeout = 0x400;
@@@ -206,7 -208,15 +208,15 @@@ int bch_set_geometry(struct gpmi_nand_d
        if (ret)
                goto err_out;
  
-       ret = gpmi_reset_block(r->bch_regs, true);
+       /*
+       * Due to erratum #2847 of the MX23, the BCH cannot be soft reset on this
+       * chip, otherwise it will lock up. So we skip resetting BCH on the MX23.
+       * On the other hand, the MX28 needs the reset, because one case has been
+       * seen where the BCH produced ECC errors constantly after 10000
+       * consecutive reboots. The latter case has not been seen on the MX23 yet,
+       * still we don't know if it could happen there as well.
+       */
+       ret = gpmi_reset_block(r->bch_regs, GPMI_IS_MX23(this));
        if (ret)
                goto err_out;
  
@@@ -827,7 -837,7 +837,7 @@@ int gpmi_send_command(struct gpmi_nand_
        pio[1] = pio[2] = 0;
        desc = channel->device->device_prep_slave_sg(channel,
                                        (struct scatterlist *)pio,
 -                                      ARRAY_SIZE(pio), DMA_NONE, 0);
 +                                      ARRAY_SIZE(pio), DMA_TRANS_NONE, 0);
        if (!desc) {
                pr_err("step 1 error\n");
                return -1;
        sg_init_one(sgl, this->cmd_buffer, this->command_length);
        dma_map_sg(this->dev, sgl, 1, DMA_TO_DEVICE);
        desc = channel->device->device_prep_slave_sg(channel,
 -                                      sgl, 1, DMA_TO_DEVICE, 1);
 +                                      sgl, 1, DMA_MEM_TO_DEV, 1);
        if (!desc) {
                pr_err("step 2 error\n");
                return -1;
@@@ -872,7 -882,7 +882,7 @@@ int gpmi_send_data(struct gpmi_nand_dat
        pio[1] = 0;
        desc = channel->device->device_prep_slave_sg(channel,
                                        (struct scatterlist *)pio,
 -                                      ARRAY_SIZE(pio), DMA_NONE, 0);
 +                                      ARRAY_SIZE(pio), DMA_TRANS_NONE, 0);
        if (!desc) {
                pr_err("step 1 error\n");
                return -1;
        /* [2] send DMA request */
        prepare_data_dma(this, DMA_TO_DEVICE);
        desc = channel->device->device_prep_slave_sg(channel, &this->data_sgl,
 -                                              1, DMA_TO_DEVICE, 1);
 +                                              1, DMA_MEM_TO_DEV, 1);
        if (!desc) {
                pr_err("step 2 error\n");
                return -1;
@@@ -908,7 -918,7 +918,7 @@@ int gpmi_read_data(struct gpmi_nand_dat
        pio[1] = 0;
        desc = channel->device->device_prep_slave_sg(channel,
                                        (struct scatterlist *)pio,
 -                                      ARRAY_SIZE(pio), DMA_NONE, 0);
 +                                      ARRAY_SIZE(pio), DMA_TRANS_NONE, 0);
        if (!desc) {
                pr_err("step 1 error\n");
                return -1;
        /* [2] : send DMA request */
        prepare_data_dma(this, DMA_FROM_DEVICE);
        desc = channel->device->device_prep_slave_sg(channel, &this->data_sgl,
 -                                              1, DMA_FROM_DEVICE, 1);
 +                                              1, DMA_DEV_TO_MEM, 1);
        if (!desc) {
                pr_err("step 2 error\n");
                return -1;
@@@ -964,7 -974,7 +974,7 @@@ int gpmi_send_page(struct gpmi_nand_dat
  
        desc = channel->device->device_prep_slave_sg(channel,
                                        (struct scatterlist *)pio,
 -                                      ARRAY_SIZE(pio), DMA_NONE, 0);
 +                                      ARRAY_SIZE(pio), DMA_TRANS_NONE, 0);
        if (!desc) {
                pr_err("step 2 error\n");
                return -1;
@@@ -998,8 -1008,7 +1008,8 @@@ int gpmi_read_page(struct gpmi_nand_dat
                | BF_GPMI_CTRL0_XFER_COUNT(0);
        pio[1] = 0;
        desc = channel->device->device_prep_slave_sg(channel,
 -                              (struct scatterlist *)pio, 2, DMA_NONE, 0);
 +                              (struct scatterlist *)pio, 2,
 +                              DMA_TRANS_NONE, 0);
        if (!desc) {
                pr_err("step 1 error\n");
                return -1;
        pio[5] = auxiliary;
        desc = channel->device->device_prep_slave_sg(channel,
                                        (struct scatterlist *)pio,
 -                                      ARRAY_SIZE(pio), DMA_NONE, 1);
 +                                      ARRAY_SIZE(pio), DMA_TRANS_NONE, 1);
        if (!desc) {
                pr_err("step 2 error\n");
                return -1;
                | BF_GPMI_CTRL0_XFER_COUNT(geo->page_size);
        pio[1] = 0;
        desc = channel->device->device_prep_slave_sg(channel,
 -                              (struct scatterlist *)pio, 2, DMA_NONE, 1);
 +                              (struct scatterlist *)pio, 2,
 +                              DMA_TRANS_NONE, 1);
        if (!desc) {
                pr_err("step 3 error\n");
                return -1;
diff --combined include/linux/mtd/mtd.h
@@@ -427,9 -427,7 +427,7 @@@ static inline int mtd_is_locked(struct 
  
  static inline int mtd_suspend(struct mtd_info *mtd)
  {
-       if (!mtd->suspend)
-               return -EOPNOTSUPP;
-       return mtd->suspend(mtd);
+       return mtd->suspend ? mtd->suspend(mtd) : 0;
  }
  
  static inline void mtd_resume(struct mtd_info *mtd)
  static inline int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs)
  {
        if (!mtd->block_isbad)
 -              return -EOPNOTSUPP;
 +              return 0;
        return mtd->block_isbad(mtd, ofs);
  }