STRUCT COUNTER_COMP(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 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 the action parameter. πŸ’«
  • device_u8_read β€” Device u8 component read callback. The read value of the respective Device u8 component should be passed back via the val parameter. πŸ“
  • count_u8_read β€” Count u8 component read callback. The read value of the respective Count u8 component should be passed back via the val parameter. πŸ“
  • signal_u8_read β€” Signal u8 component read callback. The read value of the respective Signal u8 component should be passed back via the val parameter. πŸ“
  • device_u32_read β€” Device u32 component read callback. The read value of the respective Device u32 component should be passed back via the val parameter. πŸ”₯
  • count_u32_read β€” Count u32 component read callback. The read value of the respective Count u32 component should be passed back via the val parameter. πŸ”₯
  • signal_u32_read β€” Signal u32 component read callback. The read value of the respective Signal u32 component should be passed back via the val parameter. πŸ”₯
  • device_u64_read β€” Device u64 component read callback. The read value of the respective Device u64 component should be passed back via the val parameter. ⭐
  • count_u64_read β€” Count u64 component read callback. The read value of the respective Count u64 component should be passed back via the val parameter. ⭐
  • signal_u64_read β€” Signal u64 component read callback. The read value of the respective Signal u64 component should be passed back via the val parameter. ⭐
  • signal_array_u32_read β€” Signal u32 array component read callback. The index of the respective Count u32 array component element is passed via the idx parameter. The read value of the respective Count u32 array component element should be passed back via the val parameter. πŸ‘€ (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 the idx parameter. The read value of the respective Device u64 array component element should be passed back via the val parameter. πŸ‘‘
  • count_array_u64_read β€” Count u64 array component read callback. The index of the respective Count u64 array component element is passed via the idx parameter. The read value of the respective Count u64 array component element should be passed back via the val parameter. πŸ‘‘
  • signal_array_u64_read β€” Signal u64 array component read callback. The index of the respective Count u64 array component element is passed via the idx parameter. The read value of the respective Count u64 array component element should be passed back via the val parameter. πŸ‘€ (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 the action parameter. πŸ’«
  • device_u8_write β€” Device u8 component write callback. The write value of the respective Device u8 component is passed via the val parameter. πŸ“
  • count_u8_write β€” Count u8 component write callback. The write value of the respective Count u8 component is passed via the val parameter. πŸ“
  • signal_u8_write β€” Signal u8 component write callback. The write value of the respective Signal u8 component is passed via the val parameter. πŸ“
  • device_u32_write β€” Device u32 component write callback. The write value of the respective Device u32 component is passed via the val parameter. πŸ”₯
  • count_u32_write β€” Count u32 component write callback. The write value of the respective Count u32 component is passed via the val parameter. πŸ”₯
  • signal_u32_write β€” Signal u32 component write callback. The write value of the respective Signal u32 component is passed via the val parameter. πŸ”₯
  • device_u64_write β€” Device u64 component write callback. The write value of the respective Device u64 component is passed via the val parameter. ⭐
  • count_u64_write β€” Count u64 component write callback. The write value of the respective Count u64 component is passed via the val parameter. ⭐
  • signal_u64_write β€” Signal u64 component write callback. The write value of the respective Signal u64 component is passed via the val parameter. ⭐
  • signal_array_u32_write β€” Signal u32 array component write callback. The index of the respective Signal u32 array component element is passed via the idx parameter. The write value of the respective Signal u32 array component element is passed via the val parameter. 🌟
  • device_array_u64_write β€” Device u64 array component write callback. The index of the respective Device u64 array component element is passed via the idx parameter. The write value of the respective Device u64 array component element is passed via the val parameter. 🌟
  • count_array_u64_write β€” Count u64 array component write callback. The index of the respective Count u64 array component element is passed via the idx parameter. The write value of the respective Count u64 array component element is passed via the val parameter. 🌟
  • signal_array_u64_write β€” Signal u64 array component write callback. The index of the respective Signal u64 array component element is passed via the idx parameter. The write value of the respective Signal u64 array component element is passed via the val parameter. 🌟
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.h struct 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