devm_clk_ge...onal_enabled(9)
π devm_clk_ge...onal_enabled(9) π
okay so we're deep in the Kernel API Manual bestie, and this one is a whole vibe β it's the "just grab me a clock and turn it on, and if there isn't one, honestly whatever" function. devm energy, optional energy, enabled energy. it's giving main character. π
β¨ NAME β¨
devm_clk_get_optional_enabled β literally devm_clk_get_optional() + clk_prepare_enable() and nothing else, no cap π«Ά
πΈ SYNOPSIS πΈ
struct clk * devm_clk_get_optional_enabled (struct device *dev , const
char *id );
π ARGUMENTS π
devβ the device that's being the clock "consumer" here, okay? it's the one doing the consuming πidβ the clock consumer ID, aka how we know which clock this consumer means π
π¦ CONTEXT π¦
May sleep. π΄ like fr fr, this one is allowed to nap, so don't go calling it from somewhere sleepy is forbidden.
π RETURN π
you get back a struct clk that corresponds to the clock producer, or a valid IS_ERR condition containing errno π
and the way it works: the implementation uses dev and id to figure out the clock consumer, and thereby the clock producer. iconic behavior honestly.
now here's the twist π β if no such clk is found, it returns NULL, which serves as a dummy clk. and that's the only difference compared to devm_clk_get_enabled. literally the only one. periodt.
β DESCRIPTION β
the returned clk (if it's valid, which, vibe check first pls) is prepared and enabled. yes both. we went all the way. π₯
and because it's a devm function, the clock will automatically be disabled, unprepared and freed when the device is unbound from the bus. no manual cleanup era needed, she cleans up after herself π§
π SEE ALSO π
Kernel file ./include/linux/clk.h
clk notifier callback types(9)struct clk_notifier(9)struct clk_notifier_data(9)struct clk_bulk_data(9)clk_notifier_register(9)clk_notifier_unregister(9)devm_clk_notifier_register(9)clk_get_accuracy(9)clk_set_phase(9)clk_get_phase(9)clk_set_duty_cycle(9)clk_get_scaled_duty_cycle(9)clk_is_match(9)clk_rate_exclusive_get(9)devm_clk_rate_exclusive_get(9)clk_rate_exclusive_put(9)clk_save_context(9)clk_restore_context(9)clk_prepare(9)clk_unprepare(9)clk_is_enabled_when_prepared(9)clk_get(9)clk_bulk_get(9)clk_bulk_get_all(9)clk_bulk_get_optional(9)devm_clk_bulk_get(9)devm_clk_bulk_get_optional(9)devm_clk_bulk_get_enable(9)devm_clk_bulk_get_optional_enable(9)devm_clk_bulk_get_all(9)devm_clk_bulk_get_all_enabled(9)devm_clk_get(9)devm_clk_get_prepared(9)devm_clk_get_enabled(9)devm_clk_get_optional(9)devm_clk_get_optional_prepared(9)devm_clk_get_optional_enabled_with_rate(9)devm_get_clk_from_child(9)clk_enable(9)clk_bulk_enable(9)clk_disable(9)clk_bulk_disable(9)clk_get_rate(9)clk_put(9)clk_bulk_put(9)clk_bulk_put_all(9)devm_clk_put(9)clk_round_rate(9)clk_set_rate(9)clk_set_rate_exclusive(9)clk_has_parent(9)clk_set_rate_range(9)clk_set_min_rate(9)clk_set_max_rate(9)clk_set_parent(9)clk_get_parent(9)clk_get_sys(9)clk_drop_range(9)clk_get_optional(9)
ok bestie that's the whole page, go forth and enable your clocks responsibly π
and finally, mwah, this lil page lives in ./include/linux and it's dated October 2026 β that's the whole footer era, consider yourself signed off π«Άβ¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms