STRUCT COUNTER_DEVICE(9)
โจ 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 insignals. gotta keep the count honest ngl ๐งฎcountsโ array of Counts. more arrays, more fun ๐num_countsโ number of Counts specified incounts. 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 inext. 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
- 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