Skip to content

Commit ef980cf

Browse files
gmbnomisBoris Brezillon
authored andcommitted
mtd: nand: orion: improve handling of optional clock
The clock gate used by orion_nand is not available on all platforms. When getting this optional clock gate, the code masked all errors. Let's be more precise here and actually only allow ENOENT. EPROBE_DEFER is handled like any other error code since probe deferral is not supported by drivers using module_platform_driver_probe(). Signed-off-by: Simon Baatz <gmbnomis@gmail.com> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
1 parent 675b11d commit ef980cf

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

‎drivers/mtd/nand/orion_nand.c‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,17 @@ static int __init orion_nand_probe(struct platform_device *pdev)
156156
/* Not all platforms can gate the clock, so it is not
157157
an error if the clock does not exists. */
158158
info->clk = devm_clk_get(&pdev->dev, NULL);
159-
if (!IS_ERR(info->clk))
160-
clk_prepare_enable(info->clk);
159+
if (IS_ERR(info->clk)) {
160+
ret = PTR_ERR(info->clk);
161+
if (ret == -ENOENT) {
162+
info->clk = NULL;
163+
} else {
164+
dev_err(&pdev->dev, "failed to get clock!\n");
165+
return ret;
166+
}
167+
}
168+
169+
clk_prepare_enable(info->clk);
161170

162171
ret = nand_scan(mtd, 1);
163172
if (ret)
@@ -173,9 +182,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)
173182
return 0;
174183

175184
no_dev:
176-
if (!IS_ERR(info->clk))
177-
clk_disable_unprepare(info->clk);
178-
185+
clk_disable_unprepare(info->clk);
179186
return ret;
180187
}
181188

@@ -187,8 +194,7 @@ static int orion_nand_remove(struct platform_device *pdev)
187194

188195
nand_release(mtd);
189196

190-
if (!IS_ERR(info->clk))
191-
clk_disable_unprepare(info->clk);
197+
clk_disable_unprepare(info->clk);
192198

193199
return 0;
194200
}

0 commit comments

Comments
 (0)