Skip to contentSkip to conversation

Documentation: gpio: add character device userspace API documentation

PATCH In review Kent Gibson 3 participants 15 messages Jan 15, 2024 – Jan 22, 2024

Subsystems (3)
lore
Share & tools
lore

Kent Gibson

author reviewer
#0 lore raw

v2 cover Documentation: gpio: add character device userspace API documentation

My new year's resolution was to improve the documentation of the character device API and gpio in general, so here we are.

Wrt the formatting and file breakdown, I've taken inspiration from the userspace-api/media documentation.

Patch 1 adds documentation for the current chardev uAPI. I've added it to the userspace-api book, as that is the most obvious place a reader would look for it, but have also provided links from the admin-guide book where the gpio docs currently reside.

I realise MAINTAINERS should be updated with Documentation/userspace-api/gpio/, but the split out of GPIO UAPI hasn't made it into gpio/for-next yet, so I was unsure of how to handle that.

Patch 2 updates the gpio-cdev ABI documentation to reference the chardev documentation as well as gpio.h.

Patch 3 updates the sysfs-gpio ABI documentation to reference the gpio-cdev ABI that obsoletes it.

Patch 4 relocates the sysfs API doc to stress its deprecation by moving it to a new obsolete section, again in userspace-api but with a similar section in the admin-guide. The obsolete section also serves as a placeholder for subsequent changes.

Patch 5 updates the sysfs API doc to reference the chardev documentation rather than gpio.h and make use of reST formatting.

Patch 6 adds documentation for the obsolete v1 version of the chardev uAPI. It is obsolete, but still useful to have, if nothing else to help identify the differences between v1 and v2.

Patch 7 capitalizes the title of the admin-guide/gpio to match the other subsystems and the userspace-api book.

Patch 8 adds an obsolescence note to the gpio-mockup, as it is obsoleted by the gpio-sim.

Patch 9 moves the gpio-mockup doc into the obsolete section.

I've got some minor updates for the kernel doc in gpio.h as well, but they make sense on their own so I've sent those separately to keep the cross-posting to a minimum.

I realise the only thing less exciting than writing documentation is reviewing it, so my apologies and thanks in advance if you have the fortitude to attempt such a scintillating endeavour.

Cheers,
Kent.

Changes v1 -> v2:
- add Linus' review tag (patch 1)
- add first added kernel version for APIs, and ioctls where they were added separately from the API they are part of (patch 1 and 6).
- add note that requesting a line in use is an error (EBUSY), GPIO_v2_GET_LINE_IOCTL (patch 1), GPIO_GET_LINEEVENT_IOCTL and GPIO_GET_LINEHANDLE_IOCTL (patch 6).
- add updating gpio-cdev interface doc to reference chardev.rst (patch 2).
- add updating sysfs-gpio interface doc to reference gpio-cdev (patch 3).
- rename deprecated section to obsolete section (patch 4, 6 and 9).
- rework obsolescence warning and abuse note in sysfs.rst to make use of reST formatting for emphasis, rather than ALL CAPS, and to note that the interface is to be removed in the future (patch 5).
- note that the v1 API will be removed in the future (patch 6).

