← Documents Documentation/userspace-api/gpio/error-codes.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API

GPIO 오류 코드

GPIO ioctl의 공통 errno 의미와 재시도·중단 판단 원칙을 정리합니다.

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

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

1. 요약·해설

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

요약·해설

error-codes.rst:1-79

GPIO ioctl의 공통 errno 의미와 재시도·중단 판단 원칙을 정리합니다.

원문의 문단, symbol, source path, ioctl 이름, 자료형, 표와 줄 좌표를 보존해 전문 번역했습니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 .. _gpio_errors:
4
5 *******************
6 GPIO Error Codes
7 *******************
8
9 .. _gpio-errors:
10
11 .. tabularcolumns:: |p{2.5cm}|p{15.0cm}|
12
13 .. flat-table:: Common GPIO error codes
14 :header-rows: 0
15 :stub-columns: 0
16 :widths: 1 16
17
18 - - ``EAGAIN`` (aka ``EWOULDBLOCK``)
19
20 - The device was opened in non-blocking mode and a read can't
21 be performed as there is no data available.
22
23 - - ``EBADF``
24
25 - The file descriptor is not valid.
26
27 - - ``EBUSY``
28
29 - The ioctl can't be handled because the device is busy. Typically
30 returned when an ioctl attempts something that would require the
31 usage of a resource that was already allocated. The ioctl must not
32 be retried without performing another action to fix the problem
33 first.
34
35 - - ``EFAULT``
36
37 - There was a failure while copying data from/to userspace, probably
38 caused by an invalid pointer reference.
39
40 - - ``EINVAL``
41
42 - One or more of the ioctl parameters are invalid or out of the
43 allowed range. This is a widely used error code.
44
45 - - ``ENODEV``
46
47 - Device not found or was removed.
48
49 - - ``ENOMEM``
50
51 - There's not enough memory to handle the desired operation.
52
53 - - ``EPERM``
54
55 - Permission denied. Typically returned in response to an attempt
56 to perform an action incompatible with the current line
57 configuration.
58
59 - - ``EIO``
60
61 - I/O error. Typically returned when there are problems communicating
62 with a hardware device or requesting features that hardware does not
63 support. This could indicate broken or flaky hardware.
64 It's a 'Something is wrong, I give up!' type of error.
65
66 - - ``ENXIO``
67
68 - Typically returned when a feature requiring interrupt support was
69 requested, but the line does not support interrupts.
70
71 .. note::
72
73 #. This list is not exhaustive; ioctls may return other error codes.
74 Since errors may have side effects such as a driver reset,
75 applications should abort on unexpected errors, or otherwise
76 assume that the device is in a bad state.
77
78 #. Request-specific error codes are listed in the individual
79 requests descriptions.
80

3. 한국어 전문 번역

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

공통 오류 표

1-16

이 문서는 GPIO ioctl에서 공통으로 반환될 수 있는 errno 값을 정리합니다. 표는 오류 코드와 의미를 대응시키며, 개별 요청에만 해당하는 오류는 각 요청 문서에서 별도로 설명합니다.

.. SPDX-License-Identifier: GPL-2.0

.. _gpio_errors:

*******************
GPIO Error Codes
*******************

.. _gpio-errors:

.. tabularcolumns:: |p{2.5cm}|p{15.0cm}|

.. flat-table:: Common GPIO error codes
    :header-rows:  0
    :stub-columns: 0
    :widths: 1 16

대기, 파일 디스크립터, 요청 상태 오류

17-43

`EAGAIN` 또는 `EWOULDBLOCK`은 장치를 non-blocking mode로 열었지만 읽을 데이터가 없어 즉시 read를 수행할 수 없다는 뜻입니다. `EBADF`는 file descriptor가 유효하지 않다는 뜻입니다.

`EBUSY`는 장치가 사용 중이어서 ioctl을 처리할 수 없다는 뜻입니다. 일반적으로 ioctl에 필요한 resource가 이미 할당된 경우 반환됩니다. 문제를 바로잡는 다른 조치를 먼저 수행하지 않았다면 같은 ioctl을 재시도해서는 안 됩니다.

`EFAULT`는 사용자 공간과 데이터를 복사하는 과정이 실패했다는 뜻이며 잘못된 pointer 참조가 원인일 가능성이 큽니다. `EINVAL`은 하나 이상의 ioctl parameter가 잘못됐거나 허용 범위를 벗어났다는 뜻으로, 여러 상황에서 널리 사용되는 오류 코드입니다.

