Commit 481815a6 authored by Arvind Yadav's avatar Arvind Yadav Committed by Boris Brezillon

mtd: st_spi_fsm: Handle clk_prepare_enable/clk_disable_unprepare.

- clk_prepare_enable() can fail here and we must check its return value.
 - stfsm_probe() can fail here and we must disable clock.
Signed-off-by: default avatarArvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
parent 4d26f012
...@@ -2073,15 +2073,17 @@ static int stfsm_probe(struct platform_device *pdev) ...@@ -2073,15 +2073,17 @@ static int stfsm_probe(struct platform_device *pdev)
ret = stfsm_init(fsm); ret = stfsm_init(fsm);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Failed to initialise FSM Controller\n"); dev_err(&pdev->dev, "Failed to initialise FSM Controller\n");
return ret; goto err_clk_unprepare;
} }
stfsm_fetch_platform_configs(pdev); stfsm_fetch_platform_configs(pdev);
/* Detect SPI FLASH device */ /* Detect SPI FLASH device */
info = stfsm_jedec_probe(fsm); info = stfsm_jedec_probe(fsm);
if (!info) if (!info) {
return -ENODEV; ret = -ENODEV;
goto err_clk_unprepare;
}
fsm->info = info; fsm->info = info;
/* Use device size to determine address width */ /* Use device size to determine address width */
...@@ -2095,11 +2097,11 @@ static int stfsm_probe(struct platform_device *pdev) ...@@ -2095,11 +2097,11 @@ static int stfsm_probe(struct platform_device *pdev)
if (info->config) { if (info->config) {
ret = info->config(fsm); ret = info->config(fsm);
if (ret) if (ret)
return ret; goto err_clk_unprepare;
} else { } else {
ret = stfsm_prepare_rwe_seqs_default(fsm); ret = stfsm_prepare_rwe_seqs_default(fsm);
if (ret) if (ret)
return ret; goto err_clk_unprepare;
} }
fsm->mtd.name = info->name; fsm->mtd.name = info->name;
...@@ -2124,6 +2126,10 @@ static int stfsm_probe(struct platform_device *pdev) ...@@ -2124,6 +2126,10 @@ static int stfsm_probe(struct platform_device *pdev)
fsm->mtd.erasesize, (fsm->mtd.erasesize >> 10)); fsm->mtd.erasesize, (fsm->mtd.erasesize >> 10));
return mtd_device_register(&fsm->mtd, NULL, 0); return mtd_device_register(&fsm->mtd, NULL, 0);
err_clk_unprepare:
clk_disable_unprepare(fsm->clk);
return ret;
} }
static int stfsm_remove(struct platform_device *pdev) static int stfsm_remove(struct platform_device *pdev)
...@@ -2147,9 +2153,7 @@ static int stfsmfsm_resume(struct device *dev) ...@@ -2147,9 +2153,7 @@ static int stfsmfsm_resume(struct device *dev)
{ {
struct stfsm *fsm = dev_get_drvdata(dev); struct stfsm *fsm = dev_get_drvdata(dev);
clk_prepare_enable(fsm->clk); return clk_prepare_enable(fsm->clk);
return 0;
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment