Documentation/driver-api/extcon.rst
Source file repositories/reference/linux-study-clean/Documentation/driver-api/extcon.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/driver-api/extcon.rst- Extension
.rst- Size
- 8014 bytes
- Lines
- 256
- Domain
- Support Tooling And Documentation
- Bucket
- Documentation
- Inferred role
- Support Tooling And Documentation: documentation
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/platform_device.hlinux/extcon.h
Detected Declarations
struct extcon_devstruct extcon_cablestruct my_extcon_datafunction my_extcon_probefunction my_extcon_remove
Annotated Snippet
struct extcon_dev {
const char *name;
const unsigned int *supported_cable;
const u32 *mutually_exclusive;
/* Internal data */
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;
/* Sysfs related */
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;
};
Key fields:
- ``name``: Name of the Extcon device
- ``supported_cable``: Array of supported cable types
- ``mutually_exclusive``: Array defining mutually exclusive cable types
This field is crucial for enforcing hardware constraints. It's an array of
32-bit unsigned integers, where each element represents a set of mutually
exclusive cable types. The array should be terminated with a 0.
For example:
::
static const u32 mutually_exclusive[] = {
BIT(0) | BIT(1), /* Cable 0 and 1 are mutually exclusive */
BIT(2) | BIT(3) | BIT(4), /* Cables 2, 3, and 4 are mutually exclusive */
0 /* Terminator */
};
In this example, cables 0 and 1 cannot be connected simultaneously, and
cables 2, 3, and 4 are also mutually exclusive. This is useful for
scenarios like a single port that can either be USB or HDMI, but not both
at the same time.
The Extcon core uses this information to prevent invalid combinations of
cable states, ensuring that the reported states are always consistent
with the hardware capabilities.
- ``state``: Current state of the device (bitmap of connected cables)
extcon_cable
------------
Represents an individual cable managed by an Extcon device::
struct extcon_cable {
struct extcon_dev *edev;
int cable_index;
struct attribute_group attr_g;
struct device_attribute attr_name;
struct device_attribute attr_state;
struct attribute *attrs[3];
union extcon_property_value usb_propval[EXTCON_PROP_USB_CNT];
union extcon_property_value chg_propval[EXTCON_PROP_CHG_CNT];
union extcon_property_value jack_propval[EXTCON_PROP_JACK_CNT];
union extcon_property_value disp_propval[EXTCON_PROP_DISP_CNT];
Annotation
- Immediate include surface: `linux/module.h`, `linux/platform_device.h`, `linux/extcon.h`.
- Detected declarations: `struct extcon_dev`, `struct extcon_cable`, `struct my_extcon_data`, `function my_extcon_probe`, `function my_extcon_remove`.
- Atlas domain: Support Tooling And Documentation / Documentation.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.