gpio-lineinfo-changed-read.rst 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. .. SPDX-License-Identifier: GPL-2.0
  2. .. _GPIO_LINEINFO_CHANGED_READ:
  3. **************************
  4. GPIO_LINEINFO_CHANGED_READ
  5. **************************
  6. .. warning::
  7. This ioctl is part of chardev_v1.rst and is obsoleted by
  8. gpio-v2-lineinfo-changed-read.rst.
  9. Name
  10. ====
  11. GPIO_LINEINFO_CHANGED_READ - Read line info change events for watched lines
  12. from the chip.
  13. Synopsis
  14. ========
  15. ``int read(int chip_fd, void *buf, size_t count)``
  16. Arguments
  17. =========
  18. ``chip_fd``
  19. The file descriptor of the GPIO character device returned by `open()`.
  20. ``buf``
  21. The buffer to contain the :c:type:`events<gpioline_info_changed>`.
  22. ``count``
  23. The number of bytes available in ``buf``, which must be at least the size
  24. of a :c:type:`gpioline_info_changed` event.
  25. Description
  26. ===========
  27. Read line info change events for watched lines from the chip.
  28. .. note::
  29. Monitoring line info changes is not generally required, and would typically
  30. only be performed by a system monitoring component.
  31. These events relate to changes in a line's request state or configuration,
  32. not its value. Use gpio-lineevent-data-read.rst to receive events when a
  33. line changes value.
  34. A line must be watched using gpio-get-lineinfo-watch-ioctl.rst to generate
  35. info changed events. Subsequently, a request, release, or reconfiguration
  36. of the line will generate an info changed event.
  37. The kernel timestamps events when they occur and stores them in a buffer
  38. from where they can be read by userspace at its convenience using `read()`.
  39. The size of the kernel event buffer is fixed at 32 events per ``chip_fd``.
  40. The buffer may overflow if bursts of events occur quicker than they are read
  41. by userspace. If an overflow occurs then the most recent event is discarded.
  42. Overflow cannot be detected from userspace.
  43. Events read from the buffer are always in the same order that they were
  44. detected by the kernel, including when multiple lines are being monitored by
  45. the one ``chip_fd``.
  46. To minimize the number of calls required to copy events from the kernel to
  47. userspace, `read()` supports copying multiple events. The number of events
  48. copied is the lower of the number available in the kernel buffer and the
  49. number that will fit in the userspace buffer (``buf``).
  50. A `read()` will block if no event is available and the ``chip_fd`` has not
  51. been set **O_NONBLOCK**.
  52. The presence of an event can be tested for by checking that the ``chip_fd`` is
  53. readable using `poll()` or an equivalent.
  54. First added in 5.7.
  55. Return Value
  56. ============
  57. On success the number of bytes read, which will be a multiple of the size of
  58. a :c:type:`gpioline_info_changed` event.
  59. On error -1 and the ``errno`` variable is set appropriately.
  60. Common error codes are described in error-codes.rst.