Skip to content

Commit 433f65f

Browse files
fkokosinskikartben
authored andcommitted
include/zephyr/drivers/clock_control: return -ENOSYS for empty on/off
There are in-tree clock controllers that don't implement the `on`/`off` calls, e.g. in Intel Agilex. Let's return `-ENOSYS` when that's the case. Signed-off-by: Filip Kokosinski <[email protected]> (cherry picked from commit 5dbf61a)
1 parent 020db5a commit 433f65f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

include/zephyr/drivers/clock_control.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ static inline int clock_control_on(const struct device *dev,
128128
const struct clock_control_driver_api *api =
129129
(const struct clock_control_driver_api *)dev->api;
130130

131+
if (api->on == NULL) {
132+
return -ENOSYS;
133+
}
134+
131135
return api->on(dev, sys);
132136
}
133137

@@ -147,6 +151,10 @@ static inline int clock_control_off(const struct device *dev,
147151
const struct clock_control_driver_api *api =
148152
(const struct clock_control_driver_api *)dev->api;
149153

154+
if (api->off == NULL) {
155+
return -ENOSYS;
156+
}
157+
150158
return api->off(dev, sys);
151159
}
152160

0 commit comments

Comments
 (0)