sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget,/translations/zh_CN/userspace-api/gpio/sysfsmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget,/translations/zh_TW/userspace-api/gpio/sysfsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget,/translations/it_IT/userspace-api/gpio/sysfsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget,/translations/ja_JP/userspace-api/gpio/sysfsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget,/translations/ko_KR/userspace-api/gpio/sysfsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget,/translations/sp_SP/userspace-api/gpio/sysfsmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(h"GPIO Sysfs Interface for Userspaceh]h"GPIO Sysfs Interface for Userspace}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhF/var/lib/git/docbuild/linux/Documentation/userspace-api/gpio/sysfs.rsthKubhwarning)}(hXThis API is obsoleted by the chardev.rst and the ABI documentation has been moved to Documentation/ABI/obsolete/sysfs-gpio. New developments should use the chardev.rst, and existing developments are encouraged to migrate as soon as possible, as this API will be removed in the future. This interface will continue to be maintained for the migration period, but new features will only be added to the new API.h](h paragraph)}(h{This API is obsoleted by the chardev.rst and the ABI documentation has been moved to Documentation/ABI/obsolete/sysfs-gpio.h]h{This API is obsoleted by the chardev.rst and the ABI documentation has been moved to Documentation/ABI/obsolete/sysfs-gpio.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhubh)}(hNew developments should use the chardev.rst, and existing developments are encouraged to migrate as soon as possible, as this API will be removed in the future.h]hNew developments should use the chardev.rst, and existing developments are encouraged to migrate as soon as possible, as this API will be removed in the future.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhubh)}(h{This interface will continue to be maintained for the migration period, but new features will only be added to the new API.h]h{This interface will continue to be maintained for the migration period, but new features will only be added to the new API.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhubeh}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(hhh](h)}(hThe obsolete sysfs ABIh]hThe obsolete sysfs ABI}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh)}(hXPPlatforms which use the "gpiolib" implementors framework may choose to configure a sysfs user interface to GPIOs. This is different from the debugfs interface, since it provides control over GPIO direction and value instead of just showing a gpio state summary. Plus, it could be present on production systems without debugging support.h]hXTPlatforms which use the “gpiolib” implementors framework may choose to configure a sysfs user interface to GPIOs. This is different from the debugfs interface, since it provides control over GPIO direction and value instead of just showing a gpio state summary. Plus, it could be present on production systems without debugging support.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hXGiven appropriate hardware documentation for the system, userspace could know for example that GPIO #23 controls the write protect line used to protect boot loader segments in flash memory. System upgrade procedures may need to temporarily remove that protection, first importing a GPIO, then changing its output state, then updating the code before re-enabling the write protection. In normal use, GPIO #23 would never be touched, and the kernel would have no need to know about it.h]hXGiven appropriate hardware documentation for the system, userspace could know for example that GPIO #23 controls the write protect line used to protect boot loader segments in flash memory. System upgrade procedures may need to temporarily remove that protection, first importing a GPIO, then changing its output state, then updating the code before re-enabling the write protection. In normal use, GPIO #23 would never be touched, and the kernel would have no need to know about it.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hX Again depending on appropriate hardware documentation, on some systems userspace GPIO can be used to determine system configuration data that standard kernels won't know about. And for some tasks, simple userspace GPIO drivers could be all that the system really needs.h]hXAgain depending on appropriate hardware documentation, on some systems userspace GPIO can be used to determine system configuration data that standard kernels won’t know about. And for some tasks, simple userspace GPIO drivers could be all that the system really needs.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubhnote)}(hDo NOT abuse sysfs to control hardware that has proper kernel drivers. Please read Documentation/driver-api/gpio/drivers-on-gpio.rst to avoid reinventing kernel wheels in userspace. I MEAN IT. REALLY.h](h)}(hDo NOT abuse sysfs to control hardware that has proper kernel drivers. Please read Documentation/driver-api/gpio/drivers-on-gpio.rst to avoid reinventing kernel wheels in userspace.h]hDo NOT abuse sysfs to control hardware that has proper kernel drivers. Please read Documentation/driver-api/gpio/drivers-on-gpio.rst to avoid reinventing kernel wheels in userspace.}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK%hj,ubh)}(hI MEAN IT. REALLY.h]hI MEAN IT. REALLY.}(hj>hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK)hj,ubeh}(h]h ]h"]h$]h&]uh1j*hhhhhhhNubeh}(h]the-obsolete-sysfs-abiah ]h"]the obsolete sysfs abiah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hPaths in Sysfsh]hPaths in Sysfs}(hj]hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjZhhhhhK,ubh)}(h4There are three kinds of entries in /sys/class/gpio:h]h4There are three kinds of entries in /sys/class/gpio:}(hjkhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK-hjZhhubh block_quote)}(h- Control interfaces used to get userspace control over GPIOs; - GPIOs themselves; and - GPIO controllers ("gpio_chip" instances). h]h bullet_list)}(hhh](h list_item)}(h=Control interfaces used to get userspace control over GPIOs; h]h)}(h export" will create a "gpio19" node for GPIO #19, if that's not requested by kernel code. "unexport" ... Reverses the effect of exporting to userspace. Example: "echo 19 > unexport" will remove a "gpio19" node exported using the "export" file. h](h)}(h/sys/class/gpio/h]h/sys/class/gpio/}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK9hjubjz)}(hX"export" ... Userspace may ask the kernel to export control of a GPIO to userspace by writing its number to this file. Example: "echo 19 > export" will create a "gpio19" node for GPIO #19, if that's not requested by kernel code. "unexport" ... Reverses the effect of exporting to userspace. Example: "echo 19 > unexport" will remove a "gpio19" node exported using the "export" file. h]hdefinition_list)}(hhh](hdefinition_list_item)}(h"export" ... Userspace may ask the kernel to export control of a GPIO to userspace by writing its number to this file. Example: "echo 19 > export" will create a "gpio19" node for GPIO #19, if that's not requested by kernel code. h](hterm)}(h "export" ...h]h“export” ...}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK@hjubh definition)}(hhh](h)}(hiUserspace may ask the kernel to export control of a GPIO to userspace by writing its number to this file.h]hiUserspace may ask the kernel to export control of a GPIO to userspace by writing its number to this file.}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK export" will create a "gpio19" node for GPIO #19, if that's not requested by kernel code.h]hxExample: “echo 19 > export” will create a “gpio19” node for GPIO #19, if that’s not requested by kernel code.}(hj<hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK?hj+ubeh}(h]h ]h"]h$]h&]uh1j)hjubeh}(h]h ]h"]h$]h&]uh1jhhhK@hjubj)}(h"unexport" ... Reverses the effect of exporting to userspace. Example: "echo 19 > unexport" will remove a "gpio19" node exported using the "export" file. h](j)}(h"unexport" ...h]h“unexport” ...}(hjZhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKFhjVubj*)}(hhh](h)}(h.Reverses the effect of exporting to userspace.h]h.Reverses the effect of exporting to userspace.}(hjkhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKChjhubh)}(h\Example: "echo 19 > unexport" will remove a "gpio19" node exported using the "export" file.h]hhExample: “echo 19 > unexport” will remove a “gpio19” node exported using the “export” file.}(hjyhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKEhjhubeh}(h]h ]h"]h$]h&]uh1j)hjVubeh}(h]h ]h"]h$]h&]uh1jhhhKFhjubeh}(h]h ]h"]h$]h&]uh1jhj ubah}(h]h ]h"]h$]h&]uh1jyhhhK;hjubeh}(h]h ]h"]h$]h&]uh1jyhhhK9hjZhhubh)}(hqGPIO signals have paths like /sys/class/gpio/gpio42/ (for GPIO #42) and have the following read/write attributes:h]hqGPIO signals have paths like /sys/class/gpio/gpio42/ (for GPIO #42) and have the following read/write attributes:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKHhjZhhubjz)}(hX/sys/class/gpio/gpioN/ "direction" ... reads as either "in" or "out". This value may normally be written. Writing as "out" defaults to initializing the value as low. To ensure glitch free operation, values "low" and "high" may be written to configure the GPIO as an output with that initial value. Note that this attribute *will not exist* if the kernel doesn't support changing the direction of a GPIO, or it was exported by kernel code that didn't explicitly allow userspace to reconfigure this GPIO's direction. "value" ... reads as either 0 (inactive) or 1 (active). If the GPIO is configured as an output, this value may be written; any nonzero value is treated as active. If the pin can be configured as interrupt-generating interrupt and if it has been configured to generate interrupts (see the description of "edge"), you can poll(2) on that file and poll(2) will return whenever the interrupt was triggered. If you use poll(2), set the events POLLPRI and POLLERR. If you use select(2), set the file descriptor in exceptfds. After poll(2) returns, use pread(2) to read the value at offset zero. Alternatively, either lseek(2) to the beginning of the sysfs file and read the new value or close the file and re-open it to read the value. "edge" ... reads as either "none", "rising", "falling", or "both". Write these strings to select the signal edge(s) that will make poll(2) on the "value" file return. This file exists only if the pin can be configured as an interrupt generating input pin. "active_low" ... reads as either 0 (false) or 1 (true). Write any nonzero value to invert the value attribute both for reading and writing. Existing and subsequent poll(2) support configuration via the edge attribute for "rising" and "falling" edges will follow this setting. h](h)}(h/sys/class/gpio/gpioN/h]h/sys/class/gpio/gpioN/}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKKhjubjz)}(hX"direction" ... reads as either "in" or "out". This value may normally be written. Writing as "out" defaults to initializing the value as low. To ensure glitch free operation, values "low" and "high" may be written to configure the GPIO as an output with that initial value. Note that this attribute *will not exist* if the kernel doesn't support changing the direction of a GPIO, or it was exported by kernel code that didn't explicitly allow userspace to reconfigure this GPIO's direction. "value" ... reads as either 0 (inactive) or 1 (active). If the GPIO is configured as an output, this value may be written; any nonzero value is treated as active. If the pin can be configured as interrupt-generating interrupt and if it has been configured to generate interrupts (see the description of "edge"), you can poll(2) on that file and poll(2) will return whenever the interrupt was triggered. If you use poll(2), set the events POLLPRI and POLLERR. If you use select(2), set the file descriptor in exceptfds. After poll(2) returns, use pread(2) to read the value at offset zero. Alternatively, either lseek(2) to the beginning of the sysfs file and read the new value or close the file and re-open it to read the value. "edge" ... reads as either "none", "rising", "falling", or "both". Write these strings to select the signal edge(s) that will make poll(2) on the "value" file return. This file exists only if the pin can be configured as an interrupt generating input pin. "active_low" ... reads as either 0 (false) or 1 (true). Write any nonzero value to invert the value attribute both for reading and writing. Existing and subsequent poll(2) support configuration via the edge attribute for "rising" and "falling" edges will follow this setting. h]j)}(hhh](j)}(hX"direction" ... reads as either "in" or "out". This value may normally be written. Writing as "out" defaults to initializing the value as low. To ensure glitch free operation, values "low" and "high" may be written to configure the GPIO as an output with that initial value. Note that this attribute *will not exist* if the kernel doesn't support changing the direction of a GPIO, or it was exported by kernel code that didn't explicitly allow userspace to reconfigure this GPIO's direction. h](j)}(h"direction" ...h]h“direction” ...}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKWhjubj*)}(hhh](h)}(hXreads as either "in" or "out". This value may normally be written. Writing as "out" defaults to initializing the value as low. To ensure glitch free operation, values "low" and "high" may be written to configure the GPIO as an output with that initial value.h]hXreads as either “in” or “out”. This value may normally be written. Writing as “out” defaults to initializing the value as low. To ensure glitch free operation, values “low” and “high” may be written to configure the GPIO as an output with that initial value.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKNhjubh)}(hNote that this attribute *will not exist* if the kernel doesn't support changing the direction of a GPIO, or it was exported by kernel code that didn't explicitly allow userspace to reconfigure this GPIO's direction.h](hNote that this attribute }(hjhhhNhNubhemphasis)}(h*will not exist*h]hwill not exist}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh if the kernel doesn’t support changing the direction of a GPIO, or it was exported by kernel code that didn’t explicitly allow userspace to reconfigure this GPIO’s direction.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKThjubeh}(h]h ]h"]h$]h&]uh1j)hjubeh}(h]h ]h"]h$]h&]uh1jhhhKWhjubj)}(hX"value" ... reads as either 0 (inactive) or 1 (active). If the GPIO is configured as an output, this value may be written; any nonzero value is treated as active. If the pin can be configured as interrupt-generating interrupt and if it has been configured to generate interrupts (see the description of "edge"), you can poll(2) on that file and poll(2) will return whenever the interrupt was triggered. If you use poll(2), set the events POLLPRI and POLLERR. If you use select(2), set the file descriptor in exceptfds. After poll(2) returns, use pread(2) to read the value at offset zero. Alternatively, either lseek(2) to the beginning of the sysfs file and read the new value or close the file and re-open it to read the value. h](j)}(h "value" ...h]h“value” ...}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKghjubj*)}(hhh](h)}(hreads as either 0 (inactive) or 1 (active). If the GPIO is configured as an output, this value may be written; any nonzero value is treated as active.h]hreads as either 0 (inactive) or 1 (active). If the GPIO is configured as an output, this value may be written; any nonzero value is treated as active.}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKZhj/ubh)}(hX6If the pin can be configured as interrupt-generating interrupt and if it has been configured to generate interrupts (see the description of "edge"), you can poll(2) on that file and poll(2) will return whenever the interrupt was triggered. If you use poll(2), set the events POLLPRI and POLLERR. If you use select(2), set the file descriptor in exceptfds. After poll(2) returns, use pread(2) to read the value at offset zero. Alternatively, either lseek(2) to the beginning of the sysfs file and read the new value or close the file and re-open it to read the value.h]hX:If the pin can be configured as interrupt-generating interrupt and if it has been configured to generate interrupts (see the description of “edge”), you can poll(2) on that file and poll(2) will return whenever the interrupt was triggered. If you use poll(2), set the events POLLPRI and POLLERR. If you use select(2), set the file descriptor in exceptfds. After poll(2) returns, use pread(2) to read the value at offset zero. Alternatively, either lseek(2) to the beginning of the sysfs file and read the new value or close the file and re-open it to read the value.}(hj@hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK^hj/ubeh}(h]h ]h"]h$]h&]uh1j)hjubeh}(h]h ]h"]h$]h&]uh1jhhhKghjubj)}(hX"edge" ... reads as either "none", "rising", "falling", or "both". Write these strings to select the signal edge(s) that will make poll(2) on the "value" file return. This file exists only if the pin can be configured as an interrupt generating input pin. h](j)}(h "edge" ...h]h“edge” ...}(hj^hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKohjZubj*)}(hhh](h)}(hreads as either "none", "rising", "falling", or "both". Write these strings to select the signal edge(s) that will make poll(2) on the "value" file return.h]hreads as either “none”, “rising”, “falling”, or “both”. Write these strings to select the signal edge(s) that will make poll(2) on the “value” file return.}(hjohhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKjhjlubh)}(hXThis file exists only if the pin can be configured as an interrupt generating input pin.h]hXThis file exists only if the pin can be configured as an interrupt generating input pin.}(hj}hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKnhjlubeh}(h]h ]h"]h$]h&]uh1j)hjZubeh}(h]h ]h"]h$]h&]uh1jhhhKohjubj)}(hX"active_low" ... reads as either 0 (false) or 1 (true). Write any nonzero value to invert the value attribute both for reading and writing. Existing and subsequent poll(2) support configuration via the edge attribute for "rising" and "falling" edges will follow this setting. h](j)}(h"active_low" ...h]h“active_low” ...}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKwhjubj*)}(hhh]h)}(hXreads as either 0 (false) or 1 (true). Write any nonzero value to invert the value attribute both for reading and writing. Existing and subsequent poll(2) support configuration via the edge attribute for "rising" and "falling" edges will follow this setting.h]hX reads as either 0 (false) or 1 (true). Write any nonzero value to invert the value attribute both for reading and writing. Existing and subsequent poll(2) support configuration via the edge attribute for “rising” and “falling” edges will follow this setting.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKrhjubah}(h]h ]h"]h$]h&]uh1j)hjubeh}(h]h ]h"]h$]h&]uh1jhhhKwhjubeh}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jyhhhKMhjubeh}(h]h ]h"]h$]h&]uh1jyhhhKKhjZhhubh)}(hGPIO controllers have paths like /sys/class/gpio/gpiochip42/ (for the controller implementing GPIOs starting at #42) and have the following read-only attributes:h]hGPIO controllers have paths like /sys/class/gpio/gpiochip42/ (for the controller implementing GPIOs starting at #42) and have the following read-only attributes:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKyhjZhhubjz)}(h/sys/class/gpio/gpiochipN/ "base" ... same as N, the first GPIO managed by this chip "label" ... provided for diagnostics (not always unique) "ngpio" ... how many GPIOs this manages (N to N + ngpio - 1) h](h)}(h/sys/class/gpio/gpiochipN/h]h/sys/class/gpio/gpiochipN/}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK}hjubjz)}(h"base" ... same as N, the first GPIO managed by this chip "label" ... provided for diagnostics (not always unique) "ngpio" ... how many GPIOs this manages (N to N + ngpio - 1) h]j)}(hhh](j)}(h:"base" ... same as N, the first GPIO managed by this chip h](j)}(h "base" ...h]h“base” ...}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjubj*)}(hhh]h)}(h.same as N, the first GPIO managed by this chiph]h.same as N, the first GPIO managed by this chip}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j)hjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubj)}(h9"label" ... provided for diagnostics (not always unique) h](j)}(h "label" ...h]h“label” ...}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhj.ubj*)}(hhh]h)}(h,provided for diagnostics (not always unique)h]h,provided for diagnostics (not always unique)}(hjChhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj@ubah}(h]h ]h"]h$]h&]uh1j)hj.ubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubj)}(h="ngpio" ... how many GPIOs this manages (N to N + ngpio - 1) h](j)}(h "ngpio" ...h]h“ngpio” ...}(hjahhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhj]ubj*)}(hhh]h)}(h0how many GPIOs this manages (N to N + ngpio - 1)h]h0how many GPIOs this manages (N to N + ngpio - 1)}(hjrhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjoubah}(h]h ]h"]h$]h&]uh1j)hj]ubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jyhhhKhjubeh}(h]h ]h"]h$]h&]uh1jyhhhK}hjZhhubh)}(hXBoard documentation should in most cases cover what GPIOs are used for what purposes. However, those numbers are not always stable; GPIOs on a daughtercard might be different depending on the base board being used, or other cards in the stack. In such cases, you may need to use the gpiochip nodes (possibly in conjunction with schematics) to determine the correct GPIO number to use for a given signal.h]hXBoard documentation should in most cases cover what GPIOs are used for what purposes. However, those numbers are not always stable; GPIOs on a daughtercard might be different depending on the base board being used, or other cards in the stack. In such cases, you may need to use the gpiochip nodes (possibly in conjunction with schematics) to determine the correct GPIO number to use for a given signal.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjZhhubeh}(h]paths-in-sysfsah ]h"]paths in sysfsah$]h&]uh1hhhhhhhhK,ubh)}(hhh](h)}(hExporting from Kernel codeh]hExporting from Kernel code}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hkKernel code can explicitly manage exports of GPIOs which have already been requested using gpio_request()::h]hjKernel code can explicitly manage exports of GPIOs which have already been requested using gpio_request():}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh literal_block)}(hXI/* export the GPIO to userspace */ int gpiod_export(struct gpio_desc *desc, bool direction_may_change); /* reverse gpiod_export() */ void gpiod_unexport(struct gpio_desc *desc); /* create a sysfs link to an exported GPIO node */ int gpiod_export_link(struct device *dev, const char *name, struct gpio_desc *desc);h]hXI/* export the GPIO to userspace */ int gpiod_export(struct gpio_desc *desc, bool direction_may_change); /* reverse gpiod_export() */ void gpiod_unexport(struct gpio_desc *desc); /* create a sysfs link to an exported GPIO node */ int gpiod_export_link(struct device *dev, const char *name, struct gpio_desc *desc);}hjsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1jhhhKhjhhubh)}(hX After a kernel driver requests a GPIO, it may only be made available in the sysfs interface by gpiod_export(). The driver can control whether the signal direction may change. This helps drivers prevent userspace code from accidentally clobbering important system state.h]hX After a kernel driver requests a GPIO, it may only be made available in the sysfs interface by gpiod_export(). The driver can control whether the signal direction may change. This helps drivers prevent userspace code from accidentally clobbering important system state.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hThis explicit exporting can help with debugging (by making some kinds of experiments easier), or can provide an always-there interface that's suitable for documenting as part of a board support package.h]hThis explicit exporting can help with debugging (by making some kinds of experiments easier), or can provide an always-there interface that’s suitable for documenting as part of a board support package.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hAfter the GPIO has been exported, gpiod_export_link() allows creating symlinks from elsewhere in sysfs to the GPIO sysfs node. Drivers can use this to provide the interface under their own device in sysfs with a descriptive name.h]hAfter the GPIO has been exported, gpiod_export_link() allows creating symlinks from elsewhere in sysfs to the GPIO sysfs node. Drivers can use this to provide the interface under their own device in sysfs with a descriptive name.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]exporting-from-kernel-codeah ]h"]exporting from kernel codeah$]h&]uh1hhhhhhhhKubeh}(h]"gpio-sysfs-interface-for-userspaceah ]h"]"gpio sysfs interface for userspaceah$]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_handlerjBerror_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}(jjjWjTjjjju nametypes}(jjWjjuh}(jhjThjjZjju 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.