← Documents Documentation/userspace-api/gpio/gpio-get-lineevent-ioctl.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API

GPIO_GET_LINEEVENT_IOCTL

ABI v1에서 edge detection line을 배타적으로 요청하는 ioctl의 수명, flag 제약, 오류와 반환값을 설명합니다.

Source pathDocumentation/userspace-api/gpio/gpio-get-lineevent-ioctl.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

gpio-get-lineevent-ioctl.rst:1-84

ABI v1에서 edge detection line을 배타적으로 요청하는 ioctl의 수명, flag 제약, 오류와 반환값을 설명합니다.

원문의 ioctl prototype, struct, flag, errno, source path와 줄 좌표를 보존해 전문 번역했습니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 .. _GPIO_GET_LINEEVENT_IOCTL:
4
5 ************************
6 GPIO_GET_LINEEVENT_IOCTL
7 ************************
8
9 .. warning::
10 This ioctl is part of chardev_v1.rst and is obsoleted by
11 gpio-v2-get-line-ioctl.rst.
12
13 Name
14 ====
15
16 GPIO_GET_LINEEVENT_IOCTL - Request a line with edge detection from the kernel.
17
18 Synopsis
19 ========
20
21 .. c:macro:: GPIO_GET_LINEEVENT_IOCTL
22
23 ``int ioctl(int chip_fd, GPIO_GET_LINEEVENT_IOCTL, struct gpioevent_request *request)``
24
25 Arguments
26 =========
27
28 ``chip_fd``
29 The file descriptor of the GPIO character device returned by `open()`.
30
31 ``request``
32 The :c:type:`event_request<gpioevent_request>` specifying the line
33 to request and its configuration.
34
35 Description
36 ===========
37
38 Request a line with edge detection from the kernel.
39
40 On success, the requesting process is granted exclusive access to the line
41 value and may receive events when edges are detected on the line, as
42 described in gpio-lineevent-data-read.rst.
43
44 The state of a line is guaranteed to remain as requested until the returned
45 file descriptor is closed. Once the file descriptor is closed, the state of
46 the line becomes uncontrolled from the userspace perspective, and may revert
47 to its default state.
48
49 Requesting a line already in use is an error (**EBUSY**).
50
51 Requesting edge detection on a line that does not support interrupts is an
52 error (**ENXIO**).
53
54 As with the :ref:`line handle<gpio-get-linehandle-config-support>`, the
55 bias configuration is best effort.
56
57 Closing the ``chip_fd`` has no effect on existing line events.
58
59 Configuration Rules
60 -------------------
61
62 The following configuration rules apply:
63
64 The line event is requested as an input, so no flags specific to output lines,
65 ``GPIOHANDLE_REQUEST_OUTPUT``, ``GPIOHANDLE_REQUEST_OPEN_DRAIN``, or
66 ``GPIOHANDLE_REQUEST_OPEN_SOURCE``, may be set.
67
68 Only one bias flag, ``GPIOHANDLE_REQUEST_BIAS_xxx``, may be set.
69 If no bias flags are set then the bias configuration is not changed.
70
71 The edge flags, ``GPIOEVENT_REQUEST_RISING_EDGE`` and
72 ``GPIOEVENT_REQUEST_FALLING_EDGE``, may be combined to detect both rising
73 and falling edges.
74
75 Requesting an invalid configuration is an error (**EINVAL**).
76
77 Return Value
78 ============
79
80 On success 0 and the :c:type:`request.fd<gpioevent_request>` contains the file
81 descriptor for the request.
82
83 On error -1 and the ``errno`` variable is set appropriately.
84 Common error codes are described in error-codes.rst.
85

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

상태, 이름, 호출 형식

1-34

`GPIO_GET_LINEEVENT_IOCTL`은 kernel에 edge detection을 적용한 GPIO line을 요청합니다. 이 ioctl은 `chardev_v1.rst`의 ABI v1에 속하며 `gpio-v2-get-line-ioctl.rst`로 대체되었습니다.

호출 형식은 `int ioctl(int chip_fd, GPIO_GET_LINEEVENT_IOCTL, struct gpioevent_request *request)`입니다. `chip_fd`는 GPIO character device를 `open()`해 얻고, `request`는 요청할 line과 구성을 지정하는 `gpioevent_request` 구조체입니다.

Line event 요청 인자
항목설명
chip_fdGPIO character device file descriptor
requeststruct gpioevent_request pointer
결과 fdrequest.fd

입력 구조체는 대상 line과 edge 감지 구성을 함께 전달합니다.

.. SPDX-License-Identifier: GPL-2.0

.. _GPIO_GET_LINEEVENT_IOCTL:

************************
GPIO_GET_LINEEVENT_IOCTL
************************

.. warning::
    This ioctl is part of chardev_v1.rst and is obsoleted by
    gpio-v2-get-line-ioctl.rst.

Name
====