Kent Gibson (9):
Documentation: gpio: add chardev userspace API documentation
Documentation: ABI: update gpio-cdev to reference chardev.rst
Documentation: ABI: update sysfs-gpio to reference gpio-cdev
Documentation: gpio: move sysfs into an obsolete section
Documentation: gpio: update sysfs documentation to reference new
chardev doc
Documentation: gpio: add chardev v1 userspace API documentation
Documentation: gpio: capitalize GPIO in index title
Documentation: gpio: document gpio-mockup as obsoleted by gpio-sim
Documentation: gpio: move gpio-mockup into obsolete section

 Documentation/ABI/obsolete/sysfs-gpio         |   4 +-
 Documentation/ABI/testing/gpio-cdev           |   9 +-
 .../admin-guide/gpio/gpio-mockup.rst          |   8 ++
 Documentation/admin-guide/gpio/index.rst      |   6 +-
 Documentation/admin-guide/gpio/obsolete.rst   |  13 ++
 Documentation/userspace-api/gpio/chardev.rst  | 116 ++++++++++++++++
 .../userspace-api/gpio/chardev_v1.rst         | 131 ++++++++++++++++++
 .../userspace-api/gpio/error-codes.rst        |  78 +++++++++++
 .../gpio/gpio-get-chipinfo-ioctl.rst          |  41 ++++++
 .../gpio/gpio-get-lineevent-ioctl.rst         |  78 +++++++++++
 .../gpio/gpio-get-linehandle-ioctl.rst        |  86 ++++++++++++
 .../gpio/gpio-get-lineinfo-ioctl.rst          |  54 ++++++++
 .../gpio/gpio-get-lineinfo-unwatch-ioctl.rst  |  49 +++++++
 .../gpio/gpio-get-lineinfo-watch-ioctl.rst    |  74 ++++++++++
 .../gpio-handle-get-line-values-ioctl.rst     |  56 ++++++++
 .../gpio/gpio-handle-set-config-ioctl.rst     |  62 +++++++++
 .../gpio-handle-set-line-values-ioctl.rst     |  48 +++++++
 .../gpio/gpio-lineevent-data-read.rst         |  84 +++++++++++
 .../gpio/gpio-lineinfo-changed-read.rst       |  87 ++++++++++++
 .../gpio/gpio-v2-get-line-ioctl.rst           | 101 ++++++++++++++
 .../gpio/gpio-v2-get-lineinfo-ioctl.rst       |  50 +++++++
 .../gpio/gpio-v2-get-lineinfo-watch-ioctl.rst |  67 +++++++++
 .../gpio/gpio-v2-line-event-read.rst          |  83 +++++++++++
 .../gpio/gpio-v2-line-get-values-ioctl.rst    |  51 +++++++
 .../gpio/gpio-v2-line-set-config-ioctl.rst    |  57 ++++++++
 .../gpio/gpio-v2-line-set-values-ioctl.rst    |  47 +++++++
 .../gpio/gpio-v2-lineinfo-changed-read.rst    |  81 +++++++++++
 Documentation/userspace-api/gpio/index.rst    |  18 +++
 Documentation/userspace-api/gpio/obsolete.rst |  11 ++
 .../gpio/sysfs.rst                            |  27 ++--
 Documentation/userspace-api/index.rst         |   1 +
 31 files changed, 1657 insertions(+), 21 deletions(-)
 create mode 100644 Documentation/admin-guide/gpio/obsolete.rst
 create mode 100644 Documentation/userspace-api/gpio/chardev.rst
 create mode 100644 Documentation/userspace-api/gpio/chardev_v1.rst
 create mode 100644 Documentation/userspace-api/gpio/error-codes.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-get-chipinfo-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-get-lineevent-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-get-linehandle-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-get-lineinfo-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-get-lineinfo-unwatch-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-get-lineinfo-watch-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-handle-get-line-values-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-handle-set-config-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-handle-set-line-values-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-lineevent-data-read.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-lineinfo-changed-read.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-v2-get-line-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-v2-get-lineinfo-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-v2-get-lineinfo-watch-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-v2-line-event-read.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-v2-line-get-values-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-v2-line-set-config-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-v2-line-set-values-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-v2-lineinfo-changed-read.rst
 create mode 100644 Documentation/userspace-api/gpio/index.rst
 create mode 100644 Documentation/userspace-api/gpio/obsolete.rst
 rename Documentation/{admin-guide => userspace-api}/gpio/sysfs.rst (89%)
Signature · 1 line
2.39.2
author reviewer
#1 lore raw

PATCH v2 1/9 Documentation: gpio: add chardev userspace API documentation

Add documentation for the GPIO character device userspace API.

Added to the userspace-api book, but also provide a link from the admin-guide book, as historically the GPIO documentation has been there.

