From a61ae81a1907af1987ad4c77300508327bc48b23 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Fri, 30 Oct 2015 20:33:25 -0700 Subject: mtd: nand: drop unnecessary partition parser data All of these drivers set up a parser data struct just to communicate DT partition data. This field has been deprecated and is instead supported by telling nand_scan_ident() about the 'flash_node'. This patch: * sets chip->flash_node for those drivers that didn't already (but used OF partitioning) * drops the parser data * switches to the simpler mtd_device_register() where possible, now that we've eliminated one of the auxiliary parameters Now that we've assigned chip->flash_node for these drivers, we can probably rely on nand_dt_init() to do more of the DT parsing for us, but for now, I don't want to fiddle with each of these drivers. The parsing is done in duplicate for now on some drivers. I don't think this should break things. (Famous last words.) (Rolled in some changes by Boris Brezillon) Signed-off-by: Brian Norris Reviewed-by: Boris Brezillon --- drivers/mtd/nand/hisi504_nand.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/mtd/nand/hisi504_nand.c') diff --git a/drivers/mtd/nand/hisi504_nand.c b/drivers/mtd/nand/hisi504_nand.c index 0cb2e88..0aad4ac 100644 --- a/drivers/mtd/nand/hisi504_nand.c +++ b/drivers/mtd/nand/hisi504_nand.c @@ -704,7 +704,6 @@ static int hisi_nfc_probe(struct platform_device *pdev) struct mtd_info *mtd; struct resource *res; struct device_node *np = dev->of_node; - struct mtd_part_parser_data ppdata; host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); if (!host) @@ -742,6 +741,7 @@ static int hisi_nfc_probe(struct platform_device *pdev) mtd->dev.parent = &pdev->dev; chip->priv = host; + nand_set_flash_node(chip, np); chip->cmdfunc = hisi_nfc_cmdfunc; chip->select_chip = hisi_nfc_select_chip; chip->read_byte = hisi_nfc_read_byte; @@ -805,8 +805,7 @@ static int hisi_nfc_probe(struct platform_device *pdev) goto err_res; } - ppdata.of_node = np; - ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0); + ret = mtd_device_register(mtd, NULL, 0); if (ret) { dev_err(dev, "Err MTD partition=%d\n", ret); goto err_mtd; -- cgit v1.1 From 4bd4ebcc540c35d4477b098cf26394f976551464 Mon Sep 17 00:00:00 2001 From: Boris BREZILLON Date: Tue, 1 Dec 2015 12:03:04 +0100 Subject: mtd: nand: make use of mtd_to_nand() in NAND drivers mtd_to_nand() was recently introduced to avoid direct accesses to the mtd->priv field. Update all NAND drivers to use it. Signed-off-by: Boris Brezillon Signed-off-by: Brian Norris --- drivers/mtd/nand/hisi504_nand.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/mtd/nand/hisi504_nand.c') diff --git a/drivers/mtd/nand/hisi504_nand.c b/drivers/mtd/nand/hisi504_nand.c index 0aad4ac..6358d4a 100644 --- a/drivers/mtd/nand/hisi504_nand.c +++ b/drivers/mtd/nand/hisi504_nand.c @@ -190,7 +190,7 @@ static void wait_controller_finished(struct hinfc_host *host) static void hisi_nfc_dma_transfer(struct hinfc_host *host, int todev) { struct mtd_info *mtd = &host->mtd; - struct nand_chip *chip = mtd->priv; + struct nand_chip *chip = mtd_to_nand(mtd); unsigned long val; int ret; @@ -357,7 +357,7 @@ static int hisi_nfc_send_cmd_reset(struct hinfc_host *host, int chipselect) static void hisi_nfc_select_chip(struct mtd_info *mtd, int chipselect) { - struct nand_chip *chip = mtd->priv; + struct nand_chip *chip = mtd_to_nand(mtd); struct hinfc_host *host = chip->priv; if (chipselect < 0) @@ -368,7 +368,7 @@ static void hisi_nfc_select_chip(struct mtd_info *mtd, int chipselect) static uint8_t hisi_nfc_read_byte(struct mtd_info *mtd) { - struct nand_chip *chip = mtd->priv; + struct nand_chip *chip = mtd_to_nand(mtd); struct hinfc_host *host = chip->priv; if (host->command == NAND_CMD_STATUS) @@ -384,7 +384,7 @@ static uint8_t hisi_nfc_read_byte(struct mtd_info *mtd) static u16 hisi_nfc_read_word(struct mtd_info *mtd) { - struct nand_chip *chip = mtd->priv; + struct nand_chip *chip = mtd_to_nand(mtd); struct hinfc_host *host = chip->priv; host->offset += 2; @@ -394,7 +394,7 @@ static u16 hisi_nfc_read_word(struct mtd_info *mtd) static void hisi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) { - struct nand_chip *chip = mtd->priv; + struct nand_chip *chip = mtd_to_nand(mtd); struct hinfc_host *host = chip->priv; memcpy(host->buffer + host->offset, buf, len); @@ -403,7 +403,7 @@ hisi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) static void hisi_nfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) { - struct nand_chip *chip = mtd->priv; + struct nand_chip *chip = mtd_to_nand(mtd); struct hinfc_host *host = chip->priv; memcpy(buf, host->buffer + host->offset, len); @@ -412,7 +412,7 @@ static void hisi_nfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) static void set_addr(struct mtd_info *mtd, int column, int page_addr) { - struct nand_chip *chip = mtd->priv; + struct nand_chip *chip = mtd_to_nand(mtd); struct hinfc_host *host = chip->priv; unsigned int command = host->command; @@ -448,7 +448,7 @@ static void set_addr(struct mtd_info *mtd, int column, int page_addr) static void hisi_nfc_cmdfunc(struct mtd_info *mtd, unsigned command, int column, int page_addr) { - struct nand_chip *chip = mtd->priv; + struct nand_chip *chip = mtd_to_nand(mtd); struct hinfc_host *host = chip->priv; int is_cache_invalid = 1; unsigned int flag = 0; -- cgit v1.1 From fa100163d38ef8607652681fbe6f75491032610e Mon Sep 17 00:00:00 2001 From: Boris BREZILLON Date: Thu, 10 Dec 2015 09:00:08 +0100 Subject: mtd: nand: hisi504: use the mtd instance embedded in struct nand_chip struct nand_chip now embeds an mtd device. Make use of this mtd instance. Signed-off-by: Boris Brezillon Signed-off-by: Brian Norris --- drivers/mtd/nand/hisi504_nand.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'drivers/mtd/nand/hisi504_nand.c') diff --git a/drivers/mtd/nand/hisi504_nand.c b/drivers/mtd/nand/hisi504_nand.c index 6358d4a..6e6e482 100644 --- a/drivers/mtd/nand/hisi504_nand.c +++ b/drivers/mtd/nand/hisi504_nand.c @@ -134,7 +134,6 @@ struct hinfc_host { struct nand_chip chip; - struct mtd_info mtd; struct device *dev; void __iomem *iobase; void __iomem *mmio; @@ -189,8 +188,8 @@ static void wait_controller_finished(struct hinfc_host *host) static void hisi_nfc_dma_transfer(struct hinfc_host *host, int todev) { - struct mtd_info *mtd = &host->mtd; - struct nand_chip *chip = mtd_to_nand(mtd); + struct nand_chip *chip = &host->chip; + struct mtd_info *mtd = nand_to_mtd(chip); unsigned long val; int ret; @@ -262,7 +261,7 @@ static int hisi_nfc_send_cmd_pageprog(struct hinfc_host *host) static int hisi_nfc_send_cmd_readstart(struct hinfc_host *host) { - struct mtd_info *mtd = &host->mtd; + struct mtd_info *mtd = nand_to_mtd(&host->chip); if ((host->addr_value[0] == host->cache_addr_value[0]) && (host->addr_value[1] == host->cache_addr_value[1])) @@ -643,7 +642,7 @@ static int hisi_nfc_ecc_probe(struct hinfc_host *host) int size, strength, ecc_bits; struct device *dev = host->dev; struct nand_chip *chip = &host->chip; - struct mtd_info *mtd = &host->mtd; + struct mtd_info *mtd = nand_to_mtd(chip); struct device_node *np = host->dev->of_node; size = of_get_nand_ecc_step_size(np); @@ -712,7 +711,7 @@ static int hisi_nfc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, host); chip = &host->chip; - mtd = &host->mtd; + mtd = nand_to_mtd(chip); irq = platform_get_irq(pdev, 0); if (irq < 0) { @@ -822,7 +821,7 @@ err_res: static int hisi_nfc_remove(struct platform_device *pdev) { struct hinfc_host *host = platform_get_drvdata(pdev); - struct mtd_info *mtd = &host->mtd; + struct mtd_info *mtd = nand_to_mtd(&host->chip); nand_release(mtd); -- cgit v1.1 From 37f5a54646da0760306ab8570115e20d0ed615f5 Mon Sep 17 00:00:00 2001 From: Boris BREZILLON Date: Thu, 10 Dec 2015 09:00:34 +0100 Subject: mtd: nand: remove useless mtd->priv = chip assignments mtd_to_nand() now uses the container_of() approach to transform an mtd_info pointer into a nand_chip one. Drop useless mtd->priv assignments from NAND controller drivers. Signed-off-by: Boris Brezillon Signed-off-by: Brian Norris --- drivers/mtd/nand/hisi504_nand.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/mtd/nand/hisi504_nand.c') diff --git a/drivers/mtd/nand/hisi504_nand.c b/drivers/mtd/nand/hisi504_nand.c index 6e6e482..2aee212 100644 --- a/drivers/mtd/nand/hisi504_nand.c +++ b/drivers/mtd/nand/hisi504_nand.c @@ -735,7 +735,6 @@ static int hisi_nfc_probe(struct platform_device *pdev) goto err_res; } - mtd->priv = chip; mtd->name = "hisi_nand"; mtd->dev.parent = &pdev->dev; -- cgit v1.1 From d699ed250c07384840263bbbf69cf7b90b45470c Mon Sep 17 00:00:00 2001 From: Boris BREZILLON Date: Thu, 10 Dec 2015 09:00:41 +0100 Subject: mtd: nand: make use of nand_set/get_controller_data() helpers New helpers have been added to avoid directly accessing chip->field. Use them where appropriate. Signed-off-by: Boris Brezillon [Brian: fixed a few rebase conflicts] Signed-off-by: Brian Norris --- drivers/mtd/nand/hisi504_nand.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers/mtd/nand/hisi504_nand.c') diff --git a/drivers/mtd/nand/hisi504_nand.c b/drivers/mtd/nand/hisi504_nand.c index 2aee212..f8d37f3 100644 --- a/drivers/mtd/nand/hisi504_nand.c +++ b/drivers/mtd/nand/hisi504_nand.c @@ -357,7 +357,7 @@ static int hisi_nfc_send_cmd_reset(struct hinfc_host *host, int chipselect) static void hisi_nfc_select_chip(struct mtd_info *mtd, int chipselect) { struct nand_chip *chip = mtd_to_nand(mtd); - struct hinfc_host *host = chip->priv; + struct hinfc_host *host = nand_get_controller_data(chip); if (chipselect < 0) return; @@ -368,7 +368,7 @@ static void hisi_nfc_select_chip(struct mtd_info *mtd, int chipselect) static uint8_t hisi_nfc_read_byte(struct mtd_info *mtd) { struct nand_chip *chip = mtd_to_nand(mtd); - struct hinfc_host *host = chip->priv; + struct hinfc_host *host = nand_get_controller_data(chip); if (host->command == NAND_CMD_STATUS) return *(uint8_t *)(host->mmio); @@ -384,7 +384,7 @@ static uint8_t hisi_nfc_read_byte(struct mtd_info *mtd) static u16 hisi_nfc_read_word(struct mtd_info *mtd) { struct nand_chip *chip = mtd_to_nand(mtd); - struct hinfc_host *host = chip->priv; + struct hinfc_host *host = nand_get_controller_data(chip); host->offset += 2; return *(u16 *)(host->buffer + host->offset - 2); @@ -394,7 +394,7 @@ static void hisi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) { struct nand_chip *chip = mtd_to_nand(mtd); - struct hinfc_host *host = chip->priv; + struct hinfc_host *host = nand_get_controller_data(chip); memcpy(host->buffer + host->offset, buf, len); host->offset += len; @@ -403,7 +403,7 @@ hisi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) static void hisi_nfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) { struct nand_chip *chip = mtd_to_nand(mtd); - struct hinfc_host *host = chip->priv; + struct hinfc_host *host = nand_get_controller_data(chip); memcpy(buf, host->buffer + host->offset, len); host->offset += len; @@ -412,7 +412,7 @@ static void hisi_nfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) static void set_addr(struct mtd_info *mtd, int column, int page_addr) { struct nand_chip *chip = mtd_to_nand(mtd); - struct hinfc_host *host = chip->priv; + struct hinfc_host *host = nand_get_controller_data(chip); unsigned int command = host->command; host->addr_cycle = 0; @@ -448,7 +448,7 @@ static void hisi_nfc_cmdfunc(struct mtd_info *mtd, unsigned command, int column, int page_addr) { struct nand_chip *chip = mtd_to_nand(mtd); - struct hinfc_host *host = chip->priv; + struct hinfc_host *host = nand_get_controller_data(chip); int is_cache_invalid = 1; unsigned int flag = 0; @@ -542,7 +542,7 @@ static irqreturn_t hinfc_irq_handle(int irq, void *devid) static int hisi_nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf, int oob_required, int page) { - struct hinfc_host *host = chip->priv; + struct hinfc_host *host = nand_get_controller_data(chip); int max_bitflips = 0, stat = 0, stat_max = 0, status_ecc; int stat_1, stat_2; @@ -574,7 +574,7 @@ static int hisi_nand_read_page_hwecc(struct mtd_info *mtd, static int hisi_nand_read_oob(struct mtd_info *mtd, struct nand_chip *chip, int page) { - struct hinfc_host *host = chip->priv; + struct hinfc_host *host = nand_get_controller_data(chip); chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page); chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); @@ -738,7 +738,7 @@ static int hisi_nfc_probe(struct platform_device *pdev) mtd->name = "hisi_nand"; mtd->dev.parent = &pdev->dev; - chip->priv = host; + nand_set_controller_data(chip, host); nand_set_flash_node(chip, np); chip->cmdfunc = hisi_nfc_cmdfunc; chip->select_chip = hisi_nfc_select_chip; -- cgit v1.1