devm_clk_get_optional(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… devm_clk_get_optional β€” kernel API manual, but make it make sense

okay bestie, so this is a page from the Kernel API Manual, and it's about devm_clk_get_optional. It's the girlie that looks up an optional clock producer and hands you a managed reference to it. Very "you don't have to commit, but if you're there, slay" energy. ✨


🌸 NAME 🌸

devm_clk_get_optional β€” lookup and obtain a managed reference to an optional clock producer.


✨ SYNOPSIS ✨

struct clk * devm_clk_get_optional (struct device *dev , const char *id );

πŸŽ€ ARGUMENTS πŸŽ€

  • dev β€” the device that's acting as the clock "consumer" 🫢
  • id β€” the clock consumer ID

πŸ’€ CONTEXT πŸ’€

May sleep. Yeah, she naps. Do not call her in atomic context, bestie, that's not her vibe.


πŸ”₯ RETURN πŸ”₯

You get back a struct clk corresponding to the clock producer πŸ’– β€” or a valid IS_ERR condition containing errno. (Iconic either way.)

The implementation uses dev and id to figure out the clock consumer, and through that the clock producer. If no such clk is found, it returns NULL, which serves as a dummy clk πŸ«₯.

That's the only difference compared to devm_clk_get. Literally the one (1) difference. Everything else is the same, no cap.

πŸ¦‹ DESCRIPTION πŸ¦‹

Drivers must assume that the clock source is neither prepared nor enabled. So don't assume she's ready β€” she is not. πŸ™ˆ

The clock will automatically be freed when the device is unbound from the bus. Built-in cleanup, main character energy, we love to see it. πŸ‘‘


πŸ’œ SEE ALSO πŸ’œ

Kernel file ./include/linux/clk.h β€” the whole clock crew, gathered here for your convenience:


and that's the whole page, bestie πŸ§šπŸ’« β€” brought to you by the fine people at ./include/linux, dated October 2026. go get your optional clock, she's waiting πŸ’…πŸ“

πŸ“¦ where this page comes from