GPIO_GET_LINEEVENT_IOCTL - Request a line with edge detection from the kernel.

Synopsis
========

.. c:macro:: GPIO_GET_LINEEVENT_IOCTL

``int ioctl(int chip_fd, GPIO_GET_LINEEVENT_IOCTL, struct gpioevent_request *request)``

Arguments
=========

``chip_fd``
    The file descriptor of the GPIO character device returned by `open()`.

``request``
    The :c:type:`event_request<gpioevent_request>` specifying the line
    to request and its configuration.

배타적 접근과 수명

35-58

호출은 kernel에 edge detection을 적용한 line을 요청합니다. 성공하면 요청 process가 line 값에 대한 배타적 접근 권한을 얻고, `gpio-lineevent-data-read.rst`에 설명된 방식으로 line에서 edge가 감지될 때 이벤트를 받을 수 있습니다.

반환된 file descriptor가 닫힐 때까지 line 상태는 요청한 그대로 유지됩니다. Descriptor를 닫은 뒤에는 사용자 공간 관점에서 line 상태가 제어되지 않으며 기본 상태로 되돌아갈 수 있습니다.

이미 사용 중인 line을 요청하면 `EBUSY`이고, interrupt를 지원하지 않는 line에 edge detection을 요청하면 `ENXIO`입니다. Line handle과 마찬가지로 bias 구성은 best effort입니다. 기존 line event를 유지한 채 `chip_fd`를 닫아도 그 event에는 영향이 없습니다.

Line event 수명
chip_fd로 line event 요청배타적 line 접근 획득request.fd로 edge event 수신chip_fd를 닫아도 event 유지request.fd를 닫으면 line 상태 보장 종료

Chip descriptor와 event descriptor의 수명은 서로 독립적입니다.

Description
===========

Request a line with edge detection from the kernel.

On success, the requesting process is granted exclusive access to the line
value and may receive events when edges are detected on the line, as
described in gpio-lineevent-data-read.rst.

The state of a line is guaranteed to remain as requested until the returned
file descriptor is closed. Once the file descriptor is closed, the state of
the line becomes uncontrolled from the userspace perspective, and may revert
to its default state.

Requesting a line already in use is an error (**EBUSY**).

Requesting edge detection on a line that does not support interrupts is an
error (**ENXIO**).

As with the :ref:`line handle<gpio-get-linehandle-config-support>`, the
bias configuration is best effort.

Closing the ``chip_fd`` has no effect on existing line events.

구성 규칙

59-76

Line event는 input으로 요청되므로 output 전용 flag인 `GPIOHANDLE_REQUEST_OUTPUT`, `GPIOHANDLE_REQUEST_OPEN_DRAIN`, `GPIOHANDLE_REQUEST_OPEN_SOURCE`를 설정할 수 없습니다.

`GPIOHANDLE_REQUEST_BIAS_xxx` 계열 bias flag는 하나만 설정할 수 있습니다. Bias flag를 설정하지 않으면 기존 bias 구성을 바꾸지 않습니다.

`GPIOEVENT_REQUEST_RISING_EDGE`와 `GPIOEVENT_REQUEST_FALLING_EDGE`는 함께 설정하여 rising edge와 falling edge를 모두 감지할 수 있습니다. 유효하지 않은 구성을 요청하면 `EINVAL`입니다.

Line event flag 규칙
항목설명
Output flag설정 금지
Bias flag최대 하나, 없으면 구성 유지
RISING_EDGE단독 또는 FALLING_EDGE와 결합 가능
FALLING_EDGE단독 또는 RISING_EDGE와 결합 가능
Invalid combinationEINVAL

허용되는 조합과 오류 조건을 정리했습니다.

Configuration Rules
-------------------

The following configuration rules apply:

The line event is requested as an input, so no flags specific to output lines,
``GPIOHANDLE_REQUEST_OUTPUT``, ``GPIOHANDLE_REQUEST_OPEN_DRAIN``, or
``GPIOHANDLE_REQUEST_OPEN_SOURCE``, may be set.

Only one bias flag, ``GPIOHANDLE_REQUEST_BIAS_xxx``, may be set.
If no bias flags are set then the bias configuration is not changed.

The edge flags, ``GPIOEVENT_REQUEST_RISING_EDGE`` and
``GPIOEVENT_REQUEST_FALLING_EDGE``, may be combined to detect both rising
and falling edges.

Requesting an invalid configuration is an error (**EINVAL**).

반환값

77-84

성공하면 0을 반환하고 `gpioevent_request`의 `request.fd`에 요청 file descriptor를 저장합니다. 실패하면 -1을 반환하고 `errno`를 설정합니다. 공통 오류 코드는 `error-codes.rst`를 따릅니다.

Return Value
============

On success 0 and the :c:type:`request.fd<gpioevent_request>` contains the file
descriptor for the request.

On error -1 and the ``errno`` variable is set appropriately.
Common error codes are described in error-codes.rst.