pwm_init_state(9)
π pwm_init_state(9) β the kernel API manual, bestie edition π
okay so this is a page from the Kernel API Manual, and it's literally about getting a PWM state all dressed and ready for its big moment. no cap, it's short but it's iconic β¨
πΈ NAME πΈ
pwm_init_state β prepare a brand-new state so you can later apply it with pwm_apply_might_sleep() π«Ά
β¨ SYNOPSIS β¨
void pwm_init_state (const struct pwm_device *pwm , struct pwm_state
*state );
π¦ ARGUMENTS π¦
pwmβ the PWM device in question, your main character πstateβ the state you're gonna fill up with the freshly prepared PWM state, like a little tote bag you're packing π
π DESCRIPTION π
so this function prepares a state that you can totally tweak later and then apply to the PWM device with pwm_apply_might_sleep. it's the convenient-girlie function of the family: first it retrieves the current PWM state, then it replaces the period and polarity fields with the reference values defined in pwm->args. lowkey genius π§
once the function returns, you're free to adjust the ->enabled and ->duty_cycle fields however you need before you call pwm_apply_might_sleep. do your thing π
and listen β ->duty_cycle starts out set to zero, and that's on purpose. it's there to dodge the situation where the current ->duty_cycle value exceeds the pwm_args->period one, which would trigger an error if you called pwm_apply_might_sleep without adjusting ->duty_cycle first. so yeah, zero is not a vibe, it's a safety net π
ngl bestie, that last bit is the important one β if you skip it and callpwm_apply_might_sleepstraight away without touching->duty_cycle, you can get an error. adjust first, slay after π
π SEE ALSO π
Kernel file ./include/linux/pwm.h plus all these lil friends:
enum pwm_polarity(9)struct pwm_args(9)struct pwm_waveform(9)struct pwm_device(9)pwm_get_state(9)pwm_get_relative_duty_cycle(9)pwm_set_relative_duty_cycle(9)struct pwm_capture(9)struct pwm_ops(9)struct pwm_chip(9)pwmchip_supports_waveform(9)pwm_config(9)pwm_enable(9)pwm_disable(9)pwm_might_sleep(9)
and that's the whole page, bestie π«Ά this lil gem lives under ./include/linux and the version dated October 2026 β go off, October, you ate π
β¨
π¦ 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