STRUCT PWM_CHIP(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– struct pwm_chip(9) β€” or, like, the whole vibe of a PWM controller in one struct πŸ’–

okay so this is a page from the Kernel API Manual, bestie, and it's all about struct pwm_chip β€” the literal main character that abstracts a PWM controller. no cap, this is the blueprint. let's get into it πŸŽ€


✨ NAME ✨

struct pwm_chip β€” abstract a PWM controller

like… it is the PWM controller, conceptually. the abstracted truth of it. πŸ’…


🌸 SYNOPSIS 🌸

struct pwm_chip {
    struct device dev;
    struct cdev cdev;
    const struct pwm_ops *ops;
    struct module *owner;
    unsigned int id;
    unsigned int npwm;
    struct pwm_device * (*of_xlate)(struct pwm_chip *chip, const struct of_phandle_args *args);
    bool atomic;
    struct gpio_chip gpio;
    bool uses_pwmchip_alloc;
    bool operational;
    union {
      struct mutex nonatomic_lock;
      spinlock_t atomic_lock;
    };
    struct pwm_device pwms[];
 };

okay look at her. gorgeous. every field hand-picked. ✨


πŸ¦‹ Members πŸ¦‹

bestie, this is the field-by-field tour, and yes we're doing all of them, because every single one matters:

  • dev β€” the device providing the PWMs. the actual hardware parent, basically. πŸ‘‘
  • cdev β€” the struct cdev for this device.
  • ops β€” the callbacks for this PWM controller. this is where the driver's behaviour lives, iykyk.
  • owner β€” the module providing this chip. gotta know who's responsible. πŸ’€
  • id β€” the unique number of this PWM chip. her little ID card. πŸŽ€
  • npwm β€” number of PWMs controlled by this chip. the headcount. πŸ”₯
  • of_xlate β€” request a PWM device given a device tree PWM specifier. device-tree translation duty, very demure, very mindful.
  • atomic β€” can the driver's ->apply be called in atomic context. big question, answer carefully. ⚑
  • gpio β€” struct gpio_chip to operate this PWM chip's lines as GPO.
  • uses_pwmchip_alloc β€” signals if pwmchip_allow was used to allocate this chip.
  • operational β€” signals if the chip can be used (or is already deregistered). vibe check: passed or deregistered, no in-between. 🌈
  • {unnamed_union} β€” anonymous. yes, it's just vibes. no name. πŸ™ˆ
    • nonatomic_lock β€” mutex for nonatomic chips.
    • atomic_lock β€” mutex for atomic chips.
  • pwms β€” array of PWM devices allocated by the framework. the flexible array member, the icon, the finale. ⭐
heads up: nonatomic_lock and atomic_lock live in the same anonymous union, so they're two flavours of the same slot β€” one for nonatomic chips, one for atomic chips. pick your fighter. πŸ’…

🧚 SEE ALSO 🧚

literally the whole friend group, go read these next (Kernel file ./include/linux/pwm.h):


and that's the whole page, bestie β€” no skips, no cuts, every field accounted for. πŸ’œ

okay so this was brought to you by ./include/linux, dated October 2026, filed lovingly under struct pwm_chip(9). periodt. πŸ«ΆπŸ’–

πŸ“¦ where this page comes from