Skip to content

Commit d50ffc5

Browse files
committed
Merge tag 'mtd/fixes-for-4.20-rc2' of git://git.infradead.org/linux-mtd
Pull MTD fixes from Boris Brezillon: "MTD changes: - Kill a VLA in sa1100 SPI NOR changes: - Make sure ->addr_width is restored when SFDP parsing fails - Propate errors happening in cqspi_direct_read_execute() NAND changes: - Fix kernel-doc mismatch - Fix nanddev_neraseblocks() to return the correct value - Avoid selection of BCH_CONST_PARAMS when some users require dynamic BCH settings" * tag 'mtd/fixes-for-4.20-rc2' of git://git.infradead.org/linux-mtd: mtd: nand: Fix nanddev_pos_next_page() kernel-doc header mtd: sa1100: avoid VLA in sa1100_setup_mtd mtd: spi-nor: Reset nor->addr_width when SFDP parsing failed mtd: spi-nor: cadence-quadspi: Return error code in cqspi_direct_read_execute() mtd: nand: Fix nanddev_neraseblocks() mtd: nand: drop kernel-doc notation for a deleted function parameter mtd: docg3: don't set conflicting BCH_CONST_PARAMS option
2 parents 8575877 + 98ee3fc commit d50ffc5

File tree

6 files changed

+18
-10
lines changed

6 files changed

+18
-10
lines changed

drivers/mtd/devices/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ comment "Disk-On-Chip Device Drivers"
207207
config MTD_DOCG3
208208
tristate "M-Systems Disk-On-Chip G3"
209209
select BCH
210-
select BCH_CONST_PARAMS
210+
select BCH_CONST_PARAMS if !MTD_NAND_BCH
211211
select BITREVERSE
212212
help
213213
This provides an MTD device driver for the M-Systems DiskOnChip

drivers/mtd/maps/sa1100-flash.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,14 @@ static struct sa_info *sa1100_setup_mtd(struct platform_device *pdev,
221221
info->mtd = info->subdev[0].mtd;
222222
ret = 0;
223223
} else if (info->num_subdev > 1) {
224-
struct mtd_info *cdev[nr];
224+
struct mtd_info **cdev;
225+
226+
cdev = kmalloc_array(nr, sizeof(*cdev), GFP_KERNEL);
227+
if (!cdev) {
228+
ret = -ENOMEM;
229+
goto err;
230+
}
231+
225232
/*
226233
* We detected multiple devices. Concatenate them together.
227234
*/
@@ -230,6 +237,7 @@ static struct sa_info *sa1100_setup_mtd(struct platform_device *pdev,
230237

231238
info->mtd = mtd_concat_create(cdev, info->num_subdev,
232239
plat->name);
240+
kfree(cdev);
233241
if (info->mtd == NULL) {
234242
ret = -ENXIO;
235243
goto err;

drivers/mtd/nand/raw/nand_base.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,6 @@ nand_get_device(struct mtd_info *mtd, int new_state)
590590

591591
/**
592592
* panic_nand_wait - [GENERIC] wait until the command is done
593-
* @mtd: MTD device structure
594593
* @chip: NAND chip structure
595594
* @timeo: timeout
596595
*

drivers/mtd/spi-nor/cadence-quadspi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ static int cqspi_direct_read_execute(struct spi_nor *nor, u_char *buf,
996996
err_unmap:
997997
dma_unmap_single(nor->dev, dma_dst, len, DMA_FROM_DEVICE);
998998

999-
return 0;
999+
return ret;
10001000
}
10011001

10021002
static ssize_t cqspi_read(struct spi_nor *nor, loff_t from,

drivers/mtd/spi-nor/spi-nor.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3250,12 +3250,14 @@ static int spi_nor_init_params(struct spi_nor *nor,
32503250
memcpy(&sfdp_params, params, sizeof(sfdp_params));
32513251
memcpy(&prev_map, &nor->erase_map, sizeof(prev_map));
32523252

3253-
if (spi_nor_parse_sfdp(nor, &sfdp_params))
3253+
if (spi_nor_parse_sfdp(nor, &sfdp_params)) {
3254+
nor->addr_width = 0;
32543255
/* restore previous erase map */
32553256
memcpy(&nor->erase_map, &prev_map,
32563257
sizeof(nor->erase_map));
3257-
else
3258+
} else {
32583259
memcpy(params, &sfdp_params, sizeof(*params));
3260+
}
32593261
}
32603262

32613263
return 0;

include/linux/mtd/nand.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,8 @@ static inline unsigned int nanddev_ntargets(const struct nand_device *nand)
324324
*/
325325
static inline unsigned int nanddev_neraseblocks(const struct nand_device *nand)
326326
{
327-
return (u64)nand->memorg.luns_per_target *
328-
nand->memorg.eraseblocks_per_lun *
329-
nand->memorg.pages_per_eraseblock;
327+
return nand->memorg.ntargets * nand->memorg.luns_per_target *
328+
nand->memorg.eraseblocks_per_lun;
330329
}
331330

332331
/**
@@ -569,7 +568,7 @@ static inline void nanddev_pos_next_eraseblock(struct nand_device *nand,
569568
}
570569

571570
/**
572-
* nanddev_pos_next_eraseblock() - Move a position to the next page
571+
* nanddev_pos_next_page() - Move a position to the next page
573572
* @nand: NAND device
574573
* @pos: the position to update
575574
*

0 commit comments

Comments
 (0)