Function Description The core.c file implements the core functionalities for the RF switch subsystem, including state management and event handling for RF switches. It defines the struct rfkill and related operations.
struct rfkill {
spinlock_t lock;
enum rfkill_type type;
unsigned long state;
u32 idx;
bool registered;
bool persistent;
bool polling_paused;
bool suspended;
const struct rfkill_ops *ops;
void *data;
#ifdef CONFIG_RFKILL_LEDS
struct led_trigger led_trigger;
const char *ledtrigname;
#endif
struct device dev;
struct list_head node;
struct delayed_work poll_work;
struct work_struct uevent_work;
struct work_struct sync_work;
char name[];
};
Open Capabilities - Custom State Management: Developers can extend the state management by implementing their own rfkill_ops structure, which includes functions like poll, set_block, and query. - Device Registration: Through the rfkill_register function, developers can register their own RF switch devices with the system. - LED Trigger Support: If LED support is enabled, developers can customize the behavior of LEDs using the led_trigger structure.
int __must_check rfkill_register(struct rfkill *rfkill) {
}
void rfkill_unregister(struct rfkill *rfkill) {
}
void rfkill_destroy(struct rfkill *rfkill) {
}
Function Description The Kconfig file allows users to configure the RF switch subsystem via the kernel configuration tool. It enables or disables the subsystem and its optional features, such as LED trigger support and input handling.
menuconfig RFKILL
tristate "RF switch subsystem support"
help
Say Y here if you want to have control over RF switches found on many WiFi and Bluetooth cards.
Open Capabilities - Configurable Subsystem: Users can enable or disable the RF switch subsystem and its features, allowing for flexibility in kernel configurations.
Function Description The rfkill.h header file defines the API for the RF switch subsystem, including functions for global switch operations, emergency power-off, and state restoration.
void rfkill_switch_all(const enum rfkill_type type, bool blocked);
void rfkill_epo(void);
void rfkill_restore_states(void);
Open Capabilities - API Access: Developers can use the provided API to control all RF switches, perform an emergency power-off, and restore states, allowing for high-level control over the subsystem.
Function Description The rfkill-gpio.c file provides a generic GPIO-based RF kill driver. It handles the initialization, probing, and removal of GPIO-based RF switches.
static int rfkill_gpio_probe(struct platform_device *pdev) {
struct rfkill_gpio_data *rfkill;
struct gpio_desc *gpio;
const char *type_name;
int ret;
rfkill = devm_kzalloc(&pdev->dev, sizeof(*rfkill), GFP_KERNEL);
if (!rfkill)
return -ENOMEM;
device_property_read_string(&pdev->dev, "name", &rfkill->name);
device_property_read_string(&pdev->dev, "type", &type_name);
if (!rfkill->name)
rfkill->name = dev_name(&pdev->dev);
rfkill->type = rfkill_find_type(type_name);
if (ACPI_HANDLE(&pdev->dev)) {
ret = rfkill_gpio_acpi_probe(&pdev->dev, rfkill);
if (ret)
return ret;
}
rfkill->clk = devm_clk_get(&pdev->dev, NULL);
gpio = devm_gpiod_get_optional(&pdev->dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(gpio))
return PTR_ERR(gpio);
rfkill->reset_gpio = gpio;
gpio = devm_gpiod_get_optional(&pdev->dev, "shutdown", GPIOD_OUT_LOW);
if (IS_ERR(gpio))
return PTR_ERR(gpio);
rfkill->shutdown_gpio = gpio;
if (!rfkill->reset_gpio && !rfkill->shutdown_gpio) {
dev_err(&pdev->dev, "invalid platform data\n");
return -EINVAL;
}
rfkill->rfkill_dev = rfkill_alloc(rfkill->name, &pdev->dev,
rfkill->type, &rfkill_gpio_ops,
rfkill);
if (!rfkill->rfkill_dev)
return -ENOMEM;
ret = rfkill_register(rfkill->rfkill_dev);
if (ret < 0)
goto err_destroy;
platform_set_drvdata(pdev, rfkill);
dev_info(&pdev->dev, "%s device registered.\n", rfkill->name);
return 0;
err_destroy:
rfkill_destroy(rfkill->rfkill_dev);
return ret;
}
static int rfkill_gpio_remove(struct platform_device *pdev) {
struct rfkill_gpio_data *rfkill = platform_get_drvdata(pdev);
rfkill_unregister(rfkill->rfkill_dev);
rfkill_destroy(rfkill->rfkill_dev);
return 0;
}
Open Capabilities - GPIO Customization: Developers can customize the GPIO-based RF switch driver to work with specific hardware, including setting up GPIOs and handling probe and remove operations. - Platform Device Support: The driver integrates with the platform device framework, making it easy to add support for new hardware.
Function Description The input.c file provides an interface between the RF switch subsystem and the input layer. It handles input events and translates them into RF switch commands.
static struct input_handler rfkill_handler = {
.name = "rfkill",
.event = rfkill_event,
.connect = rfkill_connect,
.start = rfkill_start,
.disconnect = rfkill_disconnect,
.id_table = rfkill_ids,
};
static void rfkill_event(struct input_handle *handle, unsigned int type,
unsigned int code, int data) {
if (type == EV_KEY && data == 1) {
switch (code) {
case KEY_WLAN:
rfkill_schedule_toggle(RFKILL_TYPE_WLAN);
break;
case KEY_BLUETOOTH:
rfkill_schedule_toggle(RFKILL_TYPE_BLUETOOTH);
break;
case KEY_UWB:
rfkill_schedule_toggle(RFKILL_TYPE_UWB);
break;
case KEY_WIMAX:
rfkill_schedule_toggle(RFKILL_TYPE_WIMAX);
break;
case KEY_RFKILL:
rfkill_schedule_toggle(RFKILL_TYPE_ALL);
break;
}
} else if (type == EV_SW && code == SW_RFKILL_ALL)
rfkill_schedule_evsw_rfkillall(data);
}
Open Capabilities - Input Event Handling: Developers can extend the input handler to handle custom input events and translate them into RF switch commands, providing a flexible way to interact with the RF switch subsystem.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。