[PATCH] misc: atmel-ssc: handle clock enable failure

Jiawen Liu <[email protected]>
Newsgroups org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Return error from failed clock enable.

ssc_probe ignores clk_prepare_enable return before register writes and
unconditional disable_unprepare. Unchecked prepare/enable may be
unprepared on failure.

Check temporary pclk enable before SSC register access in ssc_probe.

Signed-off-by: jiawen <[email protected]>
---
diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
--- a/drivers/misc/atmel-ssc.c
+++ b/drivers/misc/atmel-ssc.c
@@ -192,6 +192,7 @@
 	struct resource *regs;
 	struct ssc_device *ssc;
 	const struct atmel_ssc_platform_data *plat_dat;
+	int ret;
 
 	ssc = devm_kzalloc(&pdev->dev, sizeof(struct ssc_device), GFP_KERNEL);
 	if (!ssc) {
@@ -225,7 +226,9 @@
 	}
 
 	/* disable all interrupts */
-	clk_prepare_enable(ssc->clk);
+	ret = clk_prepare_enable(ssc->clk);
+	if (ret)
+		return ret;
 	ssc_writel(ssc->regs, IDR, -1);
 	ssc_readl(ssc->regs, SR);
 	clk_disable_unprepare(ssc->clk);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.