pwm_get_state_hw(9)
β¨ pwm_get_state_hw(9) β from the Kernel API Manual, bestie β¨
okay so this is a page straight out of the Kernel API Manual and it's lowkey one of the most useful lil functions ever β it's literally "hey hardware, what's your vibe rn?" π
πΈ NAME πΈ
pwm_get_state_hw β get the current PWM state from hardware π«Ά
Like, actually from the hardware. Not the wishlist version. The real one. No cap.
π SYNOPSIS π
int pwm_get_state_hw (struct pwm_device *pwm , struct pwm_state *state
);
that's the whole signature, she's not complicated, she just works β¨
π¦ ARGUMENTS π¦
pwmβ the PWM device π like, the actual one you're curious aboutstateβ the state you're gonna fill with the current PWM state π it's giving "empty cup, ready to be filled"
π DESCRIPTION π
So this is basically pwm_get_state's sibling, right? Same energy, but with one iconic plot twist: it reads the current PWM state from hardware instead of the requested state π
Requested state = what you asked for. Hardware state = what's actually happening. Not me trusting the hardware over the request... actually yes, that's exactly what we're doing π
β RETURN β
0on success π slay- a negative error code on failure π not slay, but at least it tells you
π CONTEXT π
May sleep. π΄
fr fr, this one is allowed to nap β don't go calling it from somewhere rude like an atomic context, okay? Be nice to her.
π₯ SEE ALSO π₯
Kernel file ./drivers/pwm/core.c β go read the source, iykyk π
pwm_round_waveform_might_sleep(9)pwm_get_waveform_might_sleep(9)pwm_set_waveform_might_sleep(9)pwm_apply_might_sleep(9)pwm_apply_atomic(9)pwm_adjust_config(9)pwm_capture(9)pwm_request_from_chip(9)of_pwm_get(9)acpi_pwm_get(9)pwm_get(9)pwm_put(9)devm_pwm_get(9)devm_fwnode_pwm_get(9)__pwmchip_add(9)pwmchip_remove(9)pwm_add_table(9)pwm_remove_table(9)
like an entire friend group of PWM functions, and honestly? obsessed π«Άπ
π§ quick reminder bestie: read the hardware state when you want the truth, read the requested state when you want the dream. they are not the same and that's the whole point π
and that's the page!! sign-off time: this one lives under ./drivers/pwm, dated October 2026 β periodt, go touch some PWM hardware ππ
π¦ 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