Skip to content

Commit b1a5588

Browse files
bjarki-andreasenkartben
authored andcommitted
drivers: clock_control: nrf_clock_control: introduce resolve API
Introduce API which allows users to determine what the actual minimum spec will be resulting from a requested minimum spec. This is useful for optimizing code as the requested minimum may be way worse than what will actually be applied. Signed-off-by: Bjarki Arge Andreasen <[email protected]>
1 parent 51f1607 commit b1a5588

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

include/zephyr/drivers/clock_control/nrf_clock_control.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ __subsystem struct nrf_clock_control_driver_api {
204204
int (*cancel_or_release)(const struct device *dev,
205205
const struct nrf_clock_spec *spec,
206206
struct onoff_client *cli);
207+
int (*resolve)(const struct device *dev,
208+
const struct nrf_clock_spec *req_spec,
209+
struct nrf_clock_spec *res_spec);
207210
};
208211

209212
/**
@@ -324,6 +327,30 @@ int nrf_clock_control_cancel_or_release(const struct device *dev,
324327
return api->cancel_or_release(dev, spec, cli);
325328
}
326329

330+
/**
331+
* @brief Resolve a requested clock spec to resulting spec.
332+
*
333+
* @param dev Device structure.
334+
* @param req_spec The requested clock specification.
335+
* @param res_spec Destination for the resulting clock specification.
336+
*
337+
* @retval Successful if successful.
338+
* @retval -errno code if failure
339+
*/
340+
static inline int nrf_clock_control_resolve(const struct device *dev,
341+
const struct nrf_clock_spec *req_spec,
342+
struct nrf_clock_spec *res_spec)
343+
{
344+
const struct nrf_clock_control_driver_api *api =
345+
(const struct nrf_clock_control_driver_api *)dev->api;
346+
347+
if (api->resolve == NULL) {
348+
return -ENOSYS;
349+
}
350+
351+
return api->resolve(dev, req_spec, res_spec);
352+
}
353+
327354
/** @brief Request the HFXO from Zero Latency Interrupt context.
328355
*
329356
* Function is optimized for use in Zero Latency Interrupt context.

0 commit comments

Comments
 (0)