Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'mtd/fixes-for-4.20-rc5' of git://git.infradead.org/linux-mtd

Pull mtd fixes from Boris Brezillon:
"NAND fix:
- Fix BBT cache allocation done in nanddev_bbt_init()

SPI NOR fixes:
- Fix the erase type selection logic"

* tag 'mtd/fixes-for-4.20-rc5' of git://git.infradead.org/linux-mtd:
mtd: nand: Fix memory allocation in nanddev_bbt_init()
mtd: spi-nor: fix erase_type array to indicate current map conf

+31 -3
+2 -1
drivers/mtd/nand/bbt.c
··· 27 27 unsigned int nwords = DIV_ROUND_UP(nblocks * bits_per_block, 28 28 BITS_PER_LONG); 29 29 30 - nand->bbt.cache = kzalloc(nwords, GFP_KERNEL); 30 + nand->bbt.cache = kcalloc(nwords, sizeof(*nand->bbt.cache), 31 + GFP_KERNEL); 31 32 if (!nand->bbt.cache) 32 33 return -ENOMEM; 33 34
+29 -2
drivers/mtd/spi-nor/spi-nor.c
··· 2995 2995 const u32 *smpt) 2996 2996 { 2997 2997 struct spi_nor_erase_map *map = &nor->erase_map; 2998 - const struct spi_nor_erase_type *erase = map->erase_type; 2998 + struct spi_nor_erase_type *erase = map->erase_type; 2999 2999 struct spi_nor_erase_region *region; 3000 3000 u64 offset; 3001 3001 u32 region_count; 3002 3002 int i, j; 3003 - u8 erase_type, uniform_erase_type; 3003 + u8 uniform_erase_type, save_uniform_erase_type; 3004 + u8 erase_type, regions_erase_type; 3004 3005 3005 3006 region_count = SMPT_MAP_REGION_COUNT(*smpt); 3006 3007 /* ··· 3015 3014 map->regions = region; 3016 3015 3017 3016 uniform_erase_type = 0xff; 3017 + regions_erase_type = 0; 3018 3018 offset = 0; 3019 3019 /* Populate regions. */ 3020 3020 for (i = 0; i < region_count; i++) { ··· 3032 3030 */ 3033 3031 uniform_erase_type &= erase_type; 3034 3032 3033 + /* 3034 + * regions_erase_type mask will indicate all the erase types 3035 + * supported in this configuration map. 3036 + */ 3037 + regions_erase_type |= erase_type; 3038 + 3035 3039 offset = (region[i].offset & ~SNOR_ERASE_FLAGS_MASK) + 3036 3040 region[i].size; 3037 3041 } 3038 3042 3043 + save_uniform_erase_type = map->uniform_erase_type; 3039 3044 map->uniform_erase_type = spi_nor_sort_erase_mask(map, 3040 3045 uniform_erase_type); 3046 + 3047 + if (!regions_erase_type) { 3048 + /* 3049 + * Roll back to the previous uniform_erase_type mask, SMPT is 3050 + * broken. 3051 + */ 3052 + map->uniform_erase_type = save_uniform_erase_type; 3053 + return -EINVAL; 3054 + } 3055 + 3056 + /* 3057 + * BFPT advertises all the erase types supported by all the possible 3058 + * map configurations. Mask out the erase types that are not supported 3059 + * by the current map configuration. 3060 + */ 3061 + for (i = 0; i < SNOR_ERASE_TYPE_MAX; i++) 3062 + if (!(regions_erase_type & BIT(erase[i].idx))) 3063 + spi_nor_set_erase_type(&erase[i], 0, 0xFF); 3041 3064 3042 3065 spi_nor_region_mark_end(&region[i - 1]); 3043 3066