diff options
| author | Sean Anderson <[email protected]> | 2022-01-15 15:52:47 -0500 |
|---|---|---|
| committer | Sean Anderson <[email protected]> | 2022-02-25 01:41:04 -0500 |
| commit | e96e2132f977aab738994c11162b14695029be6e (patch) | |
| tree | 5a16211b6c2812f67a81083d85bd11d31a672e19 /include | |
| parent | a0abea867a0d344d8e5290adf6380903b0f52e0f (diff) | |
clk: Add clk_get_by_name_optional
This adds a helper function for clk_get_by_name in cases where the clock is
optional. Hopefully this helps point driver writers in the right direction.
Also convert some existing users.
Signed-off-by: Sean Anderson <[email protected]>
Reviewed-by: Neil Armstrong <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Diffstat (limited to 'include')
| -rw-r--r-- | include/clk.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/clk.h b/include/clk.h index 303b04a726e..23e4d4ea729 100644 --- a/include/clk.h +++ b/include/clk.h @@ -288,6 +288,30 @@ static inline int clk_release_all(struct clk *clk, int count) #endif /** + * clk_get_by_name_optional() - Get/request a optional clock by name. + * @dev: The client device. + * @name: The name of the clock to request, within the client's list of + * clocks. + * @clk: A pointer to a clock struct to initialize. + * + * Behaves the same as clk_get_by_name(), except when there is no clock + * provider. In the latter case, return 0. + * + * Return: 0 if OK, or a negative error code. + */ +static inline int clk_get_by_name_optional(struct udevice *dev, + const char *name, struct clk *clk) +{ + int ret; + + ret = clk_get_by_name(dev, name, clk); + if (ret == -ENODATA) + return 0; + + return ret; +} + +/** * clk_get_by_name_nodev_optional - Get/request an optinonal clock by name * without a device. * @node: The client ofnode. |
