Skip to contentSkip to conversation

mtd: nand: vf610: Check the return value from clk_prepare_enable()

PATCH In review Fabio Estevam 2 participants 3 messages Jul 18, 2017 – Aug 4, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 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.

---
Changes since v1:
- None

 drivers/mtd/nand/vf610_nfc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/mtd/nand/vf610_nfc.c +5 -1
index 744ab10..9e49672 100644
@@ -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
#1 lore raw

PATCH v2 2/2 mtd: nand: vf610: Remove unneeded pinctrl_pm_select_default_state()

From: Fabio Estevam <[email protected]>

pinctrl_pm_select_default_state() is already the default pinctrl state and since pinctrl_pm_select_sleep_state() is not used in this driver, there is no need to explicitly call pinctrl_pm_select_default_state().

---
Changes since v1:
- Newly introduced

 drivers/mtd/nand/vf610_nfc.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/mtd/nand/vf610_nfc.c +0 -3
index 9e49672..b88a0c91 100644
@@ -34,7 +34,6 @@
 #include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
 #include <linux/of_device.h>
-#include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 
@@ -819,8 +818,6 @@ static int vf610_nfc_resume(struct device *dev)
 	struct mtd_info *mtd = dev_get_drvdata(dev);
 	struct vf610_nfc *nfc = mtd_to_nfc(mtd);
 
-	pinctrl_pm_select_default_state(dev);
-
 	err = clk_prepare_enable(nfc->clk);
 	if (err)
 		return err;
Signature · 1 line
2.7.4
#2 lore raw
In reply to Fabio Estevam
Quoted 5 lines · On Mon, 17 Jul 2017 21:54:07 -0300 Fabio Estevam <[email protected]> wrote:

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.

Applied both.

Thanks,

Boris

Quoted 30 lines

---
Changes since v1:
- None

 drivers/mtd/nand/vf610_nfc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/mtd/nand/vf610_nfc.c +5 -1
index 744ab10..9e49672 100644
@@ -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);