* [U-Boot] [PATCH 1/2] nand: zynq: Fix driver initialization
@ 2018-04-19 11:10 Michal Simek
2018-04-19 11:10 ` [U-Boot] [PATCH 2/2] nand: zynq: Cleanup initialization Michal Simek
2018-04-19 15:16 ` [U-Boot] [PATCH 1/2] nand: zynq: Fix driver initialization Ezequiel Garcia
0 siblings, 2 replies; 4+ messages in thread
From: Michal Simek @ 2018-04-19 11:10 UTC (permalink / raw)
To: u-boot
From: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
This driver is currently broken, refusing to initialize properly.
The reason is that get_nand_dev_by_index() was being called before
nand_register(), thus returning a pointer into uninitialized memory.
In other words, the struct mtd_info used by the driver is total junk.
Fix it by getting the correct struct mtd_info, via nand_to_mtd()
on the driver's struct nand_chip.
Tested on a custom board, where the CPU is halted without this patch.
Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Reviewed-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
drivers/mtd/nand/zynq_nand.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/zynq_nand.c b/drivers/mtd/nand/zynq_nand.c
index 6494196049f1..9f6ff3d045c2 100644
--- a/drivers/mtd/nand/zynq_nand.c
+++ b/drivers/mtd/nand/zynq_nand.c
@@ -1025,7 +1025,7 @@ int zynq_nand_init(struct nand_chip *nand_chip, int devnum)
}
xnand->nand_base = (void __iomem *)ZYNQ_NAND_BASEADDR;
- mtd = get_nand_dev_by_index(0);
+ mtd = nand_to_mtd(nand_chip);
nand_chip->priv = xnand;
mtd->priv = nand_chip;
--
2.17.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 2/2] nand: zynq: Cleanup initialization
2018-04-19 11:10 [U-Boot] [PATCH 1/2] nand: zynq: Fix driver initialization Michal Simek
@ 2018-04-19 11:10 ` Michal Simek
2018-04-19 15:16 ` [U-Boot] [PATCH 1/2] nand: zynq: Fix driver initialization Ezequiel Garcia
1 sibling, 0 replies; 4+ messages in thread
From: Michal Simek @ 2018-04-19 11:10 UTC (permalink / raw)
To: u-boot
From: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
CONFIG_NAND_ZYNQ selects CONFIG_SYS_NAND_SELF_INIT, so the
driver doesn't have to play any ifdef game.
Also, we can mark zynq_nand_init() as static and get rid
of the mach-specific nand.h header.
This is really a revert of:
"mtd: zynq: nand: Move board_nand_init() function to board.c"
(sha1: 310995d9f91ae56082b49be06fe8c3d01424f8f6)
Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Reviewed-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
arch/arm/mach-zynq/include/mach/nand.h | 9 ---------
drivers/mtd/nand/zynq_nand.c | 6 ++----
2 files changed, 2 insertions(+), 13 deletions(-)
delete mode 100644 arch/arm/mach-zynq/include/mach/nand.h
diff --git a/arch/arm/mach-zynq/include/mach/nand.h b/arch/arm/mach-zynq/include/mach/nand.h
deleted file mode 100644
index 61ef45f5828a..000000000000
--- a/arch/arm/mach-zynq/include/mach/nand.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
- * Copyright (C) 2017 National Instruments Corp.
- *
- * SPDX-License-Identifier: GPL-2.0+
- */
-
-#include <nand.h>
-
-void zynq_nand_init(void);
diff --git a/drivers/mtd/nand/zynq_nand.c b/drivers/mtd/nand/zynq_nand.c
index 9f6ff3d045c2..2d4e8b4736ba 100644
--- a/drivers/mtd/nand/zynq_nand.c
+++ b/drivers/mtd/nand/zynq_nand.c
@@ -1006,7 +1006,7 @@ static int zynq_nand_device_ready(struct mtd_info *mtd)
return 0;
}
-int zynq_nand_init(struct nand_chip *nand_chip, int devnum)
+static int zynq_nand_init(struct nand_chip *nand_chip, int devnum)
{
struct zynq_nand_info *xnand;
struct mtd_info *mtd;
@@ -1192,14 +1192,12 @@ fail:
return err;
}
-#ifdef CONFIG_SYS_NAND_SELF_INIT
static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];
-void __weak board_nand_init(void)
+void board_nand_init(void)
{
struct nand_chip *nand = &nand_chip[0];
if (zynq_nand_init(nand, 0))
puts("ZYNQ NAND init failed\n");
}
-#endif
--
2.17.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 1/2] nand: zynq: Fix driver initialization
2018-04-19 11:10 [U-Boot] [PATCH 1/2] nand: zynq: Fix driver initialization Michal Simek
2018-04-19 11:10 ` [U-Boot] [PATCH 2/2] nand: zynq: Cleanup initialization Michal Simek
@ 2018-04-19 15:16 ` Ezequiel Garcia
2018-04-20 7:49 ` Michal Simek
1 sibling, 1 reply; 4+ messages in thread
From: Ezequiel Garcia @ 2018-04-19 15:16 UTC (permalink / raw)
To: u-boot
Hi Michal,
On 19 April 2018 at 08:10, Michal Simek <michal.simek@xilinx.com> wrote:
> From: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
>
> This driver is currently broken, refusing to initialize properly.
>
> The reason is that get_nand_dev_by_index() was being called before
> nand_register(), thus returning a pointer into uninitialized memory.
> In other words, the struct mtd_info used by the driver is total junk.
>
> Fix it by getting the correct struct mtd_info, via nand_to_mtd()
> on the driver's struct nand_chip.
>
> Tested on a custom board, where the CPU is halted without this patch.
>
> Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
> Reviewed-by: Michal Simek <michal.simek@xilinx.com>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Thanks for collecting these and submitting them!
BTW, I thought there was no need for a reviewed-by on top
of a signed-off-by. It's kind of assumed that if you are signing
something, you have reviewed it in the first place.
Or at least that's how I've been doing it.
--
Ezequiel GarcÃa, VanguardiaSur
www.vanguardiasur.com.ar
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 1/2] nand: zynq: Fix driver initialization
2018-04-19 15:16 ` [U-Boot] [PATCH 1/2] nand: zynq: Fix driver initialization Ezequiel Garcia
@ 2018-04-20 7:49 ` Michal Simek
0 siblings, 0 replies; 4+ messages in thread
From: Michal Simek @ 2018-04-20 7:49 UTC (permalink / raw)
To: u-boot
Hi Ezequiel,
On 19.4.2018 17:16, Ezequiel Garcia wrote:
> Hi Michal,
>
> On 19 April 2018 at 08:10, Michal Simek <michal.simek@xilinx.com> wrote:
>> From: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
>>
>> This driver is currently broken, refusing to initialize properly.
>>
>> The reason is that get_nand_dev_by_index() was being called before
>> nand_register(), thus returning a pointer into uninitialized memory.
>> In other words, the struct mtd_info used by the driver is total junk.
>>
>> Fix it by getting the correct struct mtd_info, via nand_to_mtd()
>> on the driver's struct nand_chip.
>>
>> Tested on a custom board, where the CPU is halted without this patch.
>>
>> Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
>> Reviewed-by: Michal Simek <michal.simek@xilinx.com>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>
> Thanks for collecting these and submitting them!
>
> BTW, I thought there was no need for a reviewed-by on top
> of a signed-off-by. It's kind of assumed that if you are signing
> something, you have reviewed it in the first place.
>
> Or at least that's how I've been doing it.
My initial goal was to send it without my SoB line but my good git setup
is adding it automatically. I didn't touch your patches that's why I
wanted to say that I have reviewed it and at the end my SoB line will be
there too because it will go via my tree.
Thanks,
Michal
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-04-20 7:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-19 11:10 [U-Boot] [PATCH 1/2] nand: zynq: Fix driver initialization Michal Simek
2018-04-19 11:10 ` [U-Boot] [PATCH 2/2] nand: zynq: Cleanup initialization Michal Simek
2018-04-19 15:16 ` [U-Boot] [PATCH 1/2] nand: zynq: Fix driver initialization Ezequiel Garcia
2018-04-20 7:49 ` Michal Simek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.