Documentation/driver-api/gpio/legacy-boards.rst
Source file repositories/reference/linux-study-clean/Documentation/driver-api/gpio/legacy-boards.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/driver-api/gpio/legacy-boards.rst- Extension
.rst- Size
- 9982 bytes
- Lines
- 317
- Domain
- Support Tooling And Documentation
- Bucket
- Documentation
- Inferred role
- Support Tooling And Documentation: documentation
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/platform_device.hlinux/leds.hlinux/gpio_keys.hlinux/gpio/machine.hlinux/property.hlinux/gpio/property.h
Detected Declarations
function myboard_initfunction myboard_initfunction myboard_initfunction myboard_exit
Annotated Snippet
if (error) {
pr_err("Failed to register software nodes: %d\n", error);
return error;
}
// ... platform device registration follows
}
.. note::
When splitting registration of nodes by devices that they represent, it is
essential that the software node representing the GPIO controller itself
is registered first, before any of the nodes that reference it.
Step 4: Register Platform Devices with Software Nodes
*****************************************************
Finally, register the platform devices and associate them with their respective
software nodes using the ``fwnode`` field in struct platform_device_info.
.. code-block:: c
static struct platform_device *leds_pdev;
static struct platform_device *keys_pdev;
static int __init myboard_init(void)
{
struct platform_device_info pdev_info;
int error;
error = software_node_register_node_group(myboard_swnodes);
if (error)
return error;
memset(&pdev_info, 0, sizeof(pdev_info));
pdev_info.name = MYBOARD_GPIO_CONTROLLER;
pdev_info.id = PLATFORM_DEVID_NONE;
pdev_info.swnode = &myboard_gpio_controller_node;
gpio_pdev = platform_device_register_full(&pdev_info);
if (IS_ERR(gpio_pdev)) {
error = PTR_ERR(gpio_pdev);
goto err_unregister_nodes;
}
memset(&pdev_info, 0, sizeof(pdev_info));
pdev_info.name = "leds-gpio";
pdev_info.id = PLATFORM_DEVID_NONE;
pdev_info.fwnode = software_node_fwnode(&myboard_leds_node);
leds_pdev = platform_device_register_full(&pdev_info);
if (IS_ERR(leds_pdev)) {
error = PTR_ERR(leds_pdev);
platform_device_unregister(gpio_pdev);
goto err_unregister_nodes;
}
memset(&pdev_info, 0, sizeof(pdev_info));
pdev_info.name = "gpio-keys";
pdev_info.id = PLATFORM_DEVID_NONE;
pdev_info.fwnode = software_node_fwnode(&myboard_keys_node);
keys_pdev = platform_device_register_full(&pdev_info);
if (IS_ERR(keys_pdev)) {
error = PTR_ERR(keys_pdev);
platform_device_unregister(gpio_pdev);
platform_device_unregister(leds_pdev);
goto err_unregister_nodes;
}
return 0;
err_unregister_nodes:
software_node_unregister_node_group(myboard_swnodes);
Annotation
- Immediate include surface: `linux/platform_device.h`, `linux/leds.h`, `linux/gpio_keys.h`, `linux/gpio/machine.h`, `linux/property.h`, `linux/gpio/property.h`.
- Detected declarations: `function myboard_init`, `function myboard_init`, `function myboard_init`, `function myboard_exit`.
- Atlas domain: Support Tooling And Documentation / Documentation.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.