drivers/input/keyboard/lm8323.c
Source file repositories/reference/linux-study-clean/drivers/input/keyboard/lm8323.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/keyboard/lm8323.c- Extension
.c- Size
- 21269 bytes
- Lines
- 814
- Domain
- Driver Families
- Bucket
- drivers/input
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/module.hlinux/i2c.hlinux/interrupt.hlinux/sched.hlinux/mutex.hlinux/delay.hlinux/input.hlinux/leds.hlinux/platform_data/lm8323.hlinux/pm.hlinux/slab.hlinux/string_choices.h
Detected Declarations
struct lm8323_pwmstruct lm8323_chipfunction lm8323_writefunction lm8323_readfunction timefunction statefunction lm8323_ispressfunction process_keysfunction lm8323_process_errorfunction lm8323_resetfunction lm8323_configurefunction pwm_donefunction lm8323_irqfunction lm8323_read_idfunction lm8323_write_pwm_onefunction lm8323_write_pwmfunction lm8323_pwm_workfunction timefunction lm8323_pwm_set_brightnessfunction scoped_guardfunction scoped_guardfunction lm8323_pwm_show_timefunction lm8323_pwm_store_timefunction init_pwmfunction lm8323_show_disablefunction lm8323_set_disablefunction lm8323_probefunction lm8323_suspendfunction scoped_guardfunction lm8323_resumefunction scoped_guard
Annotated Snippet
struct lm8323_pwm {
int id;
int fade_time;
int brightness;
int desired_brightness;
bool enabled;
bool running;
/* pwm lock */
struct mutex lock;
struct work_struct work;
struct led_classdev cdev;
struct lm8323_chip *chip;
};
struct lm8323_chip {
/* device lock */
struct mutex lock;
struct i2c_client *client;
struct input_dev *idev;
bool kp_enabled;
bool pm_suspend;
unsigned keys_down;
char phys[32];
unsigned short keymap[LM8323_KEYMAP_SIZE];
int size_x;
int size_y;
int debounce_time;
int active_time;
struct lm8323_pwm pwm[LM8323_NUM_PWMS];
};
#define client_to_lm8323(c) container_of(c, struct lm8323_chip, client)
#define dev_to_lm8323(d) container_of(d, struct lm8323_chip, client->dev)
#define cdev_to_pwm(c) container_of(c, struct lm8323_pwm, cdev)
#define work_to_pwm(w) container_of(w, struct lm8323_pwm, work)
#define LM8323_MAX_DATA 8
/*
* To write, we just access the chip's address in write mode, and dump the
* command and data out on the bus. The command byte and data are taken as
* sequential u8s out of varargs, to a maximum of LM8323_MAX_DATA.
*/
static int lm8323_write(struct lm8323_chip *lm, int len, ...)
{
int ret, i;
va_list ap;
u8 data[LM8323_MAX_DATA];
va_start(ap, len);
if (unlikely(len > LM8323_MAX_DATA)) {
dev_err(&lm->client->dev, "tried to send %d bytes\n", len);
va_end(ap);
return 0;
}
for (i = 0; i < len; i++)
data[i] = va_arg(ap, int);
va_end(ap);
/*
* If the host is asleep while we send the data, we can get a NACK
* back while it wakes up, so try again, once.
*/
ret = i2c_master_send(lm->client, data, len);
if (unlikely(ret == -EREMOTEIO))
ret = i2c_master_send(lm->client, data, len);
if (unlikely(ret != len))
dev_err(&lm->client->dev, "sent %d bytes of %d total\n",
len, ret);
return ret;
}
/*
* To read, we first send the command byte to the chip and end the transaction,
* then access the chip in read mode, at which point it will send the data.
*/
static int lm8323_read(struct lm8323_chip *lm, u8 cmd, u8 *buf, int len)
{
int ret;
/*
* If the host is asleep while we send the byte, we can get a NACK
* back while it wakes up, so try again, once.
*/
ret = i2c_master_send(lm->client, &cmd, 1);
if (unlikely(ret == -EREMOTEIO))
Annotation
- Immediate include surface: `linux/module.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/sched.h`, `linux/mutex.h`, `linux/delay.h`, `linux/input.h`, `linux/leds.h`.
- Detected declarations: `struct lm8323_pwm`, `struct lm8323_chip`, `function lm8323_write`, `function lm8323_read`, `function time`, `function state`, `function lm8323_ispress`, `function process_keys`, `function lm8323_process_error`, `function lm8323_reset`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.