net/rfkill/rfkill-gpio.c
Source file repositories/reference/linux-study-clean/net/rfkill/rfkill-gpio.c
File Facts
- System
- Linux kernel
- Corpus path
net/rfkill/rfkill-gpio.c- Extension
.c- Size
- 5311 bytes
- Lines
- 222
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/dmi.hlinux/init.hlinux/kernel.hlinux/module.hlinux/mod_devicetable.hlinux/rfkill.hlinux/of.hlinux/platform_device.hlinux/clk.hlinux/slab.hlinux/acpi.hlinux/gpio/consumer.h
Detected Declarations
struct rfkill_gpio_datafunction rfkill_gpio_set_powerfunction rfkill_gpio_acpi_probefunction rfkill_gpio_probefunction rfkill_gpio_remove
Annotated Snippet
struct rfkill_gpio_data {
const char *name;
enum rfkill_type type;
struct gpio_desc *reset_gpio;
struct gpio_desc *shutdown_gpio;
struct rfkill *rfkill_dev;
struct clk *clk;
bool clk_enabled;
};
static int rfkill_gpio_set_power(void *data, bool blocked)
{
struct rfkill_gpio_data *rfkill = data;
if (!blocked && !IS_ERR(rfkill->clk) && !rfkill->clk_enabled) {
int ret = clk_enable(rfkill->clk);
if (ret)
return ret;
}
gpiod_set_value_cansleep(rfkill->shutdown_gpio, !blocked);
gpiod_set_value_cansleep(rfkill->reset_gpio, !blocked);
if (blocked && !IS_ERR(rfkill->clk) && rfkill->clk_enabled)
clk_disable(rfkill->clk);
rfkill->clk_enabled = !blocked;
return 0;
}
static const struct rfkill_ops rfkill_gpio_ops = {
.set_block = rfkill_gpio_set_power,
};
static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
static const struct acpi_gpio_params shutdown_gpios = { 1, 0, false };
static const struct acpi_gpio_mapping acpi_rfkill_default_gpios[] = {
{ "reset-gpios", &reset_gpios, 1 },
{ "shutdown-gpios", &shutdown_gpios, 1 },
{ },
};
static int rfkill_gpio_acpi_probe(struct device *dev,
struct rfkill_gpio_data *rfkill)
{
const struct acpi_device_id *id;
id = acpi_match_device(dev->driver->acpi_match_table, dev);
if (!id)
return -ENODEV;
rfkill->type = (unsigned)id->driver_data;
return devm_acpi_dev_add_driver_gpios(dev, acpi_rfkill_default_gpios);
}
/* List of DMI matches for devices on which rfkill-gpio should not load,
* to avoid firmware bugs.
*/
static const struct dmi_system_id rfkill_gpio_deny_table[] = {
{
/* Lenovo Yoga Tab 3 Pro YT3-X90, bogus "BCM4752" device in DSDT */
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
DMI_MATCH(DMI_PRODUCT_VERSION, "Blade3-10A-001"),
},
},
{ }
};
static int rfkill_gpio_probe(struct platform_device *pdev)
{
struct rfkill_gpio_data *rfkill;
const char *type_name = NULL;
const char *name_property;
const char *type_property;
struct gpio_desc *gpio;
int ret;
if (dmi_check_system(rfkill_gpio_deny_table))
return -ENODEV;
rfkill = devm_kzalloc(&pdev->dev, sizeof(*rfkill), GFP_KERNEL);
if (!rfkill)
return -ENOMEM;
Annotation
- Immediate include surface: `linux/dmi.h`, `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/rfkill.h`, `linux/of.h`, `linux/platform_device.h`.
- Detected declarations: `struct rfkill_gpio_data`, `function rfkill_gpio_set_power`, `function rfkill_gpio_acpi_probe`, `function rfkill_gpio_probe`, `function rfkill_gpio_remove`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source 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.