---
 Documentation/admin-guide/gpio/index.rst      |   1 +
 Documentation/userspace-api/gpio/chardev.rst  | 116 ++++++++++++++++++
 .../userspace-api/gpio/error-codes.rst        |  78 ++++++++++++
 .../gpio/gpio-get-chipinfo-ioctl.rst          |  41 +++++++
 .../gpio/gpio-get-lineinfo-unwatch-ioctl.rst  |  49 ++++++++
 .../gpio/gpio-v2-get-line-ioctl.rst           | 101 +++++++++++++++
 .../gpio/gpio-v2-get-lineinfo-ioctl.rst       |  50 ++++++++
 .../gpio/gpio-v2-get-lineinfo-watch-ioctl.rst |  67 ++++++++++
 .../gpio/gpio-v2-line-event-read.rst          |  83 +++++++++++++
 .../gpio/gpio-v2-line-get-values-ioctl.rst    |  51 ++++++++
 .../gpio/gpio-v2-line-set-config-ioctl.rst    |  57 +++++++++
 .../gpio/gpio-v2-line-set-values-ioctl.rst    |  47 +++++++
 .../gpio/gpio-v2-lineinfo-changed-read.rst    |  81 ++++++++++++
 Documentation/userspace-api/gpio/index.rst    |  17 +++
 Documentation/userspace-api/index.rst         |   1 +
 15 files changed, 840 insertions(+)
 create mode 100644 Documentation/userspace-api/gpio/chardev.rst
 create mode 100644 Documentation/userspace-api/gpio/error-codes.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-get-chipinfo-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-get-lineinfo-unwatch-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-v2-get-line-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-v2-get-lineinfo-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-v2-get-lineinfo-watch-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-v2-line-event-read.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-v2-line-get-values-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-v2-line-set-config-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-v2-line-set-values-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-v2-lineinfo-changed-read.rst
 create mode 100644 Documentation/userspace-api/gpio/index.rst
Documentation/admin-guide/gpio/index.rst +1 -0
index f6861ca16ffe..b40f0a2a6822 100644
@@ -7,6 +7,7 @@ gpio
 .. toctree::
     :maxdepth: 1
 
+    Character Device Userspace API <../../userspace-api/gpio/chardev>
     gpio-aggregator
     sysfs
     gpio-mockup
Documentation/userspace-api/gpio/chardev.rst new file +116 -0

116 lines not on this page · raw message

Documentation/userspace-api/gpio/error-codes.rst new file +78 -0

78 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-get-chipinfo-ioctl.rst new file +41 -0

41 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-get-lineinfo-unwatch-ioctl.rst new file +49 -0

49 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-v2-get-line-ioctl.rst new file +101 -0

101 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-v2-get-lineinfo-ioctl.rst new file +50 -0

50 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-v2-get-lineinfo-watch-ioctl.rst new file +67 -0

67 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-v2-line-event-read.rst new file +83 -0

83 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-v2-line-get-values-ioctl.rst new file +51 -0

51 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-v2-line-set-config-ioctl.rst new file +57 -0

57 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-v2-line-set-values-ioctl.rst new file +47 -0

47 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-v2-lineinfo-changed-read.rst new file +81 -0

81 lines not on this page · raw message

Documentation/userspace-api/gpio/index.rst new file +17 -0
new file mode 100644
index 000000000000..072b9fa18aea
@@ -0,0 +1,17 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+====
+GPIO
+====
+
+.. toctree::
+    :maxdepth: 1
+
+    Character Device Userspace API <chardev>
+
+.. only::  subproject and html
+
+   Indices
+   =======
+
+   * :ref:`genindex`
Documentation/userspace-api/index.rst +1 -0
index 031df47a7c19..8e174a605f69 100644
@@ -25,6 +25,7 @@ place where this information is gathered.
    dma-buf-alloc-exchange
    ebpf/index
    ELF
+   gpio/index
    ioctl/index
    iommu
    iommufd
Signature · 1 line
2.39.2
author reviewer
#4 lore raw

PATCH v2 2/9 Documentation: ABI: update gpio-cdev to reference chardev.rst

In reply to Kent Gibson

Update the gpio-cdev interface document to refer to the new chardev.rst.

---
 Documentation/ABI/testing/gpio-cdev | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
Documentation/ABI/testing/gpio-cdev +5 -4
index 66bdcd188b6c..c9689b2a6fed 100644
@@ -6,8 +6,9 @@ Description:
 		The character device files /dev/gpiochip* are the interface
 		between GPIO chips and userspace.
 
