Skip to content

Commit 3c0e167

Browse files
Jinjie Ruanmiquelraynal
authored andcommitted
mtd: rawnand: denali: Use the devm_clk_get_enabled() helper function
The devm_clk_get_enabled() helper: - calls devm_clk_get() - calls clk_prepare_enable() and registers what is needed in order to call clk_disable_unprepare() when needed, as a managed resource. This simplifies the code. Signed-off-by: Jinjie Ruan <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent d43b24f commit 3c0e167

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed

drivers/mtd/nand/raw/denali_dt.c

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,15 @@ static int denali_dt_probe(struct platform_device *pdev)
145145
if (IS_ERR(denali->host))
146146
return PTR_ERR(denali->host);
147147

148-
dt->clk = devm_clk_get(dev, "nand");
148+
dt->clk = devm_clk_get_enabled(dev, "nand");
149149
if (IS_ERR(dt->clk))
150150
return PTR_ERR(dt->clk);
151151

152-
dt->clk_x = devm_clk_get(dev, "nand_x");
152+
dt->clk_x = devm_clk_get_enabled(dev, "nand_x");
153153
if (IS_ERR(dt->clk_x))
154154
return PTR_ERR(dt->clk_x);
155155

156-
dt->clk_ecc = devm_clk_get(dev, "ecc");
156+
dt->clk_ecc = devm_clk_get_enabled(dev, "ecc");
157157
if (IS_ERR(dt->clk_ecc))
158158
return PTR_ERR(dt->clk_ecc);
159159

@@ -165,18 +165,6 @@ static int denali_dt_probe(struct platform_device *pdev)
165165
if (IS_ERR(dt->rst_reg))
166166
return PTR_ERR(dt->rst_reg);
167167

168-
ret = clk_prepare_enable(dt->clk);
169-
if (ret)
170-
return ret;
171-
172-
ret = clk_prepare_enable(dt->clk_x);
173-
if (ret)
174-
goto out_disable_clk;
175-
176-
ret = clk_prepare_enable(dt->clk_ecc);
177-
if (ret)
178-
goto out_disable_clk_x;
179-
180168
denali->clk_rate = clk_get_rate(dt->clk);
181169
denali->clk_x_rate = clk_get_rate(dt->clk_x);
182170

@@ -187,7 +175,7 @@ static int denali_dt_probe(struct platform_device *pdev)
187175
*/
188176
ret = reset_control_deassert(dt->rst_reg);
189177
if (ret)
190-
goto out_disable_clk_ecc;
178+
return ret;
191179

192180
ret = reset_control_deassert(dt->rst);
193181
if (ret)
@@ -222,12 +210,6 @@ static int denali_dt_probe(struct platform_device *pdev)
222210
reset_control_assert(dt->rst);
223211
out_assert_rst_reg:
224212
reset_control_assert(dt->rst_reg);
225-
out_disable_clk_ecc:
226-
clk_disable_unprepare(dt->clk_ecc);
227-
out_disable_clk_x:
228-
clk_disable_unprepare(dt->clk_x);
229-
out_disable_clk:
230-
clk_disable_unprepare(dt->clk);
231213

232214
return ret;
233215
}
@@ -239,9 +221,6 @@ static void denali_dt_remove(struct platform_device *pdev)
239221
denali_remove(&dt->controller);
240222
reset_control_assert(dt->rst);
241223
reset_control_assert(dt->rst_reg);
242-
clk_disable_unprepare(dt->clk_ecc);
243-
clk_disable_unprepare(dt->clk_x);
244-
clk_disable_unprepare(dt->clk);
245224
}
246225

247226
static struct platform_driver denali_dt_driver = {

0 commit comments

Comments
 (0)