mtd: merge MTD development from v4.4 into for-v4.5 development
authorBrian Norris <computersforpeace@gmail.com>
Wed, 6 Jan 2016 00:04:40 +0000 (16:04 -0800)
committerBrian Norris <computersforpeace@gmail.com>
Wed, 6 Jan 2016 00:05:56 +0000 (16:05 -0800)
Small conflict between some bugfixes for 4.4 and some refactoring for
4.5.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
1  2 
drivers/mtd/mtdcore.c
drivers/mtd/spi-nor/spi-nor.c
include/linux/mtd/spi-nor.h

index 89d811e7b04ab49d833a097e3e6ed8e3598557e5,ffa2884748205e26a376712c453b4fca5d3075bf..309625130b21b751e5fa42bb4693800a8327001b
@@@ -589,20 -590,22 +595,22 @@@ int mtd_device_parse_register(struct mt
                              const struct mtd_partition *parts,
                              int nr_parts)
  {
 +      struct mtd_partitions parsed;
        int ret;
 -      struct mtd_partition *real_parts = NULL;
  
 -      ret = parse_mtd_partitions(mtd, types, &real_parts, parser_data);
 -      if (ret <= 0 && nr_parts && parts) {
 -              real_parts = kmemdup(parts, sizeof(*parts) * nr_parts,
 -                                   GFP_KERNEL);
 -              if (!real_parts)
 -                      ret = -ENOMEM;
 -              else
 -                      ret = nr_parts;
 -      }
 -      /* Didn't come up with either parsed OR fallback partitions */
 -      if (ret < 0) {
+       mtd_set_dev_defaults(mtd);
 +      memset(&parsed, 0, sizeof(parsed));
 +
 +      ret = parse_mtd_partitions(mtd, types, &parsed, parser_data);
 +      if ((ret < 0 || parsed.nr_parts == 0) && parts && nr_parts) {
 +              /* Fall back to driver-provided partitions */
 +              parsed = (struct mtd_partitions){
 +                      .parts          = parts,
 +                      .nr_parts       = nr_parts,
 +              };
 +      } else if (ret < 0) {
 +              /* Didn't come up with parsed OR fallback partitions */
                pr_info("mtd: failed to find partitions; one or more parsers reports errors (%d)\n",
                        ret);
                /* Don't abort on errors; we can still use unpartitioned MTD */
index 7e5051e604b02c368cbea20a3609506917b00882,32477c4eb421390e250645f94b0eefdab871a043..f8f36d47575f138d751b38935921a95aa30ab686
@@@ -535,12 -514,10 +535,12 @@@ static int stm_unlock(struct spi_nor *n
        u8 shift = ffs(mask) - 1, pow, val;
  
        status_old = read_sr(nor);
 +      if (status_old < 0)
 +              return status_old;
  
        /* Cannot unlock; would unlock larger region than requested */
-       if (stm_is_locked_sr(nor, status_old, ofs - mtd->erasesize,
-                            mtd->erasesize))
+       if (stm_is_locked_sr(nor, ofs - mtd->erasesize, mtd->erasesize,
+                            status_old))
                return -EINVAL;
  
        /*
Simple merge