-		The ioctl(2)-based ABI is defined and documented in
-		[include/uapi]<linux/gpio.h>.
+		The ioctl(2)-based ABI is defined in
+		[include/uapi]<linux/gpio.h> and documented in
+		Documentation/userspace-api/gpio/chardev.rst.
 
 		The following file operations are supported:
 
@@ -17,8 +18,8 @@ Description:
 		ioctl(2)
 		  Initiate various actions.
 
-		  See the inline documentation in [include/uapi]<linux/gpio.h>
-		  for descriptions of all ioctls.
+		  See Documentation/userspace-api/gpio/chardev.rst
+		  for a description of all ioctls.
 
 		close(2)
 		  Stops and free up the I/O contexts that was associated
Signature · 1 line
2.39.2
author reviewer
#5 lore raw

PATCH v2 3/9 Documentation: ABI: update sysfs-gpio to reference gpio-cdev

In reply to Kent Gibson

Update the sysfs-gpio interface document to refer to the gpio-cdev interface that obsoletes it.

---
 Documentation/ABI/obsolete/sysfs-gpio | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/ABI/obsolete/sysfs-gpio +2 -2
index b8b0fd341c17..da1345d854b4 100644
@@ -28,5 +28,5 @@ Description:
 	    /label ... (r/o) descriptive, not necessarily unique
 	    /ngpio ... (r/o) number of GPIOs; numbered N to N + (ngpio - 1)
 
-  This ABI is deprecated and will be removed after 2020. It is
-  replaced with the GPIO character device.
+  This ABI is obsoleted by Documentation/ABI/testing/gpio-cdev and will be
+  removed after 2020.
Signature · 1 line
2.39.2
author reviewer
#6 lore raw

PATCH v2 4/9 Documentation: gpio: move sysfs into an obsolete section

In reply to Kent Gibson

The GPIO sysfs API is long obsolete, so highlight this even further by moving it into an obsolete APIs section in both the admin-guide and userspace-api books.

---
 Documentation/admin-guide/gpio/index.rst              |  2 +-
 Documentation/admin-guide/gpio/obsolete.rst           | 11 +++++++++++
 Documentation/userspace-api/gpio/index.rst            |  1 +
 Documentation/userspace-api/gpio/obsolete.rst         | 10 ++++++++++
 .../{admin-guide => userspace-api}/gpio/sysfs.rst     |  0
 5 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/admin-guide/gpio/obsolete.rst
 create mode 100644 Documentation/userspace-api/gpio/obsolete.rst
 rename Documentation/{admin-guide => userspace-api}/gpio/sysfs.rst (100%)
Documentation/admin-guide/gpio/index.rst +1 -1
index b40f0a2a6822..3ac3aa15fa8b 100644
@@ -9,9 +9,9 @@ gpio
 
     Character Device Userspace API <../../userspace-api/gpio/chardev>
     gpio-aggregator
-    sysfs
     gpio-mockup
     gpio-sim
+    Obsolete APIs <obsolete>
 
 .. only::  subproject and html
 
Documentation/admin-guide/gpio/obsolete.rst new file +11 -0
new file mode 100644
index 000000000000..dbf88f13c680
@@ -0,0 +1,11 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+==================
+Obsolete GPIO APIs
+==================
+
+.. toctree::
+    :maxdepth: 1
+
+    Sysfs Interface <../../userspace-api/gpio/sysfs>
+
Documentation/userspace-api/gpio/index.rst +1 -0
index 072b9fa18aea..f258de4ef370 100644
@@ -8,6 +8,7 @@ GPIO
     :maxdepth: 1
 
     Character Device Userspace API <chardev>
+    Obsolete Userspace APIs <obsolete>
 
 .. only::  subproject and html
 
