mirror of
https://github.com/apache/nuttx.git
synced 2026-08-20 04:58:28 +00:00
The pins a board publishes are visible in /dev and each can be read through its own node, but surveying a whole board that way means an open and two ioctls per pin, and the signal and interrupt counters the upper half keeps are not reachable through any of them. Adds a list of registered pins and publishes it as /proc/gpio, behind GPIO_PROCFS: a quality of life view of the same kind as /proc/pinctrl and /proc/reset. Every common field comes from state the upper half already holds: the pin type, the value through go_read(), how many times the pin has been registered for signals, and how many interrupts it has taken. Lines carry the same key:value tokens in the same order, so the file is machine parseable. Lower halves may supply an optional go_describe() adding what only they can say, such as which pad carries the line or how its trigger is configured. It writes text into a caller supplied buffer and the upper half owns the line, so a lower half needs no procfs knowledge. A lower half without it is listed with the common tokens alone. The pin type index is bounded before use: it comes from the lower half and the name table cannot cover a type the enumeration does not define. A pin that cannot be read reports val:- rather than a zero that would read as a real level. procfs_register() appends without checking for duplicates, so the entry is claimed once for the lifetime of the system rather than whenever the list is empty; pins come and go at run time. The name is held in a buffer as long as the one gpio_pin_register() accepts, so a listing always names the same string as /dev. The pin type name table is declared without an explicit size so that the assertion beside it compares against the enumeration and can fail; sized as [GPIO_NPINTYPES] it would have been tautological. Documents the entry, its tokens, and how a lower half describes a pin. Off by default: with GPIO_PROCFS unset the list, the lock and the procfs entry are compiled out, and go_describe() is one more member at the end of a structure existing lower halves do not reach. Assisted-by: Claude:claude-opus-5 Signed-off-by: Justin Hammond <justin@dynam.ac> |
||
|---|---|---|
| .. | ||
| arch | ||
| audio | ||
| concurrency | ||
| drivers | ||
| filesystem | ||
| libs | ||
| mm | ||
| net | ||
| nxgraphics | ||
| tools | ||
| binfmt.rst | ||
| boards.rst | ||
| cmake.rst | ||
| crypto.rst | ||
| index.rst | ||
| nxflat.rst | ||
| openamp.rst | ||
| paging.rst | ||
| syscall.rst | ||
| video.rst | ||
| wireless.rst | ||