tsphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget%/translations/zh_CN/driver-api/extconmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget%/translations/zh_TW/driver-api/extconmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget%/translations/it_IT/driver-api/extconmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget%/translations/ja_JP/driver-api/extconmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget%/translations/ko_KR/driver-api/extconmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget%/translations/sp_SP/driver-api/extconmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(hExtcon Device Subsystemh]hExtcon Device Subsystem}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhh?/var/lib/git/docbuild/linux/Documentation/driver-api/extcon.rsthKubh)}(hhh](h)}(hOverviewh]hOverview}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(hX The Extcon (External Connector) subsystem provides a unified framework for managing external connectors in Linux systems. It allows drivers to report the state of external connectors and provides a standardized interface for userspace to query and monitor these states.h]hX The Extcon (External Connector) subsystem provides a unified framework for managing external connectors in Linux systems. It allows drivers to report the state of external connectors and provides a standardized interface for userspace to query and monitor these states.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hExtcon is particularly useful in modern devices with multiple connectivity options, such as smartphones, tablets, and laptops. It helps manage various types of connectors, including:h]hExtcon is particularly useful in modern devices with multiple connectivity options, such as smartphones, tablets, and laptops. It helps manage various types of connectors, including:}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubhenumerated_list)}(hhh](h list_item)}(h'USB connectors (e.g., USB-C, micro-USB)h]h)}(hhh]h'USB connectors (e.g., USB-C, micro-USB)}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhubah}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(h7Charging ports (e.g., fast charging, wireless charging)h]h)}(hjh]h7Charging ports (e.g., fast charging, wireless charging)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(h(Audio jacks (e.g., 3.5mm headphone jack)h]h)}(hjh]h(Audio jacks (e.g., 3.5mm headphone jack)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(h'Video outputs (e.g., HDMI, DisplayPort)h]h)}(hj4h]h'Video outputs (e.g., HDMI, DisplayPort)}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj2ubah}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(hDocking stations h]h)}(hDocking stationsh]hDocking stations}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjIubah}(h]h ]h"]h$]h&]uh1hhhhhhhhNubeh}(h]h ]h"]h$]h&]enumtypearabicprefixhsuffix.uh1hhhhhhhhKubh)}(hReal-world examples:h]hReal-world examples:}(hjlhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(hX8Smartphone USB-C port: A single USB-C port on a smartphone can serve multiple functions. Extcon can manage the different states of this port, such as: - USB data connection - Charging (various types like fast charging, USB Power Delivery) - Audio output (USB-C headphones) - Video output (USB-C to HDMI adapter) h]h)}(hX7Smartphone USB-C port: A single USB-C port on a smartphone can serve multiple functions. Extcon can manage the different states of this port, such as: - USB data connection - Charging (various types like fast charging, USB Power Delivery) - Audio output (USB-C headphones) - Video output (USB-C to HDMI adapter)h]hX7Smartphone USB-C port: A single USB-C port on a smartphone can serve multiple functions. Extcon can manage the different states of this port, such as: - USB data connection - Charging (various types like fast charging, USB Power Delivery) - Audio output (USB-C headphones) - Video output (USB-C to HDMI adapter)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj}ubah}(h]h ]h"]h$]h&]uh1hhjzhhhhhNubh)}(hLaptop docking station: When a laptop is connected to a docking station, multiple connections are made simultaneously. Extcon can handle the state changes for: - Power delivery - External displays - USB hub connections - Ethernet connectivity h]h)}(hLaptop docking station: When a laptop is connected to a docking station, multiple connections are made simultaneously. Extcon can handle the state changes for: - Power delivery - External displays - USB hub connections - Ethernet connectivityh]hLaptop docking station: When a laptop is connected to a docking station, multiple connections are made simultaneously. Extcon can handle the state changes for: - Power delivery - External displays - USB hub connections - Ethernet connectivity}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK!hjubah}(h]h ]h"]h$]h&]uh1hhjzhhhhhNubh)}(hWireless charging pad: Extcon can manage the state of a wireless charging connection, allowing the system to respond appropriately when a device is placed on or removed from the charging pad. h]h)}(hWireless charging pad: Extcon can manage the state of a wireless charging connection, allowing the system to respond appropriately when a device is placed on or removed from the charging pad.h]hWireless charging pad: Extcon can manage the state of a wireless charging connection, allowing the system to respond appropriately when a device is placed on or removed from the charging pad.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK)hjubah}(h]h ]h"]h$]h&]uh1hhjzhhhhhNubh)}(hSmart TV HDMI ports: In a smart TV, Extcon can manage multiple HDMI ports, detecting when devices are connected or disconnected, and potentially identifying the type of device (e.g., gaming console, set-top box, Blu-ray player). h]h)}(hSmart TV HDMI ports: In a smart TV, Extcon can manage multiple HDMI ports, detecting when devices are connected or disconnected, and potentially identifying the type of device (e.g., gaming console, set-top box, Blu-ray player).h]hSmart TV HDMI ports: In a smart TV, Extcon can manage multiple HDMI ports, detecting when devices are connected or disconnected, and potentially identifying the type of device (e.g., gaming console, set-top box, Blu-ray player).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK.hjubah}(h]h ]h"]h$]h&]uh1hhjzhhhhhNubeh}(h]h ]h"]h$]h&]jgjhjihjjjkuh1hhhhhhhhKubh)}(hXAThe Extcon framework simplifies the development of drivers for these complex scenarios by providing a standardized way to report and query connector states, handle mutually exclusive connections, and manage connector properties. This allows for more robust and flexible handling of external connections in modern devices.h]hXAThe Extcon framework simplifies the development of drivers for these complex scenarios by providing a standardized way to report and query connector states, handle mutually exclusive connections, and manage connector properties. This allows for more robust and flexible handling of external connections in modern devices.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK3hhhhubeh}(h]overviewah ]h"]overviewah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hKey Componentsh]hKey Components}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK:ubh)}(hhh](h)}(h extcon_devh]h extcon_dev}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhK=ubh)}(h2The core structure representing an Extcon device::h]h1The core structure representing an Extcon device:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK?hj hhubh literal_block)}(hX3struct 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; };h]hX3struct 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; };}hj+sbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1j)hhhKAhj hhubh)}(h Key fields:h]h Key fields:}(hj;hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKXhj hhubh bullet_list)}(hhh](h)}(h#``name``: Name of the Extcon deviceh]h)}(hjPh](hliteral)}(h``name``h]hname}(hjWhhhNhNubah}(h]h ]h"]h$]h&]uh1jUhjRubh: Name of the Extcon device}(hjRhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKZhjNubah}(h]h ]h"]h$]h&]uh1hhjKhhhhhNubh)}(h3``supported_cable``: Array of supported cable typesh]h)}(hjwh](jV)}(h``supported_cable``h]hsupported_cable}(hj|hhhNhNubah}(h]h ]h"]h$]h&]uh1jUhjyubh : Array of supported cable types}(hjyhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK[hjuubah}(h]h ]h"]h$]h&]uh1hhjKhhhhhNubh)}(hX``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. h](h)}(hX``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.h](jV)}(h``mutually_exclusive``h]hmutually_exclusive}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jUhjubhX: 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.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK\hjubh)}(h For example:h]h For example:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKahjubj*)}(hstatic 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 */ };h]hstatic 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 */ };}hjsbah}(h]h ]h"]h$]h&]j9j:uh1j)hhhKehjubh)}(hIn 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.h]hIn 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.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKkhjubh)}(hThe Extcon core uses this information to prevent invalid combinations of cable states, ensuring that the reported states are always consistent with the hardware capabilities.h]hThe Extcon core uses this information to prevent invalid combinations of cable states, ensuring that the reported states are always consistent with the hardware capabilities.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKphjubeh}(h]h ]h"]h$]h&]uh1hhjKhhhhhNubh)}(hE``state``: Current state of the device (bitmap of connected cables) h]h)}(hC``state``: Current state of the device (bitmap of connected cables)h](jV)}(h ``state``h]hstate}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jUhjubh:: Current state of the device (bitmap of connected cables)}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKthjubah}(h]h ]h"]h$]h&]uh1hhjKhhhhhNubeh}(h]h ]h"]h$]h&]bullet-uh1jIhhhKZhj hhubeh}(h] extcon-devah ]h"] extcon_devah$]h&]uh1hhjhhhhhK=ubh)}(hhh](h)}(h extcon_cableh]h extcon_cable}(hj1hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj.hhhhhKxubh)}(hhj]hMhj;ubj?)}(hI``const unsigned int id`` the unique id indicating an external connector h](jE)}(h``const unsigned int id``h]jV)}(hjh]hconst unsigned int id}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jUhjubah}(h]h ]h"]h$]h&]uh1jDhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:144: ./drivers/extcon/extcon.chMhj}ubj_)}(hhh]h)}(h.the unique id indicating an external connectorh]h.the unique id indicating an external connector}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhMhjubah}(h]h ]h"]h$]h&]uh1j^hj}ubeh}(h]h ]h"]h$]h&]uh1j>hjhMhj;ubeh}(h]h ]h"]h$]h&]uh1j9hjubh)}(h**Description**h]j$)}(hjh]h Description}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j#hjubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:144: ./drivers/extcon/extcon.chMhjubh)}(h-Returns 0 if success or error number if fail.h]h-Returns 0 if success or error number if fail.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:144: ./drivers/extcon/extcon.chMhjubeh}(h]h ] kernelindentah"]h$]h&]uh1jhjkhhhNhNubj})}(hhh]h}(h]h ]h"]h$]h&]entries](jextcon_set_state (C function)c.extcon_set_statehNtauh1j|hjkhhhNhNubj)}(hhh](j)}(hKint extcon_set_state (struct extcon_dev *edev, unsigned int id, bool state)h]j)}(hJint extcon_set_state(struct extcon_dev *edev, unsigned int id, bool state)h](j)}(hinth]hint}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjhhhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:147: ./drivers/extcon/extcon.chMubj)}(h h]h }(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjhhhjhMubj)}(hextcon_set_stateh]j)}(hextcon_set_stateh]hextcon_set_state}(hj$hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj ubah}(h]h ](jjeh"]h$]h&]j9j:uh1jhjhhhjhMubj)}(h6(struct extcon_dev *edev, unsigned int id, bool state)h](j)}(hstruct extcon_dev *edevh](j)}(hjh]hstruct}(hj@hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj<ubj)}(h h]h }(hjMhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj<ubh)}(hhh]j)}(h extcon_devh]h extcon_dev}(hj^hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj[ubah}(h]h ]h"]h$]h&] refdomainj#reftypej% reftargetj`modnameN classnameNj)j,)}j/]j2)}j%j&sbc.extcon_set_stateasbuh1hhj<ubj)}(h h]h }(hj~hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj<ubjF)}(hjIh]h*}(hjhhhNhNubah}(h]h ]jRah"]h$]h&]uh1jEhj<ubj)}(hedevh]hedev}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj<ubeh}(h]h ]h"]h$]h&]noemphj9j:uh1jhj8ubj)}(hunsigned int idh](j)}(hunsignedh]hunsigned}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubj)}(h h]h }(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubj)}(hinth]hint}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubj)}(h h]h }(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubj)}(hidh]hid}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]noemphj9j:uh1jhj8ubj)}(h bool stateh](j)}(hboolh]hbool}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubj)}(h h]h }(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubj)}(hstateh]hstate}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]noemphj9j:uh1jhj8ubeh}(h]h ]h"]h$]h&]j9j:uh1jhjhhhjhMubeh}(h]h ]h"]h$]h&]j9j:juh1jjjhjhhhjhMubah}(h]jah ](jjeh"]h$]h&]jj)jhuh1jhjhMhjhhubj)}(hhh]h)}(h'Set the state of an external connector.h]h'Set the state of an external connector.}(hjIhhhNhNubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:147: ./drivers/extcon/extcon.chMhjFhhubah}(h]h ]h"]h$]h&]uh1jhjhhhjhMubeh}(h]h ](j#functioneh"]h$]h&]jj#jjajjajjjuh1jhhhjkhNhNubj)}(hX**Parameters** ``struct extcon_dev *edev`` the extcon device ``unsigned int id`` the unique id indicating an external connector ``bool state`` the new state of an external connector. the default semantics is true: attached / false: detached. **Description** Note that this function set the state of an external connector without a notification. To synchronize the state of an external connector, have to use extcon_set_state_sync() and extcon_sync(). Returns 0 if success or error number if fail.h](h)}(h**Parameters**h]j$)}(hjkh]h Parameters}(hjmhhhNhNubah}(h]h ]h"]h$]h&]uh1j#hjiubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:147: ./drivers/extcon/extcon.chMhjeubj:)}(hhh](j?)}(h.``struct extcon_dev *edev`` the extcon device h](jE)}(h``struct extcon_dev *edev``h]jV)}(hjh]hstruct extcon_dev *edev}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jUhjubah}(h]h ]h"]h$]h&]uh1jDhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:147: ./drivers/extcon/extcon.chMhjubj_)}(hhh]h)}(hthe extcon deviceh]hthe extcon device}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhMhjubah}(h]h ]h"]h$]h&]uh1j^hjubeh}(h]h ]h"]h$]h&]uh1j>hjhMhjubj?)}(hC``unsigned int id`` the unique id indicating an external connector h](jE)}(h``unsigned int id``h]jV)}(hjh]hunsigned int id}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jUhjubah}(h]h ]h"]h$]h&]uh1jDhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:147: ./drivers/extcon/extcon.chMhjubj_)}(hhh]h)}(h.the unique id indicating an external connectorh]h.the unique id indicating an external connector}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhMhjubah}(h]h ]h"]h$]h&]uh1j^hjubeh}(h]h ]h"]h$]h&]uh1j>hjhMhjubj?)}(hr``bool state`` the new state of an external connector. the default semantics is true: attached / false: detached. h](jE)}(h``bool state``h]jV)}(hjh]h bool state}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jUhjubah}(h]h ]h"]h$]h&]uh1jDhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:147: ./drivers/extcon/extcon.chMhjubj_)}(hhh]h)}(hbthe new state of an external connector. the default semantics is true: attached / false: detached.h]hbthe new state of an external connector. the default semantics is true: attached / false: detached.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:147: ./drivers/extcon/extcon.chMhjubah}(h]h ]h"]h$]h&]uh1j^hjubeh}(h]h ]h"]h$]h&]uh1j>hjhMhjubeh}(h]h ]h"]h$]h&]uh1j9hjeubh)}(h**Description**h]j$)}(hj8h]h Description}(hj:hhhNhNubah}(h]h ]h"]h$]h&]uh1j#hj6ubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:147: ./drivers/extcon/extcon.chMhjeubh)}(hNote that this function set the state of an external connector without a notification. To synchronize the state of an external connector, have to use extcon_set_state_sync() and extcon_sync().h]hNote that this function set the state of an external connector without a notification. To synchronize the state of an external connector, have to use extcon_set_state_sync() and extcon_sync().}(hjNhhhNhNubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:147: ./drivers/extcon/extcon.chMhjeubh)}(h-Returns 0 if success or error number if fail.h]h-Returns 0 if success or error number if fail.}(hj]hhhNhNubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:147: ./drivers/extcon/extcon.chMhjeubeh}(h]h ] kernelindentah"]h$]h&]uh1jhjkhhhNhNubj})}(hhh]h}(h]h ]h"]h$]h&]entries](j"extcon_set_state_sync (C function)c.extcon_set_state_synchNtauh1j|hjkhhhNhNubj)}(hhh](j)}(hPint extcon_set_state_sync (struct extcon_dev *edev, unsigned int id, bool state)h]j)}(hOint extcon_set_state_sync(struct extcon_dev *edev, unsigned int id, bool state)h](j)}(hinth]hint}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjhhhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:150: ./drivers/extcon/extcon.chMVubj)}(h h]h }(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjhhhjhMVubj)}(hextcon_set_state_synch]j)}(hextcon_set_state_synch]hextcon_set_state_sync}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubah}(h]h ](jjeh"]h$]h&]j9j:uh1jhjhhhjhMVubj)}(h6(struct extcon_dev *edev, unsigned int id, bool state)h](j)}(hstruct extcon_dev *edevh](j)}(hjh]hstruct}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubj)}(h h]h }(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubh)}(hhh]j)}(h extcon_devh]h extcon_dev}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&] refdomainj#reftypej% reftargetjmodnameN classnameNj)j,)}j/]j2)}j%jsbc.extcon_set_state_syncasbuh1hhjubj)}(h h]h }(hj hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubjF)}(hjIh]h*}(hj hhhNhNubah}(h]h ]jRah"]h$]h&]uh1jEhjubj)}(hedevh]hedev}(hj" hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]noemphj9j:uh1jhjubj)}(hunsigned int idh](j)}(hunsignedh]hunsigned}(hj; hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj7 ubj)}(h h]h }(hjI hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj7 ubj)}(hinth]hint}(hjW hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj7 ubj)}(h h]h }(hje hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj7 ubj)}(hidh]hid}(hjs hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj7 ubeh}(h]h ]h"]h$]h&]noemphj9j:uh1jhjubj)}(h bool stateh](j)}(hjh]hbool}(hj hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj ubj)}(h h]h }(hj hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj ubj)}(hstateh]hstate}(hj hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]noemphj9j:uh1jhjubeh}(h]h ]h"]h$]h&]j9j:uh1jhjhhhjhMVubeh}(h]h ]h"]h$]h&]j9j:juh1jjjhjhhhjhMVubah}(h]jah ](jjeh"]h$]h&]jj)jhuh1jhjhMVhjhhubj)}(hhh]h)}(h1Set the state of an external connector with sync.h]h1Set the state of an external connector with sync.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:150: ./drivers/extcon/extcon.chMKhj hhubah}(h]h ]h"]h$]h&]uh1jhjhhhjhMVubeh}(h]h ](j#functioneh"]h$]h&]jj#jj jj jjjuh1jhhhjkhNhNubj)}(hX**Parameters** ``struct extcon_dev *edev`` the extcon device ``unsigned int id`` the unique id indicating an external connector ``bool state`` the new state of external connector. the default semantics is true: attached / false: detached. **Description** Note that this function set the state of external connector and synchronize the state by sending a notification. Returns 0 if success or error number if fail.h](h)}(h**Parameters**h]j$)}(hj h]h Parameters}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j#hj ubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:150: ./drivers/extcon/extcon.chMOhj ubj:)}(hhh](j?)}(h.``struct extcon_dev *edev`` the extcon device h](jE)}(h``struct extcon_dev *edev``h]jV)}(hj h]hstruct extcon_dev *edev}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jUhj ubah}(h]h ]h"]h$]h&]uh1jDhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:150: ./drivers/extcon/extcon.chMLhj ubj_)}(hhh]h)}(hthe extcon deviceh]hthe extcon device}(hj+ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj' hMLhj( ubah}(h]h ]h"]h$]h&]uh1j^hj ubeh}(h]h ]h"]h$]h&]uh1j>hj' hMLhj ubj?)}(hC``unsigned int id`` the unique id indicating an external connector h](jE)}(h``unsigned int id``h]jV)}(hjK h]hunsigned int id}(hjM hhhNhNubah}(h]h ]h"]h$]h&]uh1jUhjI ubah}(h]h ]h"]h$]h&]uh1jDhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:150: ./drivers/extcon/extcon.chMMhjE ubj_)}(hhh]h)}(h.the unique id indicating an external connectorh]h.the unique id indicating an external connector}(hjd hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj` hMMhja ubah}(h]h ]h"]h$]h&]uh1j^hjE ubeh}(h]h ]h"]h$]h&]uh1j>hj` hMMhj ubj?)}(ho``bool state`` the new state of external connector. the default semantics is true: attached / false: detached. h](jE)}(h``bool state``h]jV)}(hj h]h bool state}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jUhj ubah}(h]h ]h"]h$]h&]uh1jDhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:150: ./drivers/extcon/extcon.chMOhj~ ubj_)}(hhh]h)}(h_the new state of external connector. the default semantics is true: attached / false: detached.h]h_the new state of external connector. the default semantics is true: attached / false: detached.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:150: ./drivers/extcon/extcon.chMNhj ubah}(h]h ]h"]h$]h&]uh1j^hj~ ubeh}(h]h ]h"]h$]h&]uh1j>hj hMOhj ubeh}(h]h ]h"]h$]h&]uh1j9hj ubh)}(h**Description**h]j$)}(hj h]h Description}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j#hj ubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:150: ./drivers/extcon/extcon.chMQhj ubh)}(hpNote that this function set the state of external connector and synchronize the state by sending a notification.h]hpNote that this function set the state of external connector and synchronize the state by sending a notification.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:150: ./drivers/extcon/extcon.chMQhj ubh)}(h-Returns 0 if success or error number if fail.h]h-Returns 0 if success or error number if fail.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:150: ./drivers/extcon/extcon.chMThj ubeh}(h]h ] kernelindentah"]h$]h&]uh1jhjkhhhNhNubj})}(hhh]h}(h]h ]h"]h$]h&]entries](j extcon_get_property (C function)c.extcon_get_propertyhNtauh1j|hjkhhhNhNubj)}(hhh](j)}(h|int extcon_get_property (struct extcon_dev *edev, unsigned int id, unsigned int prop, union extcon_property_value *prop_val)h]j)}(h{int extcon_get_property(struct extcon_dev *edev, unsigned int id, unsigned int prop, union extcon_property_value *prop_val)h](j)}(hinth]hint}(hj hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj hhhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:153: ./drivers/extcon/extcon.chMpubj)}(h h]h }(hj# hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj hhhj" hMpubj)}(hextcon_get_propertyh]j)}(hextcon_get_propertyh]hextcon_get_property}(hj5 hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj1 ubah}(h]h ](jjeh"]h$]h&]j9j:uh1jhj hhhj" hMpubj)}(hd(struct extcon_dev *edev, unsigned int id, unsigned int prop, union extcon_property_value *prop_val)h](j)}(hstruct extcon_dev *edevh](j)}(hjh]hstruct}(hjQ hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjM ubj)}(h h]h }(hj^ hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjM ubh)}(hhh]j)}(h extcon_devh]h extcon_dev}(hjo hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjl ubah}(h]h ]h"]h$]h&] refdomainj#reftypej% reftargetjq modnameN classnameNj)j,)}j/]j2)}j%j7 sbc.extcon_get_propertyasbuh1hhjM ubj)}(h h]h }(hj hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjM ubjF)}(hjIh]h*}(hj hhhNhNubah}(h]h ]jRah"]h$]h&]uh1jEhjM ubj)}(hedevh]hedev}(hj hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjM ubeh}(h]h ]h"]h$]h&]noemphj9j:uh1jhjI ubj)}(hunsigned int idh](j)}(hunsignedh]hunsigned}(hj hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj ubj)}(h h]h }(hj hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj ubj)}(hinth]hint}(hj hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj ubj)}(h h]h }(hj hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj ubj)}(hidh]hid}(hj hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]noemphj9j:uh1jhjI ubj)}(hunsigned int proph](j)}(hunsignedh]hunsigned}(hj hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj ubj)}(h h]h }(hj" hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj ubj)}(hinth]hint}(hj0 hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj ubj)}(h h]h }(hj> hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj ubj)}(hproph]hprop}(hjL hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]noemphj9j:uh1jhjI ubj)}(h%union extcon_property_value *prop_valh](j)}(hunionh]hunion}(hje hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhja ubj)}(h h]h }(hjs hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhja ubh)}(hhh]j)}(hextcon_property_valueh]hextcon_property_value}(hj hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj ubah}(h]h ]h"]h$]h&] refdomainj#reftypej% reftargetj modnameN classnameNj)j,)}j/]j c.extcon_get_propertyasbuh1hhja ubj)}(h h]h }(hj hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhja ubjF)}(hjIh]h*}(hj hhhNhNubah}(h]h ]jRah"]h$]h&]uh1jEhja ubj)}(hprop_valh]hprop_val}(hj hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhja ubeh}(h]h ]h"]h$]h&]noemphj9j:uh1jhjI ubeh}(h]h ]h"]h$]h&]j9j:uh1jhj hhhj" hMpubeh}(h]h ]h"]h$]h&]j9j:juh1jjjhj hhhj" hMpubah}(h]j ah ](jjeh"]h$]h&]jj)jhuh1jhj" hMphj hhubj)}(hhh]h)}(h0Get the property value of an external connector.h]h0Get the property value of an external connector.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:153: ./drivers/extcon/extcon.chMchj hhubah}(h]h ]h"]h$]h&]uh1jhj hhhj" hMpubeh}(h]h ](j#functioneh"]h$]h&]jj#jj jj jjjuh1jhhhjkhNhNubj)}(hX**Parameters** ``struct extcon_dev *edev`` the extcon device ``unsigned int id`` the unique id indicating an external connector ``unsigned int prop`` the property id indicating an extcon property ``union extcon_property_value *prop_val`` the pointer which store the value of extcon property **Description** Note that when getting the property value of external connector, the external connector should be attached. If detached state, function return 0 without property value. Also, the each property should be included in the list of supported properties according to extcon type. Returns 0 if success or error number if fail.h](h)}(h**Parameters**h]j$)}(hj h]h Parameters}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j#hj ubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:153: ./drivers/extcon/extcon.chMghj ubj:)}(hhh](j?)}(h.``struct extcon_dev *edev`` the extcon device h](jE)}(h``struct extcon_dev *edev``h]jV)}(hj( h]hstruct extcon_dev *edev}(hj* hhhNhNubah}(h]h ]h"]h$]h&]uh1jUhj& ubah}(h]h ]h"]h$]h&]uh1jDhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:153: ./drivers/extcon/extcon.chMdhj" ubj_)}(hhh]h)}(hthe extcon deviceh]hthe extcon device}(hjA hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj= hMdhj> ubah}(h]h ]h"]h$]h&]uh1j^hj" ubeh}(h]h ]h"]h$]h&]uh1j>hj= hMdhj ubj?)}(hC``unsigned int id`` the unique id indicating an external connector h](jE)}(h``unsigned int id``h]jV)}(hja h]hunsigned int id}(hjc hhhNhNubah}(h]h ]h"]h$]h&]uh1jUhj_ ubah}(h]h ]h"]h$]h&]uh1jDhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:153: ./drivers/extcon/extcon.chMehj[ ubj_)}(hhh]h)}(h.the unique id indicating an external connectorh]h.the unique id indicating an external connector}(hjz hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjv hMehjw ubah}(h]h ]h"]h$]h&]uh1j^hj[ ubeh}(h]h ]h"]h$]h&]uh1j>hjv hMehj ubj?)}(hD``unsigned int prop`` the property id indicating an extcon property h](jE)}(h``unsigned int prop``h]jV)}(hj h]hunsigned int prop}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jUhj ubah}(h]h ]h"]h$]h&]uh1jDhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:153: ./drivers/extcon/extcon.chMfhj ubj_)}(hhh]h)}(h-the property id indicating an extcon propertyh]h-the property id indicating an extcon property}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hMfhj ubah}(h]h ]h"]h$]h&]uh1j^hj ubeh}(h]h ]h"]h$]h&]uh1j>hj hMfhj ubj?)}(h_``union extcon_property_value *prop_val`` the pointer which store the value of extcon property h](jE)}(h)``union extcon_property_value *prop_val``h]jV)}(hj h]h%union extcon_property_value *prop_val}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jUhj ubah}(h]h ]h"]h$]h&]uh1jDhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:153: ./drivers/extcon/extcon.chMghj ubj_)}(hhh]h)}(h4the pointer which store the value of extcon propertyh]h4the pointer which store the value of extcon property}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hMghj ubah}(h]h ]h"]h$]h&]uh1j^hj ubeh}(h]h ]h"]h$]h&]uh1j>hj hMghj ubeh}(h]h ]h"]h$]h&]uh1j9hj ubh)}(h**Description**h]j$)}(hjh]h Description}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j#hj ubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:153: ./drivers/extcon/extcon.chMihj ubh)}(hXNote that when getting the property value of external connector, the external connector should be attached. If detached state, function return 0 without property value. Also, the each property should be included in the list of supported properties according to extcon type.h]hXNote that when getting the property value of external connector, the external connector should be attached. If detached state, function return 0 without property value. Also, the each property should be included in the list of supported properties according to extcon type.}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:153: ./drivers/extcon/extcon.chMihj ubh)}(h-Returns 0 if success or error number if fail.h]h-Returns 0 if success or error number if fail.}(hj3hhhNhNubah}(h]h ]h"]h$]h&]uh1hhZ/var/lib/git/docbuild/linux/Documentation/driver-api/extcon:153: ./drivers/extcon/extcon.chMnhj ubeh}(h]h ] kernelindentah"]h$]h&]uh1jhjkhhhNhNubeh}(h]core-functionsah ]h"]core functionsah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hSysfs Interfaceh]hSysfs Interface}(hjThhhNhNubah}(h]h ]h"]h$]h&]uh1hhjQhhhhhKubh)}(h5Extcon devices expose the following sysfs attributes:h]h5Extcon devices expose the following sysfs attributes:}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjQhhubjJ)}(hhh](h)}(h#``name``: Name of the Extcon deviceh]h)}(hjuh](jV)}(h``name``h]hname}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1jUhjwubh: Name of the Extcon device}(hjwhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjsubah}(h]h ]h"]h$]h&]uh1hhjphhhhhNubh)}(h0``state``: Current state of all supported cablesh]h)}(hjh](jV)}(h ``state``h]hstate}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jUhjubh': Current state of all supported cables}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1hhjphhhhhNubh)}(h1``cable.N/name``: Name of the Nth supported cableh]h)}(hjh](jV)}(h``cable.N/name``h]h cable.N/name}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jUhjubh!: Name of the Nth supported cable}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1hhjphhhhhNubh)}(h4``cable.N/state``: State of the Nth supported cable h]h)}(h3``cable.N/state``: State of the Nth supported cableh](jV)}(h``cable.N/state``h]h cable.N/state}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jUhjubh": State of the Nth supported cable}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1hhjphhhhhNubeh}(h]h ]h"]h$]h&]j$j%uh1jIhhhKhjQhhubh)}(hhh](h)}(h Usage Exampleh]h Usage Example}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubj*)}(hXo#include #include #include struct my_extcon_data { struct extcon_dev *edev; struct device *dev; }; static const unsigned int my_extcon_cable[] = { EXTCON_USB, EXTCON_USB_HOST, EXTCON_NONE, }; static int my_extcon_probe(struct platform_device *pdev) { struct my_extcon_data *data; int ret; data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; data->dev = &pdev->dev; /* Initialize extcon device */ data->edev = devm_extcon_dev_allocate(data->dev, my_extcon_cable); if (IS_ERR(data->edev)) { dev_err(data->dev, "Failed to allocate extcon device\n"); return PTR_ERR(data->edev); } /* Register extcon device */ ret = devm_extcon_dev_register(data->dev, data->edev); if (ret < 0) { dev_err(data->dev, "Failed to register extcon device\n"); return ret; } platform_set_drvdata(pdev, data); /* Example: Set initial state */ extcon_set_state_sync(data->edev, EXTCON_USB, true); dev_info(data->dev, "My extcon driver probed successfully\n"); return 0; } static int my_extcon_remove(struct platform_device *pdev) { struct my_extcon_data *data = platform_get_drvdata(pdev); /* Example: Clear state before removal */ extcon_set_state_sync(data->edev, EXTCON_USB, false); dev_info(data->dev, "My extcon driver removed\n"); return 0; } static const struct of_device_id my_extcon_of_match[] = { { .compatible = "my,extcon-device", }, { }, }; MODULE_DEVICE_TABLE(of, my_extcon_of_match); static struct platform_driver my_extcon_driver = { .driver = { .name = "my-extcon-driver", .of_match_table = my_extcon_of_match, }, .probe = my_extcon_probe, .remove = my_extcon_remove, }; module_platform_driver(my_extcon_driver);h]hXo#include #include #include struct my_extcon_data { struct extcon_dev *edev; struct device *dev; }; static const unsigned int my_extcon_cable[] = { EXTCON_USB, EXTCON_USB_HOST, EXTCON_NONE, }; static int my_extcon_probe(struct platform_device *pdev) { struct my_extcon_data *data; int ret; data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; data->dev = &pdev->dev; /* Initialize extcon device */ data->edev = devm_extcon_dev_allocate(data->dev, my_extcon_cable); if (IS_ERR(data->edev)) { dev_err(data->dev, "Failed to allocate extcon device\n"); return PTR_ERR(data->edev); } /* Register extcon device */ ret = devm_extcon_dev_register(data->dev, data->edev); if (ret < 0) { dev_err(data->dev, "Failed to register extcon device\n"); return ret; } platform_set_drvdata(pdev, data); /* Example: Set initial state */ extcon_set_state_sync(data->edev, EXTCON_USB, true); dev_info(data->dev, "My extcon driver probed successfully\n"); return 0; } static int my_extcon_remove(struct platform_device *pdev) { struct my_extcon_data *data = platform_get_drvdata(pdev); /* Example: Clear state before removal */ extcon_set_state_sync(data->edev, EXTCON_USB, false); dev_info(data->dev, "My extcon driver removed\n"); return 0; } static const struct of_device_id my_extcon_of_match[] = { { .compatible = "my,extcon-device", }, { }, }; MODULE_DEVICE_TABLE(of, my_extcon_of_match); static struct platform_driver my_extcon_driver = { .driver = { .name = "my-extcon-driver", .of_match_table = my_extcon_of_match, }, .probe = my_extcon_probe, .remove = my_extcon_remove, }; module_platform_driver(my_extcon_driver);}hjsbah}(h]h ]h"]h$]h&]j9j:forcelanguagej#highlight_args}uh1j)hhhKhjhhubeh}(h] usage-exampleah ]h"] usage exampleah$]h&]uh1hhjQhhhhhKubh)}(hhh](h)}(hThis example demonstrates:h]hThis example demonstrates:}(hj<hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj9hhhhhKubjJ)}(hhh](h)}(h?Defining supported cable types (USB and USB Host in this case).h]h)}(hjOh]h?Defining supported cable types (USB and USB Host in this case).}(hjQhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjMubah}(h]h ]h"]h$]h&]uh1hhjJhhhhhNubh)}(h,Allocating and registering an extcon device.h]h)}(hjfh]h,Allocating and registering an extcon device.}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjdubah}(h]h ]h"]h$]h&]uh1hhjJhhhhhNubh)}(hESetting an initial state for a cable (USB connected in this example).h]h)}(hj}h]hESetting an initial state for a cable (USB connected in this example).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj{ubah}(h]h ]h"]h$]h&]uh1hhjJhhhhhNubh)}(h.Clearing the state when the driver is removed.h]h)}(hjh]h.Clearing the state when the driver is removed.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1hhjJhhhhhNubeh}(h]h ]h"]h$]h&]j$j%uh1jIhhhKhj9hhubeh}(h]this-example-demonstratesah ]h"]this example demonstrates:ah$]h&]uh1hhjQhhhhhKubeh}(h]sysfs-interfaceah ]h"]sysfs interfaceah$]h&]uh1hhhhhhhhKubeh}(h]extcon-device-subsystemah ]h"]extcon device subsystemah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(jjjjjhjej+j(j`j]jNjKjjj6j3jju nametypes}(jjjhj+j`jNjj6juh}(jhjhjejj(j j]j.jKjkjjjjjjj j jjQj3jjj9u footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.