Skip to content

Commit 35c222f

Browse files
committed
Merge tag 'mtd/for-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux
Pull MTD updates from Miquel Raynal: "MTD core - block2mtd: page index should use pgoff_t - maps: physmap: minimal Runtime PM support - maps: pcmciamtd: avoid possible sleep-in-atomic-context bugs - concat: Fix a comment referring to an unknown symbol Raw NAND: - Macronix: Use match_string() helper - Atmel: switch to using devm_fwnode_gpiod_get() - Denali: rework the SKIP_BYTES feature and add reset controlling - Brcmnand: set appropriate DMA mask - Cadence: add unspecified HAS_IOMEM dependency - Various cleanup. Onenand: - Rename Samsung and Omap2 drivers to avoid possible build warnings - Enable compile testing - Various build issues - Kconfig cleanup SPI-NAND: - Support for Toshiba TC58CVG2S0HRAIJ SPI-NOR: - Add support for TB selection using SR bit 6, - Add support for few flashes" * tag 'mtd/for-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux: (41 commits) mtd: concat: Fix a comment referring to an unknown symbol mtd: rawnand: add unspecified HAS_IOMEM dependency mtd: block2mtd: page index should use pgoff_t mtd: maps: physmap: Add minimal Runtime PM support mtd: maps: pcmciamtd: fix possible sleep-in-atomic-context bugs in pcmciamtd_set_vpp() mtd: onenand: Rename omap2 driver to avoid a build warning mtd: onenand: Use a better name for samsung driver mtd: rawnand: atmel: switch to using devm_fwnode_gpiod_get() mtd: spinand: add support for Toshiba TC58CVG2S0HRAIJ mtd: rawnand: macronix: Use match_string() helper to simplify the code mtd: sharpslpart: Fix unsigned comparison to zero mtd: onenand: Enable compile testing of OMAP and Samsung drivers mtd: onenand: samsung: Fix printing format for size_t on 64-bit mtd: onenand: samsung: Fix pointer cast -Wpointer-to-int-cast warnings on 64 bit mtd: rawnand: denali: remove hard-coded DENALI_DEFAULT_OOB_SKIP_BYTES mtd: rawnand: denali_dt: add reset controlling dt-bindings: mtd: denali_dt: document reset property mtd: rawnand: denali_dt: Add support for configuring SPARE_AREA_SKIP_BYTES mtd: rawnand: denali_dt: error out if platform has no associated data mtd: rawnand: brcmnand: Set appropriate DMA mask ...
2 parents e84bcd6 + 4575243 commit 35c222f

26 files changed

Lines changed: 286 additions & 162 deletions

‎Documentation/devicetree/bindings/mtd/denali-nand.txt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ Required properties:
1414
interface clock, and the ECC circuit clock.
1515
- clock-names: should contain "nand", "nand_x", "ecc"
1616

17+
Optional properties:
18+
- resets: may contain phandles to the controller core reset, the register
19+
reset
20+
- reset-names: may contain "nand", "reg"
21+
1722
Sub-nodes:
1823
Sub-nodes represent available NAND chips.
1924