Documentation/userspace-api/gpio/obsolete.rst new file +10 -0
new file mode 100644
index 000000000000..c27bd6014a3d
@@ -0,0 +1,10 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+============================
+Obsolete GPIO Userspace APIs
+============================
+
+.. toctree::
+    :maxdepth: 1
+
+    Sysfs Interface <sysfs>
Documentation/userspace-api/gpio/sysfs.rst renamed from Documentation/admin-guide/gpio/sysfs.rst +0 -0
similarity index 100%
rename from Documentation/admin-guide/gpio/sysfs.rst
rename to Documentation/userspace-api/gpio/sysfs.rst
Signature · 1 line
2.39.2
author reviewer
#7 lore raw

PATCH v2 5/9 Documentation: gpio: update sysfs documentation to reference new chardev doc

In reply to Kent Gibson

Update GPIO sysfs interface documentation to reference the new chardev document rather than gpio.h.

---
 Documentation/userspace-api/gpio/sysfs.rst | 27 ++++++++++++----------
 1 file changed, 15 insertions(+), 12 deletions(-)
Documentation/userspace-api/gpio/sysfs.rst +15 -12
index 35171d15f78d..e12037a0f2b4 100644
@@ -2,18 +2,18 @@ GPIO Sysfs Interface for Userspace
 ==================================
 
 .. warning::
+   This API is obsoleted by the chardev.rst and the ABI documentation has
+   been moved to Documentation/ABI/obsolete/sysfs-gpio.
 
-  THIS ABI IS DEPRECATED, THE ABI DOCUMENTATION HAS BEEN MOVED TO
-  Documentation/ABI/obsolete/sysfs-gpio AND NEW USERSPACE CONSUMERS
-  ARE SUPPOSED TO USE THE CHARACTER DEVICE ABI. THIS OLD SYSFS ABI WILL
-  NOT BE DEVELOPED (NO NEW FEATURES), IT WILL JUST BE MAINTAINED.
+   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.
 
