drivers/gpio/gpiolib-legacy.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpiolib-legacy.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpiolib-legacy.c- Extension
.c- Size
- 2521 bytes
- Lines
- 110
- Domain
- Driver Families
- Bucket
- drivers/gpio
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/device.hlinux/errno.hlinux/export.hlinux/gfp.hlinux/gpio/consumer.hlinux/gpio/driver.hlinux/gpio.hgpiolib.h
Detected Declarations
function gpio_freefunction gpio_request_onefunction gpio_requestfunction devm_gpio_releasefunction devm_gpio_request_oneexport gpio_freeexport gpio_request_oneexport gpio_requestexport devm_gpio_request_one
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <linux/bitops.h>
#include <linux/device.h>
#include <linux/errno.h>
#include <linux/export.h>
#include <linux/gfp.h>
#include <linux/gpio/consumer.h>
#include <linux/gpio/driver.h>
#include <linux/gpio.h>
#include "gpiolib.h"
/*
* **DEPRECATED** This function is deprecated and must not be used in new code.
*/
void gpio_free(unsigned gpio)
{
gpiod_free(gpio_to_desc(gpio));
}
EXPORT_SYMBOL_GPL(gpio_free);
/**
* gpio_request_one - request a single GPIO with initial configuration
* @gpio: the GPIO number
* @flags: GPIO configuration as specified by GPIOF_*
* @label: a literal description string of this GPIO
*
* **DEPRECATED** This function is deprecated and must not be used in new code.
*
* Returns:
* 0 on success, or negative errno on failure.
*/
int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
{
int err;
err = gpio_request(gpio, label);
if (err)
return err;
if (flags & GPIOF_IN)
err = gpio_direction_input(gpio);
else
err = gpio_direction_output(gpio, !!(flags & GPIOF_OUT_INIT_HIGH));
if (err)
gpio_free(gpio);
return err;
}
EXPORT_SYMBOL_GPL(gpio_request_one);
/*
* **DEPRECATED** This function is deprecated and must not be used in new code.
*/
int gpio_request(unsigned gpio, const char *label)
{
struct gpio_desc *desc;
/* Compatibility: assume unavailable "valid" GPIOs will appear later */
desc = gpio_to_desc(gpio);
if (!desc)
return -EPROBE_DEFER;
return gpiod_request(desc, label);
}
EXPORT_SYMBOL_GPL(gpio_request);
static void devm_gpio_release(void *gpio)
{
gpio_free((unsigned)(unsigned long)gpio);
}
/**
* devm_gpio_request_one - request a single GPIO with initial setup
* @dev: device to request for
* @gpio: the GPIO number
* @flags: GPIO configuration as specified by GPIOF_*
* @label: a literal description string of this GPIO
*
* **DEPRECATED** This function is deprecated and must not be used in new code.
*
* Returns:
* 0 on success, or negative errno on failure.
*/
int devm_gpio_request_one(struct device *dev, unsigned gpio,
unsigned long flags, const char *label)
{
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/device.h`, `linux/errno.h`, `linux/export.h`, `linux/gfp.h`, `linux/gpio/consumer.h`, `linux/gpio/driver.h`, `linux/gpio.h`.
- Detected declarations: `function gpio_free`, `function gpio_request_one`, `function gpio_request`, `function devm_gpio_release`, `function devm_gpio_request_one`, `export gpio_free`, `export gpio_request_one`, `export gpio_request`, `export devm_gpio_request_one`.
- Atlas domain: Driver Families / drivers/gpio.
- Implementation status: integration implementation candidate.
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.