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

Jiawen Liu 1298662399 at qq.com
Tue Aug 18 06:22:40 PDT 2026


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 <1298662399 at qq.com>
---
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);




More information about the linux-arm-kernel mailing list