[PATCH 1/2] clocksource/drivers/timer-npcm7xx: Fix spurious timer1 clock warning

From: William A. Kennington III

Date: Fri Nov 27 2026 - 21:52:36 EST


of_clk_get(np, 1) returns ERR_PTR(-ENOENT), not NULL, when only one
clock is listed in the device tree. No in-tree device tree lists a
second timer clock, so the existing if (clk) check always logs a
warning on boot:

/ahb/apb/timer@8000: Failed to get clock for timer1: -ENOENT

Ignore -ENOENT since the second clock is optional, add the missing
trailing newline, and check clk_prepare_enable() for errors.

Fixes: db78539fc95c ("clocksource/drivers/timer-npcm7xx: Enable timer 1 clock before use")
Signed-off-by: William A. Kennington III <william@xxxxxxxxxxxxxxx>
---
drivers/clocksource/timer-npcm7xx.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/clocksource/timer-npcm7xx.c b/drivers/clocksource/timer-npcm7xx.c
index 9af30af5f989..c7377f30e95a 100644
--- a/drivers/clocksource/timer-npcm7xx.c
+++ b/drivers/clocksource/timer-npcm7xx.c
@@ -202,11 +202,15 @@ static int __init npcm7xx_timer_init(struct device_node *np)

/* Enable the clock for timer1, if it exists */
clk = of_clk_get(np, 1);
- if (clk) {
- if (!IS_ERR(clk))
- clk_prepare_enable(clk);
- else
- pr_warn("%pOF: Failed to get clock for timer1: %pe", np, clk);
+ if (!IS_ERR(clk)) {
+ ret = clk_prepare_enable(clk);
+ if (ret) {
+ pr_warn("%pOF: Failed to enable clock for timer1: %d\n",
+ np, ret);
+ clk_put(clk);
+ }
+ } else if (PTR_ERR(clk) != -ENOENT) {
+ pr_warn("%pOF: Failed to get clock for timer1: %pe\n", np, clk);
}

npcm7xx_clocksource_init();