Skip to content

Commit 6b244bb

Browse files
pH5Boris Brezillon
authored andcommitted
mtd: nand: sunxi: simplify optional reset handling
As of commit bb47523 ("reset: make optional functions really optional"), the reset framework API calls use NULL pointers to describe optional, non-present reset controls. This allows to return errors from devm_reset_control_get_optional and to call reset_control_(de)assert unconditionally. Signed-off-by: Philipp Zabel <[email protected]> Signed-off-by: Boris Brezillon <[email protected]>
1 parent 626994e commit 6b244bb

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

drivers/mtd/nand/sunxi_nand.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,17 +2212,17 @@ static int sunxi_nfc_probe(struct platform_device *pdev)
22122212
goto out_ahb_clk_unprepare;
22132213

22142214
nfc->reset = devm_reset_control_get_optional(dev, "ahb");
2215-
if (!IS_ERR(nfc->reset)) {
2216-
ret = reset_control_deassert(nfc->reset);
2217-
if (ret) {
2218-
dev_err(dev, "reset err %d\n", ret);
2219-
goto out_mod_clk_unprepare;
2220-
}
2221-
} else if (PTR_ERR(nfc->reset) != -ENOENT) {
2215+
if (IS_ERR(nfc->reset)) {
22222216
ret = PTR_ERR(nfc->reset);
22232217
goto out_mod_clk_unprepare;
22242218
}
22252219

2220+
ret = reset_control_deassert(nfc->reset);
2221+
if (ret) {
2222+
dev_err(dev, "reset err %d\n", ret);
2223+
goto out_mod_clk_unprepare;
2224+
}
2225+
22262226
ret = sunxi_nfc_rst(nfc);
22272227
if (ret)
22282228
goto out_ahb_reset_reassert;
@@ -2262,8 +2262,7 @@ static int sunxi_nfc_probe(struct platform_device *pdev)
22622262
if (nfc->dmac)
22632263
dma_release_channel(nfc->dmac);
22642264
out_ahb_reset_reassert:
2265-
if (!IS_ERR(nfc->reset))
2266-
reset_control_assert(nfc->reset);
2265+
reset_control_assert(nfc->reset);
22672266
out_mod_clk_unprepare:
22682267
clk_disable_unprepare(nfc->mod_clk);
22692268
out_ahb_clk_unprepare:
@@ -2278,8 +2277,7 @@ static int sunxi_nfc_remove(struct platform_device *pdev)
22782277

22792278
sunxi_nand_chips_cleanup(nfc);
22802279

2281-
if (!IS_ERR(nfc->reset))
2282-
reset_control_assert(nfc->reset);
2280+
reset_control_assert(nfc->reset);
22832281

22842282
if (nfc->dmac)
22852283
dma_release_channel(nfc->dmac);

0 commit comments

Comments
 (0)