STRUCT COUNTER_DEVICE(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

โœจ STRUCT COUNTER_DEVICE(9) โ€” like, the counter vibes manual โœจ

okay bestie, welcome to the kernel API manual for struct counter_device(9) ๐Ÿ’… this is the literal blueprint for a Counter data structure, and honestly? it ate. let's get into it ๐ŸŽ€


๐Ÿ’– NAME ๐Ÿ’–

struct counter_device โ€” Counter data structure. that's it, that's the whole name, she's iconic and she knows it โœจ


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

here's the whole struct in all her glory โ€” copy it exactly, don't you dare touch a character, she's perfect ๐Ÿ˜ญ

struct counter_device {
    const char *name;
    struct device *parent;
    const struct counter_ops *ops;
    struct counter_signal *signals;
    size_t num_signals;
    struct counter_count *counts;
    size_t num_counts;
    struct counter_comp *ext;
    size_t num_ext;
    struct device dev;
    struct cdev chrdev;
    struct list_head events_list;
    spinlock_t events_list_lock;
    struct list_head next_events_list;
    struct mutex n_events_list_lock;
    struct counter_event *events;
    wait_queue_head_t events_wait;
    spinlock_t events_in_lock;
    struct mutex events_out_lock;
    struct mutex ops_exist_lock;
 };

๐ŸŒธ Members ๐ŸŒธ โ€” meet the whole squad, one by one ๐Ÿซถ

  • name โ€” the name of the device. her government name, if you will ๐Ÿ‘‘
  • parent โ€” optional parent device providing the counters. optional! she can be independent, respect it ๐Ÿ’…
  • ops โ€” callbacks from driver. the driver slides in with the actual moves ๐Ÿ”ฅ
  • signals โ€” array of Signals. plural, bestie, there's a bunch ๐ŸŒˆ
  • num_signals โ€” number of Signals specified in signals. gotta keep the count honest ngl ๐Ÿงฎ
  • counts โ€” array of Counts. more arrays, more fun ๐Ÿ’œ
  • num_counts โ€” number of Counts specified in counts. yes, again, but for counts this time โญ
  • ext โ€” optional array of Counter device extensions. optional! fancy extra flair โœจ
  • num_ext โ€” number of Counter device extensions specified in ext. counting the extras, lowkey meta ๐ŸŽ€
  • dev โ€” internal device structure. the internal organs, don't poke at her ๐Ÿ™ˆ
  • chrdev โ€” internal character device structure. more internals, also internal ๐Ÿฆ‹
  • events_list โ€” list of current watching Counter events. the current watch party list ๐Ÿ‘€
  • events_list_lock โ€” lock to protect Counter events list operations. bodyguard behavior, fr fr ๐Ÿ”’
  • next_events_list โ€” list of next watching Counter events. the next watch party, already queued up ๐Ÿ’ซ
  • n_events_list_lock โ€” lock to protect Counter next events list operations. yes she has her own bodyguard too, they're matching ๐Ÿซถ
  • events โ€” queue of detected Counter events. detected! she noticed! ๐Ÿ˜ญ
  • events_wait โ€” wait queue to allow blocking reads of Counter events. the "hold on, let me get there" queue โณ
  • events_in_lock โ€” lock to protect Counter events queue in operations. in! ๐Ÿ”
  • events_out_lock โ€” lock to protect Counter events queue out operations. out! girl's got both sides covered ๐Ÿ’…
  • ops_exist_lock โ€” lock to prevent use during removal. very "we're closed, please leave" energy, but make it safe ๐Ÿšซ

๐Ÿ’€ SEE ALSO ๐Ÿ’€

Kernel file ./include/linux/counter.h โ€” go read it, it's giving required reading ๐Ÿ“š and also these lovelies:

  • struct counter_comp(9)
  • struct counter_signal(9)
  • struct counter_synapse(9)
  • struct counter_count(9)
  • struct counter_event_node(9)
  • struct counter_ops(9)

and that's the tea, bestie ๐Ÿ“ this absolute queen of a page lives in ./include/linux, freshly dated October 2026, and yes โ€” struct counter_device(9) is her handle if you ever need to @ her ๐Ÿ’œ slay, bye! ๐Ÿ˜ญ๐ŸŽ€

๐Ÿ“ฆ where this page comes from