diff options
author | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-03-25 03:53:42 -0300 |
---|---|---|
committer | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-03-25 03:53:42 -0300 |
commit | 03dd4cb26d967f9588437b0fc9cc0e8353322bb7 (patch) | |
tree | fa581f6dc1c0596391690d1f67eceef3af8246dc /drivers/mtd/nand/fsmc_nand.c | |
parent | d4e493caf788ef44982e131ff9c786546904d934 (diff) |
Linux-libre 4.5-gnu
Diffstat (limited to 'drivers/mtd/nand/fsmc_nand.c')
-rw-r--r-- | drivers/mtd/nand/fsmc_nand.c | 69 |
1 files changed, 31 insertions, 38 deletions
diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c index 07af3dc7a..1bdcd4fa2 100644 --- a/drivers/mtd/nand/fsmc_nand.c +++ b/drivers/mtd/nand/fsmc_nand.c @@ -299,7 +299,6 @@ static struct fsmc_eccplace fsmc_ecc4_sp_place = { */ struct fsmc_nand_data { u32 pid; - struct mtd_info mtd; struct nand_chip nand; struct mtd_partition *partitions; unsigned int nr_partitions; @@ -326,13 +325,18 @@ struct fsmc_nand_data { void (*select_chip)(uint32_t bank, uint32_t busw); }; +static inline struct fsmc_nand_data *mtd_to_fsmc(struct mtd_info *mtd) +{ + return container_of(mtd_to_nand(mtd), struct fsmc_nand_data, nand); +} + /* Assert CS signal based on chipnr */ static void fsmc_select_chip(struct mtd_info *mtd, int chipnr) { - struct nand_chip *chip = mtd->priv; + struct nand_chip *chip = mtd_to_nand(mtd); struct fsmc_nand_data *host; - host = container_of(mtd, struct fsmc_nand_data, mtd); + host = mtd_to_fsmc(mtd); switch (chipnr) { case -1: @@ -358,9 +362,8 @@ static void fsmc_select_chip(struct mtd_info *mtd, int chipnr) */ static void fsmc_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) { - struct nand_chip *this = mtd->priv; - struct fsmc_nand_data *host = container_of(mtd, - struct fsmc_nand_data, mtd); + struct nand_chip *this = mtd_to_nand(mtd); + struct fsmc_nand_data *host = mtd_to_fsmc(mtd); void __iomem *regs = host->regs_va; unsigned int bank = host->bank; @@ -445,8 +448,7 @@ static void fsmc_nand_setup(void __iomem *regs, uint32_t bank, */ static void fsmc_enable_hwecc(struct mtd_info *mtd, int mode) { - struct fsmc_nand_data *host = container_of(mtd, - struct fsmc_nand_data, mtd); + struct fsmc_nand_data *host = mtd_to_fsmc(mtd); void __iomem *regs = host->regs_va; uint32_t bank = host->bank; @@ -466,8 +468,7 @@ static void fsmc_enable_hwecc(struct mtd_info *mtd, int mode) static int fsmc_read_hwecc_ecc4(struct mtd_info *mtd, const uint8_t *data, uint8_t *ecc) { - struct fsmc_nand_data *host = container_of(mtd, - struct fsmc_nand_data, mtd); + struct fsmc_nand_data *host = mtd_to_fsmc(mtd); void __iomem *regs = host->regs_va; uint32_t bank = host->bank; uint32_t ecc_tmp; @@ -517,8 +518,7 @@ static int fsmc_read_hwecc_ecc4(struct mtd_info *mtd, const uint8_t *data, static int fsmc_read_hwecc_ecc1(struct mtd_info *mtd, const uint8_t *data, uint8_t *ecc) { - struct fsmc_nand_data *host = container_of(mtd, - struct fsmc_nand_data, mtd); + struct fsmc_nand_data *host = mtd_to_fsmc(mtd); void __iomem *regs = host->regs_va; uint32_t bank = host->bank; uint32_t ecc_tmp; @@ -629,7 +629,7 @@ unmap_dma: static void fsmc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) { int i; - struct nand_chip *chip = mtd->priv; + struct nand_chip *chip = mtd_to_nand(mtd); if (IS_ALIGNED((uint32_t)buf, sizeof(uint32_t)) && IS_ALIGNED(len, sizeof(uint32_t))) { @@ -652,7 +652,7 @@ static void fsmc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) static void fsmc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) { int i; - struct nand_chip *chip = mtd->priv; + struct nand_chip *chip = mtd_to_nand(mtd); if (IS_ALIGNED((uint32_t)buf, sizeof(uint32_t)) && IS_ALIGNED(len, sizeof(uint32_t))) { @@ -674,9 +674,8 @@ static void fsmc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) */ static void fsmc_read_buf_dma(struct mtd_info *mtd, uint8_t *buf, int len) { - struct fsmc_nand_data *host; + struct fsmc_nand_data *host = mtd_to_fsmc(mtd); - host = container_of(mtd, struct fsmc_nand_data, mtd); dma_xfer(host, buf, len, DMA_FROM_DEVICE); } @@ -689,9 +688,8 @@ static void fsmc_read_buf_dma(struct mtd_info *mtd, uint8_t *buf, int len) static void fsmc_write_buf_dma(struct mtd_info *mtd, const uint8_t *buf, int len) { - struct fsmc_nand_data *host; + struct fsmc_nand_data *host = mtd_to_fsmc(mtd); - host = container_of(mtd, struct fsmc_nand_data, mtd); dma_xfer(host, (void *)buf, len, DMA_TO_DEVICE); } @@ -712,8 +710,7 @@ static void fsmc_write_buf_dma(struct mtd_info *mtd, const uint8_t *buf, static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf, int oob_required, int page) { - struct fsmc_nand_data *host = container_of(mtd, - struct fsmc_nand_data, mtd); + struct fsmc_nand_data *host = mtd_to_fsmc(mtd); struct fsmc_eccplace *ecc_place = host->ecc_place; int i, j, s, stat, eccsize = chip->ecc.size; int eccbytes = chip->ecc.bytes; @@ -782,9 +779,8 @@ static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, static int fsmc_bch8_correct_data(struct mtd_info *mtd, uint8_t *dat, uint8_t *read_ecc, uint8_t *calc_ecc) { - struct fsmc_nand_data *host = container_of(mtd, - struct fsmc_nand_data, mtd); - struct nand_chip *chip = mtd->priv; + struct nand_chip *chip = mtd_to_nand(mtd); + struct fsmc_nand_data *host = mtd_to_fsmc(mtd); void __iomem *regs = host->regs_va; unsigned int bank = host->bank; uint32_t err_idx[8]; @@ -926,7 +922,6 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) { struct fsmc_nand_platform_data *pdata = dev_get_platdata(&pdev->dev); struct device_node __maybe_unused *np = pdev->dev.of_node; - struct mtd_part_parser_data ppdata = {}; struct fsmc_nand_data *host; struct mtd_info *mtd; struct nand_chip *nand; @@ -1012,12 +1007,12 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) init_completion(&host->dma_access_complete); /* Link all private pointers */ - mtd = &host->mtd; + mtd = nand_to_mtd(&host->nand); nand = &host->nand; - mtd->priv = nand; - nand->priv = host; + nand_set_controller_data(nand, host); + nand_set_flash_node(nand, np); - host->mtd.dev.parent = &pdev->dev; + mtd->dev.parent = &pdev->dev; nand->IO_ADDR_R = host->data_va; nand->IO_ADDR_W = host->data_va; nand->cmd_ctrl = fsmc_cmd_ctrl; @@ -1033,7 +1028,7 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) nand->options = pdata->options; nand->select_chip = fsmc_select_chip; nand->badblockbits = 7; - nand->flash_node = np; + nand_set_flash_node(nand, np); if (pdata->width == FSMC_NAND_BW16) nand->options |= NAND_BUSWIDTH_16; @@ -1080,14 +1075,14 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) /* * Scan to find existence of the device */ - if (nand_scan_ident(&host->mtd, 1, NULL)) { + if (nand_scan_ident(mtd, 1, NULL)) { ret = -ENXIO; dev_err(&pdev->dev, "No NAND Device found!\n"); goto err_scan_ident; } if (AMBA_REV_BITS(host->pid) >= 8) { - switch (host->mtd.oobsize) { + switch (mtd->oobsize) { case 16: nand->ecc.layout = &fsmc_ecc4_16_layout; host->ecc_place = &fsmc_ecc4_sp_place; @@ -1138,7 +1133,7 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) * generated later in nand_bch_init() later. */ if (nand->ecc.mode != NAND_ECC_SOFT_BCH) { - switch (host->mtd.oobsize) { + switch (mtd->oobsize) { case 16: nand->ecc.layout = &fsmc_ecc1_16_layout; break; @@ -1159,7 +1154,7 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) } /* Second stage of scan to fill MTD data-structures */ - if (nand_scan_tail(&host->mtd)) { + if (nand_scan_tail(mtd)) { ret = -ENXIO; goto err_probe; } @@ -1174,10 +1169,8 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) /* * Check for partition info passed */ - host->mtd.name = "nand"; - ppdata.of_node = np; - ret = mtd_device_parse_register(&host->mtd, NULL, &ppdata, - host->partitions, host->nr_partitions); + mtd->name = "nand"; + ret = mtd_device_register(mtd, host->partitions, host->nr_partitions); if (ret) goto err_probe; @@ -1207,7 +1200,7 @@ static int fsmc_nand_remove(struct platform_device *pdev) struct fsmc_nand_data *host = platform_get_drvdata(pdev); if (host) { - nand_release(&host->mtd); + nand_release(nand_to_mtd(&host->nand)); if (host->mode == USE_DMA_ACCESS) { dma_release_channel(host->write_dma_chan); |