diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-13 11:25:54 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-13 11:25:54 -0800 |
commit | ac53b2e053fffc74372da94e734b92f37e70d32c (patch) | |
tree | cda82af0fcded5d230e9f56104d3988b7a75c8aa /drivers/mtd/nand/docg4.c | |
parent | cf09112d160e6db21ff8427ce696f819b957423b (diff) | |
parent | 9146cbd52b11d4ade62dba8f238ec5e421c3fa2b (diff) |
Merge tag 'for-linus-20160112' of git://git.infradead.org/linux-mtd
Pull MTD updates from Brian Norris:
"Generic MTD:
- populate the MTD device 'of_node' field (and get a proper 'of_node'
symlink in sysfs)
This yielded some new helper functions, and changes across a
variety of drivers
- partitioning cleanups, to prepare for better device-tree based
partitioning in the future
Eliminate a lot of boilerplate for drivers that want to use
OF-based partition parsing
The DT bindings for this didn't settle yet, so most non-cleanup
portions are deferred for a future release
NAND:
- embed a struct mtd_info inside struct nand_chip
This is really long overdue; too many drivers have to do the same
silly boilerplate to allocate and link up two "independent"
structs, when in fact, everyone is assuming there is an exact 1:1
relationship between a NAND chips struct and its underlying MTD.
This aids improved helpers and should make certain abstractions
easier in the future.
Also causes a lot of churn, helped along by some automated code
transformations
- add more core support for detecting (and "correcting") bitflips in
erased pages; requires opt-in by drivers, but at least we kill a
few bad implementations and hopefully stave off future ones
- pxa3xx_nand: cleanups, a few fixes, and PM improvements
- new JZ4780 NAND driver
SPI NOR:
- provide default erase function, for controllers that just want to
send the SECTOR_ERASE command directly
- fix some module auto-loading issues with device tree
("jedec,spi-nor")
- error handling fixes
- new Mediatek QSPI flash driver
Other:
- cfi: force valid geometry Kconfig (finally!)
This one used to trip up randconfigs occasionally, since bots
aren't deterred by big scary "advanced configuration" menus
More? Probably. See the commit logs"
* tag 'for-linus-20160112' of git://git.infradead.org/linux-mtd: (168 commits)
mtd: jz4780_nand: replace if/else blocks with switch/case
mtd: nand: jz4780: Update ecc correction error codes
mtd: nandsim: use nand_get_controller_data()
mtd: jz4780_nand: remove useless mtd->priv = chip assignment
staging: mt29f_spinand: make use of nand_set/get_controller_data() helpers
mtd: nand: make use of nand_set/get_controller_data() helpers
ARM: make use of nand_set/get_controller_data() helpers
mtd: nand: add helpers to access ->priv
mtd: nand: jz4780: driver for NAND devices on JZ4780 SoCs
mtd: nand: jz4740: remove custom 'erased check' implementation
mtd: nand: diskonchip: remove custom 'erased check' implementation
mtd: nand: davinci: remove custom 'erased check' implementation
mtd: nand: use nand_check_erased_ecc_chunk in default ECC read functions
mtd: nand: return consistent error codes in ecc.correct() implementations
doc: dt: mtd: new binding for jz4780-{nand,bch}
mtd: cfi_cmdset_0001: fixing memory leak and handling failed kmalloc
mtd: spi-nor: wait until lock/unlock operations are ready
mtd: tests: consolidate kmalloc/memset 0 call to kzalloc
jffs2: use to_delayed_work
mtd: nand: assign reasonable default name for NAND drivers
...
Diffstat (limited to 'drivers/mtd/nand/docg4.c')
-rw-r--r-- | drivers/mtd/nand/docg4.c | 102 |
1 files changed, 49 insertions, 53 deletions
diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c index 408cf69b854b..df4165b02c62 100644 --- a/drivers/mtd/nand/docg4.c +++ b/drivers/mtd/nand/docg4.c @@ -242,7 +242,7 @@ static inline void write_nop(void __iomem *docptr) static void docg4_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) { int i; - struct nand_chip *nand = mtd->priv; + struct nand_chip *nand = mtd_to_nand(mtd); uint16_t *p = (uint16_t *) buf; len >>= 1; @@ -253,7 +253,7 @@ static void docg4_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) static void docg4_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len) { int i; - struct nand_chip *nand = mtd->priv; + struct nand_chip *nand = mtd_to_nand(mtd); uint16_t *p = (uint16_t *) buf; len >>= 1; @@ -297,7 +297,7 @@ static int poll_status(struct docg4_priv *doc) static int docg4_wait(struct mtd_info *mtd, struct nand_chip *nand) { - struct docg4_priv *doc = nand->priv; + struct docg4_priv *doc = nand_get_controller_data(nand); int status = NAND_STATUS_WP; /* inverse logic?? */ dev_dbg(doc->dev, "%s...\n", __func__); @@ -318,8 +318,8 @@ static void docg4_select_chip(struct mtd_info *mtd, int chip) * Select among multiple cascaded chips ("floors"). Multiple floors are * not yet supported, so the only valid non-negative value is 0. */ - struct nand_chip *nand = mtd->priv; - struct docg4_priv *doc = nand->priv; + struct nand_chip *nand = mtd_to_nand(mtd); + struct docg4_priv *doc = nand_get_controller_data(nand); void __iomem *docptr = doc->virtadr; dev_dbg(doc->dev, "%s: chip %d\n", __func__, chip); @@ -337,8 +337,8 @@ static void reset(struct mtd_info *mtd) { /* full device reset */ - struct nand_chip *nand = mtd->priv; - struct docg4_priv *doc = nand->priv; + struct nand_chip *nand = mtd_to_nand(mtd); + struct docg4_priv *doc = nand_get_controller_data(nand); void __iomem *docptr = doc->virtadr; writew(DOC_ASICMODE_RESET | DOC_ASICMODE_MDWREN, @@ -375,8 +375,8 @@ static int correct_data(struct mtd_info *mtd, uint8_t *buf, int page) * Up to four bitflips can be corrected. */ - struct nand_chip *nand = mtd->priv; - struct docg4_priv *doc = nand->priv; + struct nand_chip *nand = mtd_to_nand(mtd); + struct docg4_priv *doc = nand_get_controller_data(nand); void __iomem *docptr = doc->virtadr; int i, numerrs, errpos[4]; const uint8_t blank_read_hwecc[8] = { @@ -464,8 +464,8 @@ static int correct_data(struct mtd_info *mtd, uint8_t *buf, int page) static uint8_t docg4_read_byte(struct mtd_info *mtd) { - struct nand_chip *nand = mtd->priv; - struct docg4_priv *doc = nand->priv; + struct nand_chip *nand = mtd_to_nand(mtd); + struct docg4_priv *doc = nand_get_controller_data(nand); dev_dbg(doc->dev, "%s\n", __func__); @@ -545,8 +545,8 @@ static int pageprog(struct mtd_info *mtd) * internal buffer out to the flash array, or some such. */ - struct nand_chip *nand = mtd->priv; - struct docg4_priv *doc = nand->priv; + struct nand_chip *nand = mtd_to_nand(mtd); + struct docg4_priv *doc = nand_get_controller_data(nand); void __iomem *docptr = doc->virtadr; int retval = 0; @@ -582,8 +582,8 @@ static void sequence_reset(struct mtd_info *mtd) { /* common starting sequence for all operations */ - struct nand_chip *nand = mtd->priv; - struct docg4_priv *doc = nand->priv; + struct nand_chip *nand = mtd_to_nand(mtd); + struct docg4_priv *doc = nand_get_controller_data(nand); void __iomem *docptr = doc->virtadr; writew(DOC_CTRL_UNKNOWN | DOC_CTRL_CE, docptr + DOC_FLASHCONTROL); @@ -599,8 +599,8 @@ static void read_page_prologue(struct mtd_info *mtd, uint32_t docg4_addr) { /* first step in reading a page */ - struct nand_chip *nand = mtd->priv; - struct docg4_priv *doc = nand->priv; + struct nand_chip *nand = mtd_to_nand(mtd); + struct docg4_priv *doc = nand_get_controller_data(nand); void __iomem *docptr = doc->virtadr; dev_dbg(doc->dev, @@ -626,8 +626,8 @@ static void write_page_prologue(struct mtd_info *mtd, uint32_t docg4_addr) { /* first step in writing a page */ - struct nand_chip *nand = mtd->priv; - struct docg4_priv *doc = nand->priv; + struct nand_chip *nand = mtd_to_nand(mtd); + struct docg4_priv *doc = nand_get_controller_data(nand); void __iomem *docptr = doc->virtadr; dev_dbg(doc->dev, @@ -691,8 +691,8 @@ static void docg4_command(struct mtd_info *mtd, unsigned command, int column, { /* handle standard nand commands */ - struct nand_chip *nand = mtd->priv; - struct docg4_priv *doc = nand->priv; + struct nand_chip *nand = mtd_to_nand(mtd); + struct docg4_priv *doc = nand_get_controller_data(nand); uint32_t g4_addr = mtd_to_docg4_address(page_addr, column); dev_dbg(doc->dev, "%s %x, page_addr=%x, column=%x\n", @@ -756,7 +756,7 @@ static void docg4_command(struct mtd_info *mtd, unsigned command, int column, static int read_page(struct mtd_info *mtd, struct nand_chip *nand, uint8_t *buf, int page, bool use_ecc) { - struct docg4_priv *doc = nand->priv; + struct docg4_priv *doc = nand_get_controller_data(nand); void __iomem *docptr = doc->virtadr; uint16_t status, edc_err, *buf16; int bits_corrected = 0; @@ -836,7 +836,7 @@ static int docg4_read_page(struct mtd_info *mtd, struct nand_chip *nand, static int docg4_read_oob(struct mtd_info *mtd, struct nand_chip *nand, int page) { - struct docg4_priv *doc = nand->priv; + struct docg4_priv *doc = nand_get_controller_data(nand); void __iomem *docptr = doc->virtadr; uint16_t status; @@ -874,8 +874,8 @@ static int docg4_read_oob(struct mtd_info *mtd, struct nand_chip *nand, static int docg4_erase_block(struct mtd_info *mtd, int page) { - struct nand_chip *nand = mtd->priv; - struct docg4_priv *doc = nand->priv; + struct nand_chip *nand = mtd_to_nand(mtd); + struct docg4_priv *doc = nand_get_controller_data(nand); void __iomem *docptr = doc->virtadr; uint16_t g4_page; @@ -923,7 +923,7 @@ static int docg4_erase_block(struct mtd_info *mtd, int page) static int write_page(struct mtd_info *mtd, struct nand_chip *nand, const uint8_t *buf, bool use_ecc) { - struct docg4_priv *doc = nand->priv; + struct docg4_priv *doc = nand_get_controller_data(nand); void __iomem *docptr = doc->virtadr; uint8_t ecc_buf[8]; @@ -1003,7 +1003,7 @@ static int docg4_write_oob(struct mtd_info *mtd, struct nand_chip *nand, */ /* note that bytes 7..14 are hw generated hamming/ecc and overwritten */ - struct docg4_priv *doc = nand->priv; + struct docg4_priv *doc = nand_get_controller_data(nand); doc->oob_page = page; memcpy(doc->oob_buf, nand->oob_poi, 16); return 0; @@ -1016,8 +1016,8 @@ static int __init read_factory_bbt(struct mtd_info *mtd) * update the memory-based bbt accordingly. */ - struct nand_chip *nand = mtd->priv; - struct docg4_priv *doc = nand->priv; + struct nand_chip *nand = mtd_to_nand(mtd); + struct docg4_priv *doc = nand_get_controller_data(nand); uint32_t g4_addr = mtd_to_docg4_address(DOCG4_FACTORY_BBT_PAGE, 0); uint8_t *buf; int i, block; @@ -1089,8 +1089,8 @@ static int docg4_block_markbad(struct mtd_info *mtd, loff_t ofs) int ret, i; uint8_t *buf; - struct nand_chip *nand = mtd->priv; - struct docg4_priv *doc = nand->priv; + struct nand_chip *nand = mtd_to_nand(mtd); + struct docg4_priv *doc = nand_get_controller_data(nand); struct nand_bbt_descr *bbtd = nand->badblock_pattern; int page = (int)(ofs >> nand->page_shift); uint32_t g4_addr = mtd_to_docg4_address(page, 0); @@ -1202,8 +1202,8 @@ static void __init init_mtd_structs(struct mtd_info *mtd) * things as well, such as call nand_set_defaults(). */ - struct nand_chip *nand = mtd->priv; - struct docg4_priv *doc = nand->priv; + struct nand_chip *nand = mtd_to_nand(mtd); + struct docg4_priv *doc = nand_get_controller_data(nand); mtd->size = DOCG4_CHIP_SIZE; mtd->name = "Msys_Diskonchip_G4"; @@ -1261,8 +1261,8 @@ static void __init init_mtd_structs(struct mtd_info *mtd) static int __init read_id_reg(struct mtd_info *mtd) { - struct nand_chip *nand = mtd->priv; - struct docg4_priv *doc = nand->priv; + struct nand_chip *nand = mtd_to_nand(mtd); + struct docg4_priv *doc = nand_get_controller_data(nand); void __iomem *docptr = doc->virtadr; uint16_t id1, id2; @@ -1305,17 +1305,16 @@ static int __init probe_docg4(struct platform_device *pdev) return -EIO; } - len = sizeof(struct mtd_info) + sizeof(struct nand_chip) + - sizeof(struct docg4_priv); - mtd = kzalloc(len, GFP_KERNEL); - if (mtd == NULL) { + len = sizeof(struct nand_chip) + sizeof(struct docg4_priv); + nand = kzalloc(len, GFP_KERNEL); + if (nand == NULL) { retval = -ENOMEM; - goto fail; + goto fail_unmap; } - nand = (struct nand_chip *) (mtd + 1); + + mtd = nand_to_mtd(nand); doc = (struct docg4_priv *) (nand + 1); - mtd->priv = nand; - nand->priv = doc; + nand_set_controller_data(nand, doc); mtd->dev.parent = &pdev->dev; doc->virtadr = virtadr; doc->dev = dev; @@ -1353,16 +1352,13 @@ static int __init probe_docg4(struct platform_device *pdev) doc->mtd = mtd; return 0; - fail: +fail: + nand_release(mtd); /* deletes partitions and mtd devices */ + free_bch(doc->bch); + kfree(nand); + +fail_unmap: iounmap(virtadr); - if (mtd) { - /* re-declarations avoid compiler warning */ - struct nand_chip *nand = mtd->priv; - struct docg4_priv *doc = nand->priv; - nand_release(mtd); /* deletes partitions and mtd devices */ - free_bch(doc->bch); - kfree(mtd); - } return retval; } @@ -1372,7 +1368,7 @@ static int __exit cleanup_docg4(struct platform_device *pdev) struct docg4_priv *doc = platform_get_drvdata(pdev); nand_release(doc->mtd); free_bch(doc->bch); - kfree(doc->mtd); + kfree(mtd_to_nand(doc->mtd)); iounmap(doc->virtadr); return 0; } |