devm_clk_ge...onal_enabled(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ 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


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