Re: [PATCH v6 2/2] mtd: nand: sunxi: add reset line support

From: Boris Brezillon
Date: Fri Jun 24 2016 - 00:20:04 EST


On Fri, 24 Jun 2016 07:20:38 +0800
Icenowy Zheng <icenowy@xxxxxxxx> wrote:

> In my opinion, return directly PTR_ERR(nfc->reset) is OK here.
> If devm_reset_control_get_optional() return -EPROBE_DEFER, the code here will also return it. However, if we get other error, why should it return -EPROBE_DEFER again?

Sorry, I just had a brainfart :-). Your implementation is correct.
BTW, can you avoid top-posting and reply inline?

>
> 24.06.2016, 00:01, "Boris Brezillon" <boris.brezillon@xxxxxxxxxxxxxxxxxx>:
> > On Mon, 20 Jun 2016 12:48:38 +0800
> > Icenowy Zheng <icenowy@xxxxxxxx> wrote:
> >
> >> ÂThe NAND controller on some sun8i chips needs its reset line to be
> >> Âdeasserted before they can enter working state.
> >>
> >> ÂSigned-off-by: Icenowy Zheng <icenowy@xxxxxxxx>
> >> Â---
> >> ÂÂÂChanges in v2:
> >> ÂÂÂÂÂ- Corrected the error checking code of reset line.
> >>
> >> ÂÂÂChanges in v3:
> >> ÂÂÂÂÂ- Corrected a more serious error brought in the "fix" of v2.
> >>
> >> ÂÂÂChanges in v4:
> >> ÂÂÂÂÂ- Removed unneeded code block after "else".
> >>
> >> ÂÂÂChanges in v5:
> >> ÂÂÂÂÂ- Added reassertion code in case of initialization error and device
> >> ÂÂÂÂÂÂÂremove.
> >>
> >> ÂÂÂChanges in v6:
> >> ÂÂÂÂÂ- Fixed a resource leak by not using goto to exit in case of error.
> >>
> >> ÂÂdrivers/mtd/nand/sunxi_nand.c | 28 +++++++++++++++++++++++++---
> >> ÂÂ1 file changed, 25 insertions(+), 3 deletions(-)
> >>
> >> Âdiff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
> >> Âindex a83a690..08d5e88 100644
> >> Â--- a/drivers/mtd/nand/sunxi_nand.c
> >> Â+++ b/drivers/mtd/nand/sunxi_nand.c
> >> Â@@ -39,6 +39,7 @@
> >> ÂÂ#include <linux/gpio.h>
> >> ÂÂ#include <linux/interrupt.h>
> >> ÂÂ#include <linux/iopoll.h>
> >> Â+#include <linux/reset.h>
> >>
> >> ÂÂ#define NFC_REG_CTL 0x0000
> >> ÂÂ#define NFC_REG_ST 0x0004
> >> Â@@ -269,6 +270,7 @@ struct sunxi_nfc {
> >> ÂÂÂÂÂÂÂÂÂÂvoid __iomem *regs;
> >> ÂÂÂÂÂÂÂÂÂÂstruct clk *ahb_clk;
> >> ÂÂÂÂÂÂÂÂÂÂstruct clk *mod_clk;
> >> Â+ struct reset_control *reset;
> >> ÂÂÂÂÂÂÂÂÂÂunsigned long assigned_cs;
> >> ÂÂÂÂÂÂÂÂÂÂunsigned long clk_rate;
> >> ÂÂÂÂÂÂÂÂÂÂstruct list_head chips;
> >> Â@@ -1871,26 +1873,42 @@ static int sunxi_nfc_probe(struct platform_device *pdev)
> >> ÂÂÂÂÂÂÂÂÂÂif (ret)
> >> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂgoto out_ahb_clk_unprepare;
> >>
> >> Â+ nfc->reset = devm_reset_control_get_optional(dev, "ahb");
> >> Â+
> >> Â+ if (!IS_ERR(nfc->reset)) {
> >> Â+ ret = reset_control_deassert(nfc->reset);
> >> Â+ if (ret) {
> >> Â+ dev_err(dev, "reset err %d\n", ret);
> >> Â+ goto out_mod_clk_unprepare;
> >> Â+ }
> >> Â+ } else if (PTR_ERR(nfc->reset) != -ENOENT) {
> >> Â+ ret = PTR_ERR(nfc->reset);
> >
> > You should return -EDEFER_PROBE here.
> >
> > And can you please rebase this series on top of nand/next [1]?
> >
> > [1]https://github.com/linux-nand/linux/tree/nand/next