Skip to content

Commit 2c11ea7

Browse files
Li Zetaomiquelraynal
authored andcommitted
mtd: rawnand: orion: Use helper function devm_clk_get_optional_enabled()
Since commit 7ef9651 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), devm_clk_get_optional() and clk_prepare_enable() can now be replaced by devm_clk_get_optional_enabled() when driver enables (and possibly prepares) the clocks for the whole lifetime of the device. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly, so drop the label "no_dev". Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Li Zetao <lizetao1@huawei.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20230821031737.1973183-13-lizetao1@huawei.com
1 parent 4195b64 commit 2c11ea7

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

drivers/mtd/nand/raw/orion_nand.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,10 @@ static int __init orion_nand_probe(struct platform_device *pdev)
169169
platform_set_drvdata(pdev, info);
170170

171171
/* Not all platforms can gate the clock, so it is optional. */
172-
info->clk = devm_clk_get_optional(&pdev->dev, NULL);
172+
info->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
173173
if (IS_ERR(info->clk))
174174
return dev_err_probe(&pdev->dev, PTR_ERR(info->clk),
175-
"failed to get clock!\n");
176-
177-
ret = clk_prepare_enable(info->clk);
178-
if (ret) {
179-
dev_err(&pdev->dev, "failed to prepare clock!\n");
180-
return ret;
181-
}
175+
"failed to get and enable clock!\n");
182176

183177
/*
184178
* This driver assumes that the default ECC engine should be TYPE_SOFT.
@@ -189,19 +183,13 @@ static int __init orion_nand_probe(struct platform_device *pdev)
189183

190184
ret = nand_scan(nc, 1);
191185
if (ret)
192-
goto no_dev;
186+
return ret;
193187

194188
mtd->name = "orion_nand";
195189
ret = mtd_device_register(mtd, board->parts, board->nr_parts);
196-
if (ret) {
190+
if (ret)
197191
nand_cleanup(nc);
198-
goto no_dev;
199-
}
200-
201-
return 0;
202192

203-
no_dev:
204-
clk_disable_unprepare(info->clk);
205193
return ret;
206194
}
207195

@@ -215,8 +203,6 @@ static void orion_nand_remove(struct platform_device *pdev)
215203
WARN_ON(ret);
216204

217205
nand_cleanup(chip);
218-
219-
clk_disable_unprepare(info->clk);
220206
}
221207

222208
#ifdef CONFIG_OF

0 commit comments

Comments
 (0)