]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
Merge v4.4-rc1 into MTD development
authorBrian Norris <computersforpeace@gmail.com>
Mon, 16 Nov 2015 04:30:53 +0000 (20:30 -0800)
committerBrian Norris <computersforpeace@gmail.com>
Mon, 16 Nov 2015 04:31:29 +0000 (20:31 -0800)
Sync up with the upstream development.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
1  2 
drivers/mtd/devices/m25p80.c
drivers/mtd/devices/mtd_dataflash.c
drivers/mtd/mtdcore.c
drivers/staging/mt29f_spinand/mt29f_spinand.c

index 6dbf7832e77a3d76a863b77086d888520242dca6,fe9ceb7b5405adc029842ebc444e8c82e690ec89..f002a8f7537447bc0ec5d3f9e51a1f06acce38bc
@@@ -175,6 -175,7 +175,6 @@@ static int m25p80_erase(struct spi_nor 
   */
  static int m25p_probe(struct spi_device *spi)
  {
 -      struct mtd_part_parser_data     ppdata;
        struct flash_platform_data      *data;
        struct m25p *flash;
        struct spi_nor *nor;
        nor->read_reg = m25p80_read_reg;
  
        nor->dev = &spi->dev;
 -      nor->flash_node = spi->dev.of_node;
 +      spi_nor_set_flash_node(nor, spi->dev.of_node);
        nor->priv = flash;
  
        spi_set_drvdata(spi, flash);
        if (ret)
                return ret;
  
 -      ppdata.of_node = spi->dev.of_node;
 -
 -      return mtd_device_parse_register(&nor->mtd, NULL, &ppdata,
 -                      data ? data->parts : NULL,
 -                      data ? data->nr_parts : 0);
 +      return mtd_device_register(&nor->mtd, data ? data->parts : NULL,
 +                                 data ? data->nr_parts : 0);
  }
  
  
@@@ -297,7 -301,6 +297,6 @@@ MODULE_DEVICE_TABLE(of, m25p_of_table)
  static struct spi_driver m25p80_driver = {
        .driver = {
                .name   = "m25p80",
-               .owner  = THIS_MODULE,
                .of_match_table = m25p_of_table,
        },
        .id_table       = m25p_ids,
index 0ada3ed6c23fc527a566e0ff7f89089959945e29,e4a88715a844952b73a62bd5427af89b46935cd4..f9e9bd1cfaa034a4e79f0d4458ca90d47236a6f3
@@@ -624,6 -624,7 +624,6 @@@ static int add_dataflash_otp(struct spi
  {
        struct dataflash                *priv;
        struct mtd_info                 *device;
 -      struct mtd_part_parser_data     ppdata;
        struct flash_platform_data      *pdata = dev_get_platdata(&spi->dev);
        char                            *otp_tag = "";
        int                             err = 0;
        device->priv = priv;
  
        device->dev.parent = &spi->dev;
 +      mtd_set_of_node(device, spi->dev.of_node);
  
        if (revision >= 'c')
                otp_tag = otp_setup(device, revision);
                        pagesize, otp_tag);
        spi_set_drvdata(spi, priv);
  
 -      ppdata.of_node = spi->dev.of_node;
 -      err = mtd_device_parse_register(device, NULL, &ppdata,
 +      err = mtd_device_register(device,
                        pdata ? pdata->parts : NULL,
                        pdata ? pdata->nr_parts : 0);
  
@@@ -909,7 -910,6 +909,6 @@@ static int dataflash_remove(struct spi_
  static struct spi_driver dataflash_driver = {
        .driver = {
                .name           = "mtd_dataflash",
-               .owner          = THIS_MODULE,
                .of_match_table = of_match_ptr(dataflash_dt_ids),
        },
  
diff --combined drivers/mtd/mtdcore.c
index c393a115537643832c903a1ce9ba5f8249900aad,95c13b2ffa799e59f453e8a95813171cd56a13fc..62f83b05097843806dbe1965713882db07c360ec
@@@ -32,7 -32,6 +32,7 @@@
  #include <linux/err.h>
  #include <linux/ioctl.h>
  #include <linux/init.h>
 +#include <linux/of.h>
  #include <linux/proc_fs.h>
  #include <linux/idr.h>
  #include <linux/backing-dev.h>
@@@ -455,7 -454,6 +455,7 @@@ int add_mtd_device(struct mtd_info *mtd
        mtd->dev.devt = MTD_DEVT(i);
        dev_set_name(&mtd->dev, "mtd%d", i);
        dev_set_drvdata(&mtd->dev, mtd);
 +      of_node_get(mtd_get_of_node(mtd));
        error = device_register(&mtd->dev);
        if (error)
                goto fail_added;
        return 0;
  
  fail_added:
 +      of_node_put(mtd_get_of_node(mtd));
        idr_remove(&mtd_idr, i);
  fail_locked:
        mutex_unlock(&mtd_table_mutex);
@@@ -520,7 -517,6 +520,7 @@@ int del_mtd_device(struct mtd_info *mtd
                device_unregister(&mtd->dev);
  
                idr_remove(&mtd_idr, mtd->index);
 +              of_node_put(mtd_get_of_node(mtd));
  
                module_put(THIS_MODULE);
                ret = 0;
@@@ -1220,8 -1216,7 +1220,7 @@@ EXPORT_SYMBOL_GPL(mtd_writev)
   */
  void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size)
  {
-       gfp_t flags = __GFP_NOWARN | __GFP_WAIT |
-                      __GFP_NORETRY | __GFP_NO_KSWAPD;
+       gfp_t flags = __GFP_NOWARN | __GFP_DIRECT_RECLAIM | __GFP_NORETRY;
        size_t min_alloc = max_t(size_t, mtd->writesize, PAGE_SIZE);
        void *kbuf;
  
index 49807de7d91eb1a5860331cdc91907a61d96387e,47bb56f1f8c0d65c93aa5c50435f982603ed1a05..6536066b23490ac91e8504ddc71fab0e6f383b98
@@@ -145,7 -145,7 +145,7 @@@ static int spinand_read_id(struct spi_d
   *    Once the status turns to be ready, the other status bits also are
   *    valid status bits.
   */
- static int spinand_read_status(struct spi_device *spi_nand, uint8_t *status)
+ static int spinand_read_status(struct spi_device *spi_nand, u8 *status)
  {
        struct spinand_cmd cmd = {0};
        int ret;
@@@ -186,6 -186,7 +186,7 @@@ static int wait_till_ready(struct spi_d
  
        return -1;
  }
  /**
   * spinand_get_otp- send command 0xf to read the SPI Nand OTP register
   * Description:
@@@ -321,7 -322,7 +322,7 @@@ static int spinand_read_page_to_cache(s
   *   No tRd delay.
   */
  static int spinand_read_from_cache(struct spi_device *spi_nand, u16 page_id,
-               u16 byte_id, u16 len, u8 *rbuf)
+                                  u16 byte_id, u16 len, u8 *rbuf)
  {
        struct spinand_cmd cmd = {0};
        u16 column;
   *   Poll to read status to wait for tRD time.
   */
  static int spinand_read_page(struct spi_device *spi_nand, u16 page_id,
-               u16 offset, u16 len, u8 *rbuf)
+                            u16 offset, u16 len, u8 *rbuf)
  {
        int ret;
        u8 status = 0;
                ret = spinand_read_status(spi_nand, &status);
                if (ret < 0) {
                        dev_err(&spi_nand->dev,
-                                       "err %d read status register\n", ret);
+                               "err %d read status register\n", ret);
                        return ret;
                }
  
                if ((status & STATUS_OIP_MASK) == STATUS_READY) {
                        if ((status & STATUS_ECC_MASK) == STATUS_ECC_ERROR) {
                                dev_err(&spi_nand->dev, "ecc error, page=%d\n",
-                                               page_id);
+                                       page_id);
                                return 0;
                        }
                        break;
   *   Since it is writing the data to cache, there is no tPROG time.
   */
  static int spinand_program_data_to_cache(struct spi_device *spi_nand,
-               u16 page_id, u16 byte_id, u16 len, u8 *wbuf)
+                                        u16 page_id, u16 byte_id,
+                                        u16 len, u8 *wbuf)
  {
        struct spinand_cmd cmd = {0};
        u16 column;
@@@ -473,11 -475,11 +475,11 @@@ static int spinand_program_execute(stru
   *   Poll to wait for the tPROG time to finish the transaction.
   */
  static int spinand_program_page(struct spi_device *spi_nand,
-               u16 page_id, u16 offset, u16 len, u8 *buf)
+                               u16 page_id, u16 offset, u16 len, u8 *buf)
  {
        int retval;
        u8 status = 0;
-       uint8_t *wbuf;
+       u8 *wbuf;
  #ifdef CONFIG_MTD_SPINAND_ONDIEECC
        unsigned int i, j;
  
                dev_err(&spi_nand->dev, "wait timedout!!!\n");
  
        retval = spinand_program_data_to_cache(spi_nand, page_id,
-                       offset, len, wbuf);
+                                              offset, len, wbuf);
        if (retval < 0)
                return retval;
        retval = spinand_program_execute(spi_nand, page_id);
                retval = spinand_read_status(spi_nand, &status);
                if (retval < 0) {
                        dev_err(&spi_nand->dev,
-                                       "error %d reading status register\n",
-                                       retval);
+                               "error %d reading status register\n", retval);
                        return retval;
                }
  
@@@ -593,8 -594,7 +594,7 @@@ static int spinand_erase_block(struct s
                retval = spinand_read_status(spi_nand, &status);
                if (retval < 0) {
                        dev_err(&spi_nand->dev,
-                                       "error %d reading status register\n",
-                                       (int) retval);
+                               "error %d reading status register\n", retval);
                        return retval;
                }
  
  
  #ifdef CONFIG_MTD_SPINAND_ONDIEECC
  static int spinand_write_page_hwecc(struct mtd_info *mtd,
-               struct nand_chip *chip, const uint8_t *buf, int oob_required,
-               int page)
+                                   struct nand_chip *chip,
+                                   const u8 *buf, int oob_required,
+                                   int page)
  {
-       const uint8_t *p = buf;
+       const u8 *p = buf;
        int eccsize = chip->ecc.size;
        int eccsteps = chip->ecc.steps;
  
  }
  
  static int spinand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
-               uint8_t *buf, int oob_required, int page)
+                                  u8 *buf, int oob_required, int page)
  {
        int retval;
        u8 status;
-       uint8_t *p = buf;
+       u8 *p = buf;
        int eccsize = chip->ecc.size;
        int eccsteps = chip->ecc.steps;
        struct spinand_info *info = (struct spinand_info *)chip->priv;
                retval = spinand_read_status(info->spi, &status);
                if (retval < 0) {
                        dev_err(&mtd->dev,
-                                       "error %d reading status register\n",
-                                       retval);
+                               "error %d reading status register\n", retval);
                        return retval;
                }
  
                }
        }
        return 0;
  }
  #endif
  
@@@ -668,7 -667,7 +667,7 @@@ static void spinand_select_chip(struct 
  {
  }
  
- static uint8_t spinand_read_byte(struct mtd_info *mtd)
+ static u8 spinand_read_byte(struct mtd_info *mtd)
  {
        struct spinand_state *state = mtd_to_state(mtd);
        u8 data;
        return data;
  }
  
  static int spinand_wait(struct mtd_info *mtd, struct nand_chip *chip)
  {
        struct spinand_info *info = (struct spinand_info *)chip->priv;
                retval = spinand_read_status(info->spi, &status);
                if (retval < 0) {
                        dev_err(&mtd->dev,
-                                       "error %d reading status register\n",
-                                       retval);
+                               "error %d reading status register\n", retval);
                        return retval;
                }
  
        return 0;
  }
  
- static void spinand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
+ static void spinand_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
  {
        struct spinand_state *state = mtd_to_state(mtd);
  
        memcpy(state->buf + state->buf_ptr, buf, len);
        state->buf_ptr += len;
  }
  
- static void spinand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
+ static void spinand_read_buf(struct mtd_info *mtd, u8 *buf, int len)
  {
        struct spinand_state *state = mtd_to_state(mtd);
  
@@@ -739,14 -735,14 +735,14 @@@ static void spinand_reset(struct spi_de
                pr_info("spinand reset failed!\n");
  
        /* elapse 1ms before issuing any other command */
-       udelay(1000);
+       usleep_range(1000, 2000);
  
        if (wait_till_ready(spi_nand))
                dev_err(&spi_nand->dev, "wait timedout!\n");
  }
  
  static void spinand_cmdfunc(struct mtd_info *mtd, unsigned int command,
-               int column, int page)
+                           int column, int page)
  {
        struct nand_chip *chip = (struct nand_chip *)mtd->priv;
        struct spinand_info *info = (struct spinand_info *)chip->priv;
        /* PAGEPROG reuses all of the setup from SEQIN and adds the length */
        case NAND_CMD_PAGEPROG:
                spinand_program_page(info->spi, state->row, state->col,
-                               state->buf_ptr, state->buf);
+                                    state->buf_ptr, state->buf);
                break;
        case NAND_CMD_STATUS:
                spinand_get_otp(info->spi, state->buf);
                if (wait_till_ready(info->spi))
                        dev_err(&info->spi->dev, "WAIT timedout!!!\n");
                /* a minimum of 250us must elapse before issuing RESET cmd*/
-               udelay(250);
+               usleep_range(250, 1000);
                spinand_reset(info->spi);
                break;
        default:
@@@ -840,6 -836,7 +836,7 @@@ static int spinand_lock_block(struct sp
  
        return ret;
  }
  /*
   * spinand_probe - [spinand Interface]
   * @spi_nand: registered device driver.
@@@ -853,9 -850,10 +850,9 @@@ static int spinand_probe(struct spi_dev
        struct nand_chip *chip;
        struct spinand_info *info;
        struct spinand_state *state;
 -      struct mtd_part_parser_data ppdata;
  
        info  = devm_kzalloc(&spi_nand->dev, sizeof(struct spinand_info),
-                       GFP_KERNEL);
+                            GFP_KERNEL);
        if (!info)
                return -ENOMEM;
  
        spinand_lock_block(spi_nand, BL_ALL_UNLOCKED);
  
        state = devm_kzalloc(&spi_nand->dev, sizeof(struct spinand_state),
-                       GFP_KERNEL);
+                            GFP_KERNEL);
        if (!state)
                return -ENOMEM;
  
                return -ENOMEM;
  
        chip = devm_kzalloc(&spi_nand->dev, sizeof(struct nand_chip),
-                       GFP_KERNEL);
+                           GFP_KERNEL);
        if (!chip)
                return -ENOMEM;
  
                pr_info("%s: disable ecc failed!\n", __func__);
  #endif
  
 +      nand_set_flash_node(chip, spi_nand->dev.of_node);
        chip->priv      = info;
        chip->read_buf  = spinand_read_buf;
        chip->write_buf = spinand_write_buf;
        if (nand_scan(mtd, 1))
                return -ENXIO;
  
 -      ppdata.of_node = spi_nand->dev.of_node;
 -      return mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);
 +      return mtd_device_register(mtd, NULL, 0);
  }
  
  /*
@@@ -940,6 -938,7 +937,7 @@@ static const struct of_device_id spinan
        { .compatible = "spinand,mt29f", },
        {}
  };
+ MODULE_DEVICE_TABLE(of, spinand_dt);
  
  /*
   * Device name structure description
  static struct spi_driver spinand_driver = {
        .driver = {
                .name           = "mt29f",
-               .owner          = THIS_MODULE,
                .of_match_table = spinand_dt,
        },
        .probe          = spinand_probe,