From 91395b5d4ebb07bf6488058f0ba37256856816f6 Mon Sep 17 00:00:00 2001 From: Chris Packham Date: Mon, 29 Aug 2016 15:20:52 +1200 Subject: mtd: nand: pxa3xx: use nand_set_controller_data In commit 17cb4b8f327e ("mtd: nand: Add+use mtd_to/from_nand and nand_get/set_controller_data") the assignment of mtd->priv was removed but was not replaced. This adds the required nand_set_controller_data() call. Signed-off-by: Chris Packham --- drivers/mtd/nand/pxa3xx_nand.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c index d3ac539..b1d58e0 100644 --- a/drivers/mtd/nand/pxa3xx_nand.c +++ b/drivers/mtd/nand/pxa3xx_nand.c @@ -1496,6 +1496,7 @@ static int alloc_nand_resource(struct pxa3xx_nand_info *info) host->read_id_bytes = 4; mtd->owner = THIS_MODULE; + nand_set_controller_data(chip, host); chip->ecc.read_page = pxa3xx_nand_read_page_hwecc; chip->ecc.write_page = pxa3xx_nand_write_page_hwecc; chip->controller = &info->controller; -- cgit v1.1 From 4004a81828c72311f9c310c38d903b3f6638465d Mon Sep 17 00:00:00 2001 From: Tony Lindgren Date: Mon, 29 Aug 2016 09:11:43 -0700 Subject: nand: Fix nand info for no device Looks like we have few more places where we're testing for nand_info[i]->name. We can now use just test for nand_info[i] instead. This fixes a data abort on devices with no NAND when doing nand info. Signed-off-by: Tony Lindgren Reviewed-by: Tom Rini --- cmd/nand.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/nand.c b/cmd/nand.c index 97f1619..c25e25a 100644 --- a/cmd/nand.c +++ b/cmd/nand.c @@ -398,7 +398,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) putc('\n'); for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) { - if (nand_info[i]->name) + if (nand_info[i]) nand_print_and_set_info(i); } return 0; @@ -433,7 +433,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) * for another device is to be used. */ if (dev < 0 || dev >= CONFIG_SYS_MAX_NAND_DEVICE || - !nand_info[dev]->name) { + !nand_info[dev]) { puts("\nno devices available\n"); return 1; } @@ -991,7 +991,7 @@ usage: idx = simple_strtoul(boot_device, NULL, 16); - if (idx < 0 || idx >= CONFIG_SYS_MAX_NAND_DEVICE || !nand_info[idx]->name) { + if (idx < 0 || idx >= CONFIG_SYS_MAX_NAND_DEVICE || !nand_info[idx]) { printf("\n** Device %d not available\n", idx); bootstage_error(BOOTSTAGE_ID_NAND_AVAILABLE); return 1; -- cgit v1.1 From 8b7d51249eca113c4965a7c417f33d7eb569434b Mon Sep 17 00:00:00 2001 From: Scott Wood Date: Thu, 1 Sep 2016 17:31:31 -0500 Subject: nand: Fix some more NULL name tests Now that nand_info[] is an array of pointers we need to test the pointer itself rather than using name as a proxy for NULLness. Fixes: b616d9b0a708eb9 ("nand: Embed mtd_info in struct nand_chip") Signed-off-by: Scott Wood Cc: Lukasz Majewski Cc: Tony Lindgren Acked-by: Tony Lindgren --- cmd/nand.c | 2 +- drivers/dfu/dfu_nand.c | 4 ++-- drivers/mtd/nand/omap_gpmc.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/nand.c b/cmd/nand.c index c25e25a..c16ec77 100644 --- a/cmd/nand.c +++ b/cmd/nand.c @@ -191,7 +191,7 @@ int do_nand_env_oob(cmd_tbl_t *cmdtp, int argc, char *const argv[]) struct mtd_info *mtd = nand_info[0]; char *cmd = argv[1]; - if (CONFIG_SYS_MAX_NAND_DEVICE == 0 || !mtd->name) { + if (CONFIG_SYS_MAX_NAND_DEVICE == 0 || !mtd) { puts("no devices available\n"); return 1; } diff --git a/drivers/dfu/dfu_nand.c b/drivers/dfu/dfu_nand.c index 9fb874c..23f1571 100644 --- a/drivers/dfu/dfu_nand.c +++ b/drivers/dfu/dfu_nand.c @@ -39,7 +39,7 @@ static int nand_block_op(enum dfu_op op, struct dfu_entity *dfu, if (nand_curr_device < 0 || nand_curr_device >= CONFIG_SYS_MAX_NAND_DEVICE || - !nand_info[nand_curr_device]->name) { + !nand_info[nand_curr_device]) { printf("%s: invalid nand device\n", __func__); return -1; } @@ -148,7 +148,7 @@ static int dfu_flush_medium_nand(struct dfu_entity *dfu) if (nand_curr_device < 0 || nand_curr_device >= CONFIG_SYS_MAX_NAND_DEVICE || - !nand_info[nand_curr_device]->name) { + !nand_info[nand_curr_device]) { printf("%s: invalid nand device\n", __func__); return -1; } diff --git a/drivers/mtd/nand/omap_gpmc.c b/drivers/mtd/nand/omap_gpmc.c index 6e201d6..af618fc 100644 --- a/drivers/mtd/nand/omap_gpmc.c +++ b/drivers/mtd/nand/omap_gpmc.c @@ -899,7 +899,7 @@ int __maybe_unused omap_nand_switch_ecc(uint32_t hardware, uint32_t eccstrength) if (nand_curr_device < 0 || nand_curr_device >= CONFIG_SYS_MAX_NAND_DEVICE || - !nand_info[nand_curr_device]->name) { + !nand_info[nand_curr_device]) { printf("nand: error: no NAND devices found\n"); return -ENODEV; } -- cgit v1.1