drivers/platform/chrome/wilco_ec/keyboard_leds.c
Source file repositories/reference/linux-study-clean/drivers/platform/chrome/wilco_ec/keyboard_leds.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/chrome/wilco_ec/keyboard_leds.c- Extension
.c- Size
- 5202 bytes
- Lines
- 204
- Domain
- Driver Families
- Bucket
- drivers/platform
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/device.hlinux/kernel.hlinux/leds.hlinux/platform_data/wilco-ec.hlinux/slab.h
Detected Declarations
struct wilco_keyboard_ledsstruct wilco_keyboard_leds_msgenum wilco_kbbl_subcommandfunction send_kbbl_msgfunction set_kbblfunction kbbl_existfunction kbbl_initfunction wilco_keyboard_leds_setfunction wilco_keyboard_leds_init
Annotated Snippet
struct wilco_keyboard_leds {
struct wilco_ec_device *ec;
struct led_classdev keyboard;
};
enum wilco_kbbl_subcommand {
WILCO_KBBL_SUBCMD_GET_FEATURES = 0x00,
WILCO_KBBL_SUBCMD_GET_STATE = 0x01,
WILCO_KBBL_SUBCMD_SET_STATE = 0x02,
};
/**
* struct wilco_keyboard_leds_msg - Message to/from EC for keyboard LED control.
* @command: Always WILCO_EC_COMMAND_KBBL.
* @status: Set by EC to 0 on success, 0xFF on failure.
* @subcmd: One of enum wilco_kbbl_subcommand.
* @reserved3: Should be 0.
* @mode: Bit flags for used mode, we want to use WILCO_KBBL_MODE_FLAG_PWM.
* @reserved5to8: Should be 0.
* @percent: Brightness in 0-100. Only meaningful in PWM mode.
* @reserved10to15: Should be 0.
*/
struct wilco_keyboard_leds_msg {
u8 command;
u8 status;
u8 subcmd;
u8 reserved3;
u8 mode;
u8 reserved5to8[4];
u8 percent;
u8 reserved10to15[6];
} __packed;
/* Send a request, get a response, and check that the response is good. */
static int send_kbbl_msg(struct wilco_ec_device *ec,
struct wilco_keyboard_leds_msg *request,
struct wilco_keyboard_leds_msg *response)
{
struct wilco_ec_message msg;
int ret;
memset(&msg, 0, sizeof(msg));
msg.type = WILCO_EC_MSG_LEGACY;
msg.request_data = request;
msg.request_size = sizeof(*request);
msg.response_data = response;
msg.response_size = sizeof(*response);
ret = wilco_ec_mailbox(ec, &msg);
if (ret < 0) {
dev_err(ec->dev,
"Failed sending keyboard LEDs command: %d\n", ret);
return ret;
}
return 0;
}
static int set_kbbl(struct wilco_ec_device *ec, enum led_brightness brightness)
{
struct wilco_keyboard_leds_msg request;
struct wilco_keyboard_leds_msg response;
int ret;
memset(&request, 0, sizeof(request));
request.command = WILCO_EC_COMMAND_KBBL;
request.subcmd = WILCO_KBBL_SUBCMD_SET_STATE;
request.mode = WILCO_KBBL_MODE_FLAG_PWM;
request.percent = brightness;
ret = send_kbbl_msg(ec, &request, &response);
if (ret < 0)
return ret;
if (response.status) {
dev_err(ec->dev,
"EC reported failure sending keyboard LEDs command: %d\n",
response.status);
return -EIO;
}
return 0;
}
static int kbbl_exist(struct wilco_ec_device *ec, bool *exists)
{
struct wilco_keyboard_leds_msg request;
struct wilco_keyboard_leds_msg response;
int ret;
Annotation
- Immediate include surface: `linux/device.h`, `linux/kernel.h`, `linux/leds.h`, `linux/platform_data/wilco-ec.h`, `linux/slab.h`.
- Detected declarations: `struct wilco_keyboard_leds`, `struct wilco_keyboard_leds_msg`, `enum wilco_kbbl_subcommand`, `function send_kbbl_msg`, `function set_kbbl`, `function kbbl_exist`, `function kbbl_init`, `function wilco_keyboard_leds_set`, `function wilco_keyboard_leds_init`.
- Atlas domain: Driver Families / drivers/platform.
- 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.