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/staging/mt29f_spinand/mt29f_spinand.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c b/drivers/staging/mt29f_spinand/mt29f_spinand.c index 405b643189fd..49807de7d91e 100644 --- a/drivers/staging/mt29f_spinand/mt29f_spinand.c +++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c @@ -853,7 +853,6 @@ static int spinand_probe(struct spi_device *spi_nand) struct nand_chip *chip; struct spinand_info *info; struct spinand_state *state; - struct mtd_part_parser_data ppdata; info = devm_kzalloc(&spi_nand->dev, sizeof(struct spinand_info), GFP_KERNEL); @@ -897,6 +896,7 @@ static int spinand_probe(struct spi_device *spi_nand) pr_info("%s: disable ecc failed!\n", __func__); #endif + nand_set_flash_node(chip, spi_nand->dev.of_node); chip->priv = info; chip->read_buf = spinand_read_buf; chip->write_buf = spinand_write_buf; @@ -919,8 +919,7 @@ static int spinand_probe(struct spi_device *spi_nand) if (nand_scan(mtd, 1)) return -ENXIO; - ppdata.of_node = spi_nand->dev.of_node; - return mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0); + return mtd_device_register(mtd, NULL, 0); } /* -- cgit v1.2.1 From a83dfa92850e521dfb6485ad4aa3c7c1fb52f06e Mon Sep 17 00:00:00 2001 From: Boris BREZILLON Date: Tue, 1 Dec 2015 12:03:05 +0100 Subject: staging: mt29f_spinand: make use of mtd_to_nand() mtd_to_nand() was recently introduced to avoid direct accesses to the mtd->priv field. Use it where appropriate. Signed-off-by: Boris Brezillon Signed-off-by: Brian Norris --- drivers/staging/mt29f_spinand/mt29f_spinand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c b/drivers/staging/mt29f_spinand/mt29f_spinand.c index 6536066b2349..8924a9645a43 100644 --- a/drivers/staging/mt29f_spinand/mt29f_spinand.c +++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c @@ -31,7 +31,7 @@ static inline struct spinand_state *mtd_to_state(struct mtd_info *mtd) { - struct nand_chip *chip = (struct nand_chip *)mtd->priv; + struct nand_chip *chip = mtd_to_nand(mtd); struct spinand_info *info = (struct spinand_info *)chip->priv; struct spinand_state *state = (struct spinand_state *)info->priv; @@ -744,7 +744,7 @@ static void spinand_reset(struct spi_device *spi_nand) static void spinand_cmdfunc(struct mtd_info *mtd, unsigned int command, int column, int page) { - struct nand_chip *chip = (struct nand_chip *)mtd->priv; + struct nand_chip *chip = mtd_to_nand(mtd); struct spinand_info *info = (struct spinand_info *)chip->priv; struct spinand_state *state = (struct spinand_state *)info->priv; -- cgit v1.2.1 From ba4ed8605cb09b2cb72bf14499cf4605a0f9eb23 Mon Sep 17 00:00:00 2001 From: Boris BREZILLON Date: Thu, 10 Dec 2015 09:00:31 +0100 Subject: staging: mt29f_spinand: use the mtd instance embedded in struct nand_chip struct nand_chip now embeds an mtd device, use it instead of allocating a new one. Signed-off-by: Boris Brezillon Signed-off-by: Brian Norris --- drivers/staging/mt29f_spinand/mt29f_spinand.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c b/drivers/staging/mt29f_spinand/mt29f_spinand.c index 8924a9645a43..8171b741ff86 100644 --- a/drivers/staging/mt29f_spinand/mt29f_spinand.c +++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c @@ -903,9 +903,7 @@ static int spinand_probe(struct spi_device *spi_nand) chip->options |= NAND_CACHEPRG; chip->select_chip = spinand_select_chip; - mtd = devm_kzalloc(&spi_nand->dev, sizeof(struct mtd_info), GFP_KERNEL); - if (!mtd) - return -ENOMEM; + mtd = nand_to_mtd(chip); dev_set_drvdata(&spi_nand->dev, mtd); -- cgit v1.2.1 From f12d86afc5594c89492fb7c78fce07a4e94b2384 Mon Sep 17 00:00:00 2001 From: Boris BREZILLON Date: Thu, 10 Dec 2015 09:00:36 +0100 Subject: staging: mt29f_spinand: remove useless mtd->priv = chip assignment 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/staging/mt29f_spinand/mt29f_spinand.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c b/drivers/staging/mt29f_spinand/mt29f_spinand.c index 8171b741ff86..b7d429d45dab 100644 --- a/drivers/staging/mt29f_spinand/mt29f_spinand.c +++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c @@ -907,7 +907,6 @@ static int spinand_probe(struct spi_device *spi_nand) dev_set_drvdata(&spi_nand->dev, mtd); - mtd->priv = chip; mtd->dev.parent = &spi_nand->dev; mtd->oobsize = 64; -- cgit v1.2.1 From f07dcb90e4a9ccab9663a50847f255c9b0e2ada1 Mon Sep 17 00:00:00 2001 From: Boris BREZILLON Date: Thu, 10 Dec 2015 09:00:42 +0100 Subject: staging: mt29f_spinand: 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 Signed-off-by: Brian Norris --- drivers/staging/mt29f_spinand/mt29f_spinand.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c b/drivers/staging/mt29f_spinand/mt29f_spinand.c index b7d429d45dab..197d1124733d 100644 --- a/drivers/staging/mt29f_spinand/mt29f_spinand.c +++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c @@ -32,7 +32,7 @@ static inline struct spinand_state *mtd_to_state(struct mtd_info *mtd) { struct nand_chip *chip = mtd_to_nand(mtd); - struct spinand_info *info = (struct spinand_info *)chip->priv; + struct spinand_info *info = nand_get_controller_data(chip); struct spinand_state *state = (struct spinand_state *)info->priv; return state; @@ -633,7 +633,7 @@ static int spinand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, u8 *p = buf; int eccsize = chip->ecc.size; int eccsteps = chip->ecc.steps; - struct spinand_info *info = (struct spinand_info *)chip->priv; + struct spinand_info *info = nand_get_controller_data(chip); enable_read_hw_ecc = 1; @@ -679,7 +679,7 @@ static u8 spinand_read_byte(struct mtd_info *mtd) static int spinand_wait(struct mtd_info *mtd, struct nand_chip *chip) { - struct spinand_info *info = (struct spinand_info *)chip->priv; + struct spinand_info *info = nand_get_controller_data(chip); unsigned long timeo = jiffies; int retval, state = chip->state; @@ -745,7 +745,7 @@ static void spinand_cmdfunc(struct mtd_info *mtd, unsigned int command, int column, int page) { struct nand_chip *chip = mtd_to_nand(mtd); - struct spinand_info *info = (struct spinand_info *)chip->priv; + struct spinand_info *info = nand_get_controller_data(chip); struct spinand_state *state = (struct spinand_state *)info->priv; switch (command) { @@ -894,7 +894,7 @@ static int spinand_probe(struct spi_device *spi_nand) #endif nand_set_flash_node(chip, spi_nand->dev.of_node); - chip->priv = info; + nand_set_controller_data(chip, info); chip->read_buf = spinand_read_buf; chip->write_buf = spinand_write_buf; chip->read_byte = spinand_read_byte; -- cgit v1.2.1