요청과 상태 관련 오류
오류의미
EAGAIN / EWOULDBLOCKNon-blocking read에 사용할 데이터가 없음
EBADF유효하지 않은 file descriptor
EBUSY필요 resource가 이미 사용 중이며 원인 해소 전 재시도 금지
EFAULT사용자 공간 복사 실패 또는 잘못된 pointer
EINVAL잘못됐거나 범위를 벗어난 ioctl parameter

즉시 재시도 가능 여부는 오류 원인에 따라 다릅니다.


    -  -  ``EAGAIN`` (aka ``EWOULDBLOCK``)

       -  The device was opened in non-blocking mode and a read can't
          be performed as there is no data available.

    -  -  ``EBADF``

       -  The file descriptor is not valid.

    -  -  ``EBUSY``

       -  The ioctl can't be handled because the device is busy. Typically
          returned when an ioctl attempts something that would require the
          usage of a resource that was already allocated. The ioctl must not
          be retried without performing another action to fix the problem
          first.

    -  -  ``EFAULT``

       -  There was a failure while copying data from/to userspace, probably
	  caused by an invalid pointer reference.

    -  -  ``EINVAL``

       -  One or more of the ioctl parameters are invalid or out of the
          allowed range. This is a widely used error code.

장치, 메모리, 권한, I/O 오류

44-69

`ENODEV`는 장치를 찾을 수 없거나 장치가 제거됐다는 뜻이고, `ENOMEM`은 원하는 연산을 처리할 메모리가 부족하다는 뜻입니다.

`EPERM`은 권한이 거부됐다는 뜻입니다. 보통 현재 line configuration과 호환되지 않는 동작을 시도했을 때 반환됩니다.

`EIO`는 I/O 오류입니다. 하드웨어 장치와 통신하는 데 문제가 있거나 하드웨어가 지원하지 않는 기능을 요청했을 때 흔히 반환됩니다. 고장 났거나 불안정한 하드웨어를 나타낼 수 있으며, 더 진행할 수 없는 포괄적 실패로 취급해야 합니다.

`ENXIO`는 대개 interrupt 지원이 필요한 기능을 요청했지만 해당 line이 interrupt를 지원하지 않을 때 반환됩니다.

장치와 기능 관련 오류
오류의미
ENODEV장치가 없거나 제거됨
ENOMEM연산 처리에 필요한 메모리 부족
EPERM현재 line configuration과 호환되지 않는 동작
EIO하드웨어 통신 실패 또는 미지원 기능
ENXIOInterrupt가 필요한 기능을 line이 지원하지 않음

장치 상태와 hardware capability를 함께 확인해야 하는 오류입니다.


    -  -  ``ENODEV``

       -  Device not found or was removed.

    -  -  ``ENOMEM``

       -  There's not enough memory to handle the desired operation.

    -  -  ``EPERM``

       -  Permission denied. Typically returned in response to an attempt
          to perform an action incompatible with the current line
          configuration.

    -  -  ``EIO``

       -  I/O error. Typically returned when there are problems communicating
          with a hardware device or requesting features that hardware does not
          support. This could indicate broken or flaky hardware.
          It's a 'Something is wrong, I give up!' type of error.

    -  - ``ENXIO``

       -  Typically returned when a feature requiring interrupt support was
          requested, but the line does not support interrupts.

예상하지 못한 오류 처리

70-79

이 목록은 모든 오류를 망라하지 않으며 ioctl은 다른 오류 코드도 반환할 수 있습니다. 오류 처리에는 driver reset 같은 부작용이 따를 수 있으므로, 예상하지 못한 오류가 발생하면 application을 중단해야 합니다. 계속 실행해야 한다면 장치가 비정상 상태라고 가정해야 합니다.

특정 요청에만 해당하는 오류 코드는 각 요청의 설명에 나열됩니다.

GPIO ioctl 오류 처리
ioctl 실패와 errno 확인개별 요청 문서의 오류 목록과 대조알려진 복구 절차가 있으면 상태를 먼저 수정예상하지 못한 오류면 application 중단계속해야 한다면 장치를 비정상 상태로 취급

예상 범위 밖의 errno를 정상적인 재시도 신호로 간주하지 않습니다.


.. note::

  #. This list is not exhaustive; ioctls may return other error codes.
     Since errors may have side effects such as a driver reset,
     applications should abort on unexpected errors, or otherwise
     assume that the device is in a bad state.

  #. Request-specific error codes are listed in the individual
     requests descriptions.