mtd: nand: vf610: Check the return value from clk_prepare_enable()
Subsystems (2)
PATCH 1/1 mtd: nand: vf610: Check the return value from clk_prepare_enable()
From: Fabio Estevam <[email protected]>
clk_prepare_enable() may fail, so we should better check its return value and propagate it in the case of error.
--- drivers/mtd/nand/vf610_nfc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/mtd/nand/vf610_nfc.c +5 -1
@@ -814,12 +814,16 @@ static int vf610_nfc_suspend(struct device *dev)static int vf610_nfc_resume (struct device *dev) { +int err; +struct mtd_info *mtd =dev_get_drvdata (dev);struct vf610_nfc *nfc =mtd_to_nfc (mtd);pinctrl_pm_select_default_state (dev); -clk_prepare_enable (nfc->clk); + err =clk_prepare_enable (nfc->clk); +if (err) +return err;vf610_nfc_preinit_controller (nfc);vf610_nfc_init_controller (nfc);
Signature · 1 line
2.7.4
Quoted 15 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
clk_prepare_enable()may fail, so we should better check its return value and propagate it in the case of error.Signed-off-by Fabio Estevam <[email protected]>--- drivers/mtd/nand/vf610_nfc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/mtd/nand/vf610_nfc.c +0
-0
drivers/mtd/nand/vf610_nfc.c static int vf610_nfc_suspend(struct device *dev) · line 822
Quoted 9 lines
drivers/mtd/nand/vf610_nfc.c +2
-0@@ -814,12 +814,16 @@ static int vf610_nfc_suspend(struct device *dev)static int vf610_nfc_resume (struct device *dev) { +int err; +struct mtd_info *mtd =dev_get_drvdata (dev);struct vf610_nfc *nfc =mtd_to_nfc (mtd);pinctrl_pm_select_default_state (dev);
AFAICT pinctrl_pm_select_default_state() can also fail. What makes it different from clk_prepare_enable() failures?
drivers/mtd/nand/vf610_nfc.c static int vf610_nfc_suspend(struct device *dev) · line 827
Quoted 6 lines
drivers/mtd/nand/vf610_nfc.c +3
-1-clk_prepare_enable (nfc->clk); + err =clk_prepare_enable (nfc->clk); +if (err) +return err;
I guess the idea was that clk_prepare_enabled already succeeded at probe time and there was not real reason for it to fail at resume time. But extra checks are never bad. BTW, I don't remember what happens if ->resume() returns an error. Does it prevent the whole system from resuming or just make this specific device unusable?
Quoted 2 lines
drivers/mtd/nand/vf610_nfc.c +0
-0vf610_nfc_preinit_controller (nfc);vf610_nfc_init_controller (nfc);
Quoted 32 lines · Boris Brezillon
Quoted 15 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
clk_prepare_enable()may fail, so we should better check its return value and propagate it in the case of error.Signed-off-by Fabio Estevam <[email protected]>--- drivers/mtd/nand/vf610_nfc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/mtd/nand/vf610_nfc.c +0
-0drivers/mtd/nand/vf610_nfc.c static int vf610_nfc_suspend(struct device *dev) · line 822
Quoted 9 lines
drivers/mtd/nand/vf610_nfc.c +2
-0@@ -814,12 +814,16 @@ static int vf610_nfc_suspend(struct device *dev)static int vf610_nfc_resume (struct device *dev) { +int err; +struct mtd_info *mtd =dev_get_drvdata (dev);struct vf610_nfc *nfc =mtd_to_nfc (mtd);pinctrl_pm_select_default_state (dev);AFAICT
pinctrl_pm_select_default_state()can also fail. What makes it different fromclk_prepare_enable()failures?Quoted 1 line
Quoted 11 lines
drivers/mtd/nand/vf610_nfc.c static int vf610_nfc_suspend(struct device *dev) · line 826
Quoted 5 lines
drivers/mtd/nand/vf610_nfc.c +3
-1-clk_prepare_enable (nfc->clk); + err =clk_prepare_enable (nfc->clk); +if (err) +return err;I guess the idea was that
clk_prepare_enabledalready succeeded at probe time and there was not real reason for it to fail at resume time. But extra checks are never bad. BTW, I don't remember what happens if ->resume() returns an error. Does it prevent the whole system from resuming or just make this specific device unusable?
Just found the answer [1]: it's harmless.
[1]http://elixir.free-electrons.com/linux/latest/source/include/linux/pm.h#L262
Hi Boris,
Quoted 2 lines · Boris Brezillon
AFAICT
pinctrl_pm_select_default_state()can also fail. What makes it different fromclk_prepare_enable()failures?
IMHO we could even remove pinctrl_pm_select_default_state() from this driver since pinctrl_pm_select_sleep_state() is never used.
This is the only driver that uses pinctrl_pm_select_default_state() inside drivers/mtd/.