@@ -46,6 +51,8 @@ nand: nand@ff900000 {
4651
reg-names = "nand_data", "denali_reg";
4752
clocks = <&nand_clk>, <&nand_x_clk>, <&nand_ecc_clk>;
4853
clock-names = "nand", "nand_x", "ecc";
54+
resets = <&nand_rst>, <&nand_reg_rst>;
55+
reset-names = "nand", "reg";
4956
interrupts = <0 144 4>;
5057

5158
nand@0 {

‎drivers/mtd/devices/block2mtd.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct block2mtd_dev {
4444
static LIST_HEAD(blkmtd_device_list);
4545

4646

47-
static struct page *page_read(struct address_space *mapping, int index)
47+
static struct page *page_read(struct address_space *mapping, pgoff_t index)
4848
{
4949
return read_mapping_page(mapping, index, NULL);
5050
}
@@ -54,7 +54,7 @@ static int _block2mtd_erase(struct block2mtd_dev *dev, loff_t to, size_t len)
5454
{
5555
struct address_space *mapping = dev->blkdev->bd_inode->i_mapping;
5656
struct page *page;
57-
int index = to >> PAGE_SHIFT; // page index
57+
pgoff_t index = to >> PAGE_SHIFT; // page index
5858
int pages = len >> PAGE_SHIFT;
5959
u_long *p;
6060
u_long *max;
@@ -103,7 +103,7 @@ static int block2mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
103103
{
104104
struct block2mtd_dev *dev = mtd->priv;
105105
struct page *page;
106-
int index = from >> PAGE_SHIFT;
106+
pgoff_t index = from >> PAGE_SHIFT;
107107
int offset = from & (PAGE_SIZE-1);
108108
int cpylen;
109109

@@ -137,7 +137,7 @@ static int _block2mtd_write(struct block2mtd_dev *dev, const u_char *buf,
137137
{
138138
struct page *page;
139139
struct address_space *mapping = dev->blkdev->bd_inode->i_mapping;
140-
int index = to >> PAGE_SHIFT; // page index
140+
pgoff_t index = to >> PAGE_SHIFT; // page index
141141
int offset = to & ~PAGE_MASK; // page offset
142142
int cpylen;
143143

‎drivers/mtd/maps/pcmciamtd.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,24 +294,23 @@ static void pcmcia_copy_to(struct map_info *map, unsigned long to, const void *f
294294
}
295295

296296

297-
static DEFINE_SPINLOCK(pcmcia_vpp_lock);
297+
static DEFINE_MUTEX(pcmcia_vpp_lock);
298298
static int pcmcia_vpp_refcnt;
299299
static void pcmciamtd_set_vpp(struct map_info *map, int on)
300300
{
301301
struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
302302
struct pcmcia_device *link = dev->p_dev;
303-
unsigned long flags;
304303

305304
pr_debug("dev = %p on = %d vpp = %d\n\n", dev, on, dev->vpp);
306-
spin_lock_irqsave(&pcmcia_vpp_lock, flags);
305+
mutex_lock(&pcmcia_vpp_lock);
307306
if (on) {
308307
if (++pcmcia_vpp_refcnt == 1) /* first nested 'on' */
309308
pcmcia_fixup_vpp(link, dev->vpp);
310309
} else {
311310
if (--pcmcia_vpp_refcnt == 0) /* last nested 'off' */
312311
pcmcia_fixup_vpp(link, 0);
313312
}
314-
spin_unlock_irqrestore(&pcmcia_vpp_lock, flags);
313+
mutex_unlock(&pcmcia_vpp_lock);
315314
}
316315

317316

‎drivers/mtd/maps/physmap-core.c‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <linux/mtd/cfi_endian.h>
3939
#include <linux/io.h>
4040
#include <linux/of_device.h>
41+
#include <linux/pm_runtime.h>
4142
#include <linux/gpio/consumer.h>
4243

4344
#include "physmap-gemini.h"
@@ -64,16 +65,16 @@ static int physmap_flash_remove(struct platform_device *dev)
6465
{
6566
struct physmap_flash_info *info;
6667
struct physmap_flash_data *physmap_data;
67-
int i, err;
68+
int i, err = 0;
6869

6970
info = platform_get_drvdata(dev);
7071
if (!info)
71-
return 0;
72+
goto out;
7273

7374
if (info->cmtd) {
7475
err = mtd_device_unregister(info->cmtd);
7576
if (err)
76-
return err;
77+
goto out;
7778

7879
if (info->cmtd != info->mtds[0])
7980
mtd_concat_destroy(info->cmtd);
@@ -88,7 +89,10 @@ static int physmap_flash_remove(struct platform_device *dev)
8889
if (physmap_data && physmap_data->exit)
8990
physmap_data->exit(dev);
9091

91-
return 0;
92+
out:
93+
pm_runtime_put(&dev->dev);
94+
pm_runtime_disable(&dev->dev);
95+
return err;
9296
}
9397

9498
static void physmap_set_vpp(struct map_info *map, int state)
@@ -484,13 +488,19 @@ static int physmap_flash_probe(struct platform_device *dev)
484488
return -EINVAL;
485489
}
486490

491+
pm_runtime_enable(&dev->dev);
492+
pm_runtime_get_sync(&dev->dev);
493+
487494
if (dev->dev.of_node)
488495
err = physmap_flash_of_init(dev);
489496
else
490497
err = physmap_flash_pdata_init(dev);
491498

492-
if (err)
499+
if (err) {
500+
pm_runtime_put(&dev->dev);
501+
pm_runtime_disable(&dev->dev);
493502
return err;
503+
}
494504

495505
for (i = 0; i < info->nmaps; i++) {
496506
struct resource *res;

‎drivers/mtd/mtdconcat.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
841841
return &concat->mtd;
842842
}
843843

844-
/*
845-
* This function destroys an MTD object obtained from concat_mtd_devs()
846-
*/
847-
844+
/* Cleans the context obtained from mtd_concat_create() */
848845
void mtd_concat_destroy(struct mtd_info *mtd)
849846
{
850847
struct mtd_concat *concat = CONCAT(mtd);

‎drivers/mtd/nand/onenand/Kconfig‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@ config MTD_ONENAND_GENERIC
2525

2626
config MTD_ONENAND_OMAP2
2727
tristate "OneNAND on OMAP2/OMAP3 support"
28-
depends on ARCH_OMAP2 || ARCH_OMAP3
28+
depends on ARCH_OMAP2 || ARCH_OMAP3 || (COMPILE_TEST && ARM)
2929
depends on OF || COMPILE_TEST
3030
help
3131
Support for a OneNAND flash device connected to an OMAP2/OMAP3 SoC
3232
via the GPMC memory controller.
3333
Enable dmaengine and gpiolib for better performance.
3434

3535
config MTD_ONENAND_SAMSUNG
36-
tristate "OneNAND on Samsung SOC controller support"
37-
depends on ARCH_S3C64XX || ARCH_S5PV210 || ARCH_EXYNOS4
38-
help
39-
Support for a OneNAND flash device connected to an Samsung SOC.
40-
S3C64XX uses command mapping method.
41-
S5PC110/S5PC210 use generic OneNAND method.
36+
tristate "OneNAND on Samsung SOC controller support"
37+
depends on ARCH_S3C64XX || ARCH_S5PV210 || ARCH_EXYNOS4 || COMPILE_TEST
38+
help
39+
Support for a OneNAND flash device connected to an Samsung SOC.
40+
S3C64XX uses command mapping method.
41+
S5PC110/S5PC210 use generic OneNAND method.
4242

4343
config MTD_ONENAND_OTP
4444
bool "OneNAND OTP Support"

‎drivers/mtd/nand/onenand/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ obj-$(CONFIG_MTD_ONENAND) += onenand.o
88

99
# Board specific.
1010
obj-$(CONFIG_MTD_ONENAND_GENERIC) += generic.o
11-
obj-$(CONFIG_MTD_ONENAND_OMAP2) += omap2.o
12-
obj-$(CONFIG_MTD_ONENAND_SAMSUNG) += samsung_mtd.o
11+
obj-$(CONFIG_MTD_ONENAND_OMAP2) += onenand_omap2.o
12+
obj-$(CONFIG_MTD_ONENAND_SAMSUNG) += onenand_samsung.o
1313

1414
onenand-objs = onenand_base.o onenand_bbt.o

‎drivers/mtd/nand/onenand/onenand_base.c‎

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,44 +1248,44 @@ static int onenand_read_ops_nolock(struct mtd_info *mtd, loff_t from,
12481248

12491249
stats = mtd->ecc_stats;
12501250

1251-
/* Read-while-load method */
1251+
/* Read-while-load method */
12521252

1253-
/* Do first load to bufferRAM */
1254-
if (read < len) {
1255-
if (!onenand_check_bufferram(mtd, from)) {
1253+
/* Do first load to bufferRAM */
1254+
if (read < len) {
1255+
if (!onenand_check_bufferram(mtd, from)) {
12561256
this->command(mtd, ONENAND_CMD_READ, from, writesize);
1257-
ret = this->wait(mtd, FL_READING);
1258-
onenand_update_bufferram(mtd, from, !ret);
1257+
ret = this->wait(mtd, FL_READING);
1258+
onenand_update_bufferram(mtd, from, !ret);
12591259
if (mtd_is_eccerr(ret))
12601260
ret = 0;
1261-
}
1262-
}
1261+
}
1262+
}
12631263

12641264
thislen = min_t(int, writesize, len - read);
12651265
column = from & (writesize - 1);
12661266
if (column + thislen > writesize)
12671267
thislen = writesize - column;
12681268

1269-
while (!ret) {
1270-
/* If there is more to load then start next load */
1271-
from += thislen;
1272-
if (read + thislen < len) {
1269+
while (!ret) {
1270+
/* If there is more to load then start next load */
1271+
from += thislen;
1272+
if (read + thislen < len) {
12731273
this->command(mtd, ONENAND_CMD_READ, from, writesize);
1274-
/*
1275-
* Chip boundary handling in DDP
1276-
* Now we issued chip 1 read and pointed chip 1
1274+
/*
1275+
* Chip boundary handling in DDP
1276+
* Now we issued chip 1 read and pointed chip 1
12771277
* bufferram so we have to point chip 0 bufferram.
1278-
*/
1279-
if (ONENAND_IS_DDP(this) &&
1280-
unlikely(from == (this->chipsize >> 1))) {
1281-
this->write_word(ONENAND_DDP_CHIP0, this->base + ONENAND_REG_START_ADDRESS2);
1282-
boundary = 1;
1283-
} else
1284-
boundary = 0;
1285-
ONENAND_SET_PREV_BUFFERRAM(this);
1286-
}
1287-
/* While load is going, read from last bufferRAM */
1288-
this->read_bufferram(mtd, ONENAND_DATARAM, buf, column, thislen);
1278+
*/
1279+
if (ONENAND_IS_DDP(this) &&
1280+
unlikely(from == (this->chipsize >> 1))) {
1281+
this->write_word(ONENAND_DDP_CHIP0, this->base + ONENAND_REG_START_ADDRESS2);
1282+
boundary = 1;
1283+
} else
1284+
boundary = 0;
1285+
ONENAND_SET_PREV_BUFFERRAM(this);
1286+
}
1287+
/* While load is going, read from last bufferRAM */
1288+
this->read_bufferram(mtd, ONENAND_DATARAM, buf, column, thislen);
12891289

12901290
/* Read oob area if needed */
12911291
if (oobbuf) {
@@ -1301,24 +1301,24 @@ static int onenand_read_ops_nolock(struct mtd_info *mtd, loff_t from,
13011301
oobcolumn = 0;
13021302
}
13031303

1304-
/* See if we are done */
1305-
read += thislen;
1306-
if (read == len)
1307-
break;
1308-
/* Set up for next read from bufferRAM */
1309-
if (unlikely(boundary))
1310-
this->write_word(ONENAND_DDP_CHIP1, this->base + ONENAND_REG_START_ADDRESS2);
1311-
ONENAND_SET_NEXT_BUFFERRAM(this);
1312-
buf += thislen;
1304+
/* See if we are done */
1305+
read += thislen;
1306+
if (read == len)
1307+
break;
1308+
/* Set up for next read from bufferRAM */
1309+
if (unlikely(boundary))
1310+
this->write_word(ONENAND_DDP_CHIP1, this->base + ONENAND_REG_START_ADDRESS2);
1311+
ONENAND_SET_NEXT_BUFFERRAM(this);
1312+
buf += thislen;
13131313
thislen = min_t(int, writesize, len - read);
1314-
column = 0;
1315-
cond_resched();
1316-
/* Now wait for load */
1317-
ret = this->wait(mtd, FL_READING);
1318-
onenand_update_bufferram(mtd, from, !ret);
1314+
column = 0;
1315+
cond_resched();
1316+
/* Now wait for load */
1317+
ret = this->wait(mtd, FL_READING);
1318+
onenand_update_bufferram(mtd, from, !ret);
13191319
if (mtd_is_eccerr(ret))
13201320
ret = 0;
1321-
}
1321+
}
13221322

13231323
/*
13241324
* Return success, if no ECC failures, else -EBADMSG

drivers/mtd/nand/onenand/samsung_mtd.c renamed to drivers/mtd/nand/onenand/onenand_samsung.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ static unsigned short s3c_onenand_readw(void __iomem *addr)
248248
}
249249

250250
/* BootRAM access control */
251-
if ((unsigned int) addr < ONENAND_DATARAM && onenand->bootram_command) {
251+
if ((unsigned long)addr < ONENAND_DATARAM && onenand->bootram_command) {
252252
if (word_addr == 0)
253253
return s3c_read_reg(MANUFACT_ID_OFFSET);
254254
if (word_addr == 1)
@@ -289,7 +289,7 @@ static void s3c_onenand_writew(unsigned short value, void __iomem *addr)
289289
}
290290

291291
/* BootRAM access control */
292-
if ((unsigned int)addr < ONENAND_DATARAM) {
292+
if ((unsigned long)addr < ONENAND_DATARAM) {
293293
if (value == ONENAND_CMD_READID) {
294294
onenand->bootram_command = 1;
295295
return;
@@ -658,7 +658,7 @@ static int s5pc110_read_bufferram(struct mtd_info *mtd, int area,
658658
dma_dst = dma_map_single(dev, buf, count, DMA_FROM_DEVICE);
659659
}
660660
if (dma_mapping_error(dev, dma_dst)) {
661-
dev_err(dev, "Couldn't map a %d byte buffer for DMA\n", count);
661+
dev_err(dev, "Couldn't map a %zu byte buffer for DMA\n", count);
662662
goto normal;
663663
}
664664
err = s5pc110_dma_ops(dma_dst, dma_src,
@@ -728,13 +728,12 @@ static void s3c_onenand_check_lock_status(struct mtd_info *mtd)
728728
struct onenand_chip *this = mtd->priv;
729729
struct device *dev = &onenand->pdev->dev;
730730
unsigned int block, end;
731-
int tmp;
732731

733732
end = this->chipsize >> this->erase_shift;
734733

735734
for (block = 0; block < end; block++) {
736735
unsigned int mem_addr = onenand->mem_addr(block, 0, 0);
737-
tmp = s3c_read_cmd(CMD_MAP_01(onenand, mem_addr));
736+
s3c_read_cmd(CMD_MAP_01(onenand, mem_addr));
738737

739738
if (s3c_read_reg(INT_ERR_STAT_OFFSET) & LOCKED_BLK) {
740739
dev_err(dev, "block %d is write-protected!\n", block);

0 commit comments

Comments
 (0)