-Refer to the examples in tools/gpio/* for an introduction to the new
-character device ABI. Also see the userspace header in
-include/uapi/linux/gpio.h
+   This interface will continue to be maintained for the migration period,
+   but new features will only be added to the new API.
 
-The deprecated sysfs ABI
-------------------------
+The obsolete sysfs ABI
+----------------------
 Platforms 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
@@ -33,9 +33,12 @@ 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.
 
-DO NOT ABUSE SYSFS TO CONTROL HARDWARE THAT HAS PROPER KERNEL DRIVERS.
-PLEASE READ THE DOCUMENT AT Documentation/driver-api/gpio/drivers-on-gpio.rst
-TO AVOID REINVENTING KERNEL WHEELS IN USERSPACE. I MEAN IT. REALLY.
+.. note::
+   Do 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.
 
 Paths in Sysfs
 --------------
Signature · 1 line
2.39.2
author reviewer
#8 lore raw

PATCH v2 6/9 Documentation: gpio: add chardev v1 userspace API documentation

In reply to Kent Gibson

Add documentation for v1 of the GPIO character device userspace API to the obsolete section of both the admin-guide and userspace-api books.

---
 Documentation/admin-guide/gpio/obsolete.rst   |   1 +
 .../userspace-api/gpio/chardev_v1.rst         | 131 ++++++++++++++++++
 .../gpio/gpio-get-lineevent-ioctl.rst         |  78 +++++++++++
 .../gpio/gpio-get-linehandle-ioctl.rst        |  86 ++++++++++++
 .../gpio/gpio-get-lineinfo-ioctl.rst          |  54 ++++++++
 .../gpio/gpio-get-lineinfo-unwatch-ioctl.rst  |   2 +-
 .../gpio/gpio-get-lineinfo-watch-ioctl.rst    |  74 ++++++++++
 .../gpio-handle-get-line-values-ioctl.rst     |  56 ++++++++
 .../gpio/gpio-handle-set-config-ioctl.rst     |  62 +++++++++
 .../gpio-handle-set-line-values-ioctl.rst     |  48 +++++++
 .../gpio/gpio-lineevent-data-read.rst         |  84 +++++++++++
 .../gpio/gpio-lineinfo-changed-read.rst       |  87 ++++++++++++
 Documentation/userspace-api/gpio/obsolete.rst |   1 +
 13 files changed, 763 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/userspace-api/gpio/chardev_v1.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-get-lineevent-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-get-linehandle-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-get-lineinfo-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-get-lineinfo-watch-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-handle-get-line-values-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-handle-set-config-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-handle-set-line-values-ioctl.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-lineevent-data-read.rst
 create mode 100644 Documentation/userspace-api/gpio/gpio-lineinfo-changed-read.rst
Documentation/admin-guide/gpio/obsolete.rst +1 -0
index dbf88f13c680..5926e5440207 100644
@@ -7,5 +7,6 @@ Obsolete GPIO APIs
 .. toctree::
     :maxdepth: 1
 
+    Character Device Userspace API (v1) <../../userspace-api/gpio/chardev_v1>
     Sysfs Interface <../../userspace-api/gpio/sysfs>
 
Documentation/userspace-api/gpio/chardev_v1.rst new file +131 -0

131 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-get-lineevent-ioctl.rst new file +78 -0

78 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-get-linehandle-ioctl.rst new file +86 -0

86 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-get-lineinfo-ioctl.rst new file +54 -0

54 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-get-lineinfo-unwatch-ioctl.rst +1 -1
index 2fec6f12e3bf..a82d0161daf8 100644
@@ -33,7 +33,7 @@ Description
 
 Remove the line from the list of lines being watched on this ``chip_fd``.
 
-This is the opposite of gpio-v2-get-lineinfo-watch-ioctl.rst (v2) and
+This is the reverse of gpio-v2-get-lineinfo-watch-ioctl.rst (v2) and
 gpio-get-lineinfo-watch-ioctl.rst (v1).
 
 Unwatching a line that is not watched is an error (**EBUSY**).
Documentation/userspace-api/gpio/gpio-get-lineinfo-watch-ioctl.rst new file +74 -0

74 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-handle-get-line-values-ioctl.rst new file +56 -0

56 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-handle-set-config-ioctl.rst new file +62 -0

62 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-handle-set-line-values-ioctl.rst new file +48 -0

48 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-lineevent-data-read.rst new file +84 -0

84 lines not on this page · raw message

Documentation/userspace-api/gpio/gpio-lineinfo-changed-read.rst new file +87 -0

87 lines not on this page · raw message

Documentation/userspace-api/gpio/obsolete.rst +1 -0
index c27bd6014a3d..c42538b44ec8 100644
@@ -7,4 +7,5 @@ Obsolete GPIO Userspace APIs
 .. toctree::
     :maxdepth: 1
 
+    Character Device Userspace API (v1) <chardev_v1>
     Sysfs Interface <sysfs>
Signature · 1 line
2.39.2
author reviewer
#9 lore raw

PATCH v2 7/9 Documentation: gpio: capitalize GPIO in index title

In reply to Kent Gibson

Capitalise the title of the GPIO documentation page to match other subsystems.

---
 Documentation/admin-guide/gpio/index.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/admin-guide/gpio/index.rst +1 -1
index 3ac3aa15fa8b..3f6d5a76702b 100644
@@ -1,7 +1,7 @@
 .. SPDX-License-Identifier: GPL-2.0
 
 ====
-gpio
+GPIO
 ====
 
 .. toctree::
Signature · 1 line
2.39.2
author reviewer
#10 lore raw

PATCH v2 8/9 Documentation: gpio: document gpio-mockup as obsoleted by gpio-sim

In reply to Kent Gibson

Update the gpio-mockup documentation to note that is has been obsoleted by the gpio-sim.

---
 Documentation/admin-guide/gpio/gpio-mockup.rst | 8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/admin-guide/gpio/gpio-mockup.rst +8 -0
index 493071da1738..d6e7438a7550 100644
@@ -3,6 +3,14 @@
 GPIO Testing Driver
 ===================
 
+.. note::
+
+   This module has been obsoleted by the more flexible gpio-sim.rst.
+   New developments should use that API and existing developments are
+   encouraged to migrate as soon as possible.
+   This module will continue to be maintained but no new features will be
+   added.
+
 The GPIO Testing Driver (gpio-mockup) provides a way to create simulated GPIO
 chips for testing purposes. The lines exposed by these chips can be accessed
 using the standard GPIO character device interface as well as manipulated
Signature · 1 line
2.39.2
author reviewer
#11 lore raw

PATCH v2 9/9 Documentation: gpio: move gpio-mockup into obsolete section

In reply to Kent Gibson

The gpio-mockup has been obsoleted by the gpio-sim, so relocate its documentation into the obsolete section of the admin-guide book.

---
 Documentation/admin-guide/gpio/index.rst    | 1 -
 Documentation/admin-guide/gpio/obsolete.rst | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)
Documentation/admin-guide/gpio/index.rst +0 -1
index 3f6d5a76702b..460afd29617e 100644
@@ -9,7 +9,6 @@ GPIO
 
     Character Device Userspace API <../../userspace-api/gpio/chardev>
     gpio-aggregator
-    gpio-mockup
     gpio-sim
     Obsolete APIs <obsolete>
 
Documentation/admin-guide/gpio/obsolete.rst +1 -0
index 5926e5440207..5adbff02d61f 100644
@@ -9,4 +9,5 @@ Obsolete GPIO APIs
 
     Character Device Userspace API (v1) <../../userspace-api/gpio/chardev_v1>
     Sysfs Interface <../../userspace-api/gpio/sysfs>
+    Mockup Testing Module <gpio-mockup>
 
Signature · 1 line
2.39.2
#2 lore raw

Re: [PATCH v2 1/9] Documentation: gpio: add chardev userspace API documentation

In reply to Kent Gibson
Quoted 6 lines · Kent Gibson

Add documentation for the GPIO character device userspace API.

Added to the userspace-api book, but also provide a link from the admin-guide book, as historically the GPIO documentation has been there.

...

Documentation/userspace-api/gpio/chardev.rst line 24

Quoted 13 lines

+.. note::

Documentation/userspace-api/gpio/chardev.rst new file +12 -0
+   Do NOT abuse userspace APIs to control hardware that has proper kernel
+   drivers. There may already be a driver for your use case, and an existing
+   kernel driver is sure to provide a superior solution to bitbashing
+   from userspace.
+
+   Read Documentation/driver-api/gpio/drivers-on-gpio.rst to avoid reinventing
+   kernel wheels in userspace.
+
+   Similarly, for multi-function lines there may be other subsystems, such as
+   Documentation/spi/index.rst, Documentation/i2c/index.rst,
+   Documentation/driver-api/pwm.rst, Documentation/w1/index.rst etc, that
+   provide suitable drivers and APIs for your hardware.

Very good note and would be nice to convince users to follow it:
https://stackoverflow.com/q/77683532/2511795
(OOH you might be proud it's Rust, OTOH as described above)

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#12 lore raw

Re: [PATCH v2 9/9] Documentation: gpio: move gpio-mockup into obsolete section

In reply to Kent Gibson
Quoted 3 lines · Kent Gibson

The gpio-mockup has been obsoleted by the gpio-sim, so relocate its documentation into the obsolete section of the admin-guide book.

...

Quoted 3 lines

Character Device Userspace API (v1) <../../userspace-api/gpio/chardev_v1> Sysfs Interface <../../userspace-api/gpio/sysfs>
+ Mockup Testing Module <gpio-mockup>

Not because of the alphabetical ordering, but historically/semantically shouldn't this be in between? (I'm fine with either way, just asking)

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author reviewer
#3 lore raw

Re: [PATCH v2 1/9] Documentation: gpio: add chardev userspace API documentation

In reply to Andy Shevchenko
Quoted 19 lines · Andy Shevchenko
Quoted 6 lines · Kent Gibson

Add documentation for the GPIO character device userspace API.

Added to the userspace-api book, but also provide a link from the admin-guide book, as historically the GPIO documentation has been there.

...

Quoted 9 lines

+.. note::

Documentation/userspace-api/gpio/chardev.rst new file +8 -0
+   Do NOT abuse userspace APIs to control hardware that has proper kernel
+   drivers. There may already be a driver for your use case, and an existing
+   kernel driver is sure to provide a superior solution to bitbashing
+   from userspace.
+
+   Read Documentation/driver-api/gpio/drivers-on-gpio.rst to avoid reinventing
+   kernel wheels in userspace.
+
Quoted 9 lines

Documentation/userspace-api/gpio/chardev.rst line 24

Quoted 4 lines
Documentation/userspace-api/gpio/chardev.rst new file +4 -0
+   Similarly, for multi-function lines there may be other subsystems, such as
+   Documentation/spi/index.rst, Documentation/i2c/index.rst,
+   Documentation/driver-api/pwm.rst, Documentation/w1/index.rst etc, that
+   provide suitable drivers and APIs for your hardware.

Very good note and would be nice to convince users to follow it:
https://stackoverflow.com/q/77683532/2511795
(OOH you might be proud it's Rust, OTOH as described above)

Not familiar with that sensor. And wasn't sure what they were up to or why, so didn't comment. You do a good job reminding people in the forums, though, as above, not sure how many listen.

I'm language agnostic, so choose the language that suits your use case. You can still do stupid things in any language, though the language may constrain the set of stupid things you have to play with, or throw in some bonus ones you didn't realise you were getting (I'm looking at you C++).

Cheers,
Kent.

author reviewer
#13 lore raw

Re: [PATCH v2 9/9] Documentation: gpio: move gpio-mockup into obsolete section

In reply to Andy Shevchenko
Quoted 7 lines · Andy Shevchenko
Quoted 3 lines · Kent Gibson

The gpio-mockup has been obsoleted by the gpio-sim, so relocate its documentation into the obsolete section of the admin-guide book.

...

Quoted 8 lines
Quoted 3 lines

Character Device Userspace API (v1) <../../userspace-api/gpio/chardev_v1> Sysfs Interface <../../userspace-api/gpio/sysfs>
+ Mockup Testing Module <gpio-mockup>

Not because of the alphabetical ordering, but historically/semantically shouldn't this be in between? (I'm fine with either way, just asking)

It is in order of most interest to the reader, hopefully. The first two are arguable, but the mockup is clearly last there. sysfs may actually be of more interest on average, but anyone still hanging on to sysfs deserves what they get.
If the list were longer I would switch to alphabetical.

Cheers,
Kent.

#14 lore raw
In reply to Kent Gibson
Quoted 43 lines · Kent Gibson

My new year's resolution was to improve the documentation of the character device API and gpio in general, so here we are.

Wrt the formatting and file breakdown, I've taken inspiration from the userspace-api/media documentation.

Patch 1 adds documentation for the current chardev uAPI. I've added it to the userspace-api book, as that is the most obvious place a reader would look for it, but have also provided links from the admin-guide book where the gpio docs currently reside.

I realise MAINTAINERS should be updated with Documentation/userspace-api/gpio/, but the split out of GPIO UAPI hasn't made it into gpio/for-next yet, so I was unsure of how to handle that.

Patch 2 updates the gpio-cdev ABI documentation to reference the chardev documentation as well as gpio.h.

Patch 3 updates the sysfs-gpio ABI documentation to reference the gpio-cdev ABI that obsoletes it.

Patch 4 relocates the sysfs API doc to stress its deprecation by moving it to a new obsolete section, again in userspace-api but with a similar section in the admin-guide. The obsolete section also serves as a placeholder for subsequent changes.

Patch 5 updates the sysfs API doc to reference the chardev documentation rather than gpio.h and make use of reST formatting.

Patch 6 adds documentation for the obsolete v1 version of the chardev uAPI. It is obsolete, but still useful to have, if nothing else to help identify the differences between v1 and v2.

Patch 7 capitalizes the title of the admin-guide/gpio to match the other subsystems and the userspace-api book.

Patch 8 adds an obsolescence note to the gpio-mockup, as it is obsoleted by the gpio-sim.

Patch 9 moves the gpio-mockup doc into the obsolete section.

Quoted 8 lines

I've got some minor updates for the kernel doc in gpio.h as well, but they make sense on their own so I've sent those separately to keep the cross-posting to a minimum.

I realise the only thing less exciting than writing documentation is reviewing it, so my apologies and thanks in advance if you have the fortitude to attempt such a scintillating endeavour.

Not all heroes wear capes. Thanks for doing this Kent!

Queued the series for v6.9.

[snip]