STRUCT COUNTER_COMP(9)
πΈ struct counter_comp (9) πΈ
okay so this is a page from the Kernel API Manual (yes, that manual, the kernel one π
) and it's all about struct counter_comp β the Counter component node. bestie, grab a lil snack, we're meeting a struct with, like, a lot of function pointers π
β¨ NAME β¨
struct counter_comp β the Counter component node. that's it, that's the whole vibe β¨
π¦ SYNOPSIS π¦
no cap, here's the whole thing, every field, exactly as it lives:
struct counter_comp {
enum counter_comp_type type;
const char *name;
void *priv;
union {
int (*action_read)(struct counter_device *counter, struct
counter_count *count, struct counter_synapse *synapse, enum
counter_synapse_action *action);
int (*device_u8_read)(struct counter_device *counter, u8 *val);
int (*count_u8_read)(struct counter_device *counter, struct
counter_count *count, u8 *val);
int (*signal_u8_read)(struct counter_device *counter, struct
counter_signal *signal, u8 *val);
int (*device_u32_read)(struct counter_device *counter, u32 *val);
int (*count_u32_read)(struct counter_device *counter, struct
counter_count *count, u32 *val);
int (*signal_u32_read)(struct counter_device *counter, struct
counter_signal *signal, u32 *val);
int (*device_u64_read)(struct counter_device *counter, u64 *val);
int (*count_u64_read)(struct counter_device *counter, struct
counter_count *count, u64 *val);
int (*signal_u64_read)(struct counter_device *counter, struct
counter_signal *signal, u64 *val);
int (*signal_array_u32_read)(struct counter_device *counter,
struct counter_signal *signal, size_t idx, u32 *val);
int (*device_array_u64_read)(struct counter_device *counter,
size_t idx, u64 *val);
int (*count_array_u64_read)(struct counter_device *counter, struct
counter_count *count, size_t idx, u64 *val);
int (*signal_array_u64_read)(struct counter_device *counter,
struct counter_signal *signal, size_t idx, u64 *val);
};
union {
int (*action_write)(struct counter_device *counter, struct
counter_count *count, struct counter_synapse *synapse, enum
counter_synapse_action action);
int (*device_u8_write)(struct counter_device *counter, u8 val);
int (*count_u8_write)(struct counter_device *counter, struct
counter_count *count, u8 val);
int (*signal_u8_write)(struct counter_device *counter, struct
counter_signal *signal, u8 val);
int (*device_u32_write)(struct counter_device *counter, u32 val);
int (*count_u32_write)(struct counter_device *counter, struct
counter_count *count, u32 val);
int (*signal_u32_write)(struct counter_device *counter, struct
counter_signal *signal, u32 val);
int (*device_u64_write)(struct counter_device *counter, u64 val);
int (*count_u64_write)(struct counter_device *counter, struct
counter_count *count, u64 val);
int (*signal_u64_write)(struct counter_device *counter, struct
counter_signal *signal, u64 val);
int (*signal_array_u32_write)(struct counter_device *counter,
struct counter_signal *signal, size_t idx, u32 val);
int (*device_array_u64_write)(struct counter_device *counter,
size_t idx, u64 val);
int (*count_array_u64_write)(struct counter_device *counter, struct
counter_count *count, size_t idx, u64 val);
int (*signal_array_u64_write)(struct counter_device *counter,
struct counter_signal *signal, size_t idx, u64 val);
};
};
two anonymous unions in one structβ¦ it's giving "i contain multitudes" π she's an icon, she's a legend, she has fourteen read callbacks and fourteen write callbacks and she's not sorry about it π
π MEMBERS π
π the plain ol' fields π
typeβ Counter component data type π§nameβ device-specific component name β¨privβ component-relevant data π«Ά{unnamed_union}β anonymous. that's literally all it says, it's a mystery on purpose π
π read callbacks (the first anonymous union) π
these all hand info back to the kernel. no cap, notice how the array ones take idx too π
action_readβ Synapse action mode read callback. The read value of the respective Synapse action mode should be passed back via theactionparameter. π«device_u8_readβ Device u8 component read callback. The read value of the respective Device u8 component should be passed back via thevalparameter. πcount_u8_readβ Count u8 component read callback. The read value of the respective Count u8 component should be passed back via thevalparameter. πsignal_u8_readβ Signal u8 component read callback. The read value of the respective Signal u8 component should be passed back via thevalparameter. πdevice_u32_readβ Device u32 component read callback. The read value of the respective Device u32 component should be passed back via thevalparameter. π₯count_u32_readβ Count u32 component read callback. The read value of the respective Count u32 component should be passed back via thevalparameter. π₯signal_u32_readβ Signal u32 component read callback. The read value of the respective Signal u32 component should be passed back via thevalparameter. π₯device_u64_readβ Device u64 component read callback. The read value of the respective Device u64 component should be passed back via thevalparameter. βcount_u64_readβ Count u64 component read callback. The read value of the respective Count u64 component should be passed back via thevalparameter. βsignal_u64_readβ Signal u64 component read callback. The read value of the respective Signal u64 component should be passed back via thevalparameter. βsignal_array_u32_readβ Signal u32 array component read callback. The index of the respective Count u32 array component element is passed via theidxparameter. The read value of the respective Count u32 array component element should be passed back via thevalparameter. π (yes, it says Count in there, that's what the page says, we don't editorialize, we report π«‘)device_array_u64_readβ Device u64 array component read callback. The index of the respective Device u64 array component element is passed via theidxparameter. The read value of the respective Device u64 array component element should be passed back via thevalparameter. πcount_array_u64_readβ Count u64 array component read callback. The index of the respective Count u64 array component element is passed via theidxparameter. The read value of the respective Count u64 array component element should be passed back via thevalparameter. πsignal_array_u64_readβ Signal u64 array component read callback. The index of the respective Count u64 array component element is passed via theidxparameter. The read value of the respective Count u64 array component element should be passed back via thevalparameter. π (same deal β the page says Count, so we say Count π)
π¦ write callbacks (the second anonymous union) π¦
now we're sending values in. these don't pass anything back, they just receive, main character energy honestly π
{unnamed_union}β anonymous. again. iconic πaction_writeβ Synapse action mode write callback. The write value of the respective Synapse action mode is passed via theactionparameter. π«device_u8_writeβ Device u8 component write callback. The write value of the respective Device u8 component is passed via thevalparameter. πcount_u8_writeβ Count u8 component write callback. The write value of the respective Count u8 component is passed via thevalparameter. πsignal_u8_writeβ Signal u8 component write callback. The write value of the respective Signal u8 component is passed via thevalparameter. πdevice_u32_writeβ Device u32 component write callback. The write value of the respective Device u32 component is passed via thevalparameter. π₯count_u32_writeβ Count u32 component write callback. The write value of the respective Count u32 component is passed via thevalparameter. π₯signal_u32_writeβ Signal u32 component write callback. The write value of the respective Signal u32 component is passed via thevalparameter. π₯device_u64_writeβ Device u64 component write callback. The write value of the respective Device u64 component is passed via thevalparameter. βcount_u64_writeβ Count u64 component write callback. The write value of the respective Count u64 component is passed via thevalparameter. βsignal_u64_writeβ Signal u64 component write callback. The write value of the respective Signal u64 component is passed via thevalparameter. βsignal_array_u32_writeβ Signal u32 array component write callback. The index of the respective Signal u32 array component element is passed via theidxparameter. The write value of the respective Signal u32 array component element is passed via thevalparameter. πdevice_array_u64_writeβ Device u64 array component write callback. The index of the respective Device u64 array component element is passed via theidxparameter. The write value of the respective Device u64 array component element is passed via thevalparameter. πcount_array_u64_writeβ Count u64 array component write callback. The index of the respective Count u64 array component element is passed via theidxparameter. The write value of the respective Count u64 array component element is passed via thevalparameter. πsignal_array_u64_writeβ Signal u64 array component write callback. The index of the respective Signal u64 array component element is passed via theidxparameter. The write value of the respective Signal u64 array component element is passed via thevalparameter. π
ngl there are a lot of these and every single one matters β if you're implementing a driver you match the callback to the exact component type or it's not gonna slay. lowkey that's the whole point of the union π
π SEE ALSO π
go read these next, bestie, they're the friend group π«Ά
- Kernel file
./include/linux/counter.hstruct counter_signal(9) struct counter_synapse(9)struct counter_count(9)struct counter_event_node(9)struct counter_ops(9)struct counter_device(9)
okay that's the page!! this one lives in ./include/linux and it's stamped October 2026 β so like, future energy πβ¨ go forth and register your components, you're gonna 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