STRUCT EXTCON_DEV(9)
π struct extcon_dev(9) β like, the whole kernel API manual, but make it make sense π
okay so bestie, this is a page straight out of the Kernel API Manual, and it's about struct extcon_dev β which lowkey is just β¨ an extcon device representing one external connector β¨. one connector. one vibe. iykyk.
πΈ NAME πΈ
struct extcon_dev β an extcon device represents one external connector, periodt. ππ«Ά
β¨ SYNOPSIS β¨
here's the literal struct, copied exactly, no notes, no edits, we do not touch the source code in this house:
struct extcon_dev {
const char *name;
const unsigned int *supported_cable;
const u32 *mutually_exclusive;
struct device dev;
unsigned int id;
struct raw_notifier_head nh_all;
struct raw_notifier_head *nh;
struct list_head entry;
int max_supported;
spinlock_t lock;
u32 state;
struct device_type extcon_dev_type;
struct extcon_cable *cables;
struct attribute_group attr_g_muex;
struct attribute **attrs_muex;
struct device_attribute *d_attrs_muex;
};
look at her. icon. π
π¦ Members π¦
okay this is the part where we go field by field, and yes we're doing all of them, grab a snack π
nameβ the name of this extcon device. if it'sNULL, the parent device name gets used instead. no name? the parent steps in, main character energy. β¨supported_cableβ array of supported cable names, ending withEXTCON_NONE. and listen: ifsupported_cableisNULL, all the cable-name-related APIs are disabled. like, off. not a thing. πmutually_exclusiveβ array of mutually exclusive sets of cables that cannot be attached simultaneously. the array has to end with0, or just beNULL(which means no mutually exclusive cables at all). for example, if it's{0x7, 0x30, 0}, then{0, 1},{0, 1, 2},{0, 2},{1, 2}, or{4, 5}cannot be attached simultaneously.{0x7, 0}is equivalent to{0x3, 0x6, 0x5, 0}. and if it's{0xFFFFFFFF, 0}, there can be no simultaneous connections β none, zero, absolutely not, we don't do that here πdevβ device of this extcon. that's it. that's the field. π«Άidβ unique device ID of this extcon. unique!! do not reuse, bestie. βnh_allβ notifier for the state change events for all supported external connectors from this extcon. the group chat of notifiers π£nhβ notifier for the state change events from this extcon. (no "all", just this one, she's focused) πentryβ to support a list of extcon devices so users can search for extcon devices based on the extcon name. it's giving linked-list realness. πmax_supportedβ internal value to store the number of cables. internal! not for you! πlockβ protects device state and serialises device registration. spinlock doing spinlock things, no cap πstateβ attach/detach state of this extcon. > do not provide this at register-time. like, genuinely, don't. the register function handles it.extcon_dev_typeβdevice_typestruct to provideattribute_groupscustomized for each extcon device. bespoke. tailored. cute. πcablesβ sysfs subdirectories. each one represents one cable. one cable, one subdirectory, that's the whole deal ποΈ
π Description π
so here's the tea: in most cases, users only need to provide the "User initializing data" of this struct when registering an extcon. easy. slay. β
in some exceptional cases, optional callbacks may be needed. fancy, but rare. π§
BUT β and this is the important part β the values in "internal data" are overwritten by the register function. so don't get attached to them, they're not yours. π
π SEE ALSO π
- Kernel file
./drivers/extcon/extcon.hβ go read it, i'm literally begging π«Ά
okay that's the whole page!! sourced from ./drivers/extcon, dated October 2026, in the Kernel API Manual β that's struct extcon_dev(9), bestie, and she 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