drivers/input/touchscreen/mms114.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/mms114.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/mms114.c- Extension
.c- Size
- 17479 bytes
- Lines
- 714
- 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/delay.hlinux/of.hlinux/i2c.hlinux/input/mt.hlinux/input/touchscreen.hlinux/interrupt.hlinux/regulator/consumer.hlinux/slab.h
Detected Declarations
struct mms114_datastruct mms114_touchenum mms_typefunction __mms114_read_regfunction mms114_read_regfunction mms114_write_regfunction mms114_process_mtfunction mms114_process_touchkeyfunction mms114_interruptfunction mms114_set_activefunction mms114_get_versionfunction mms114_setup_regsfunction mms114_startfunction mms114_stopfunction mms114_input_openfunction mms114_input_closefunction mms114_parse_legacy_bindingsfunction mms114_probefunction mms114_suspendfunction mms114_resume
Annotated Snippet
struct mms114_data {
struct i2c_client *client;
struct input_dev *input_dev;
struct regulator *core_reg;
struct regulator *io_reg;
struct touchscreen_properties props;
enum mms_type type;
unsigned int contact_threshold;
unsigned int moving_threshold;
u32 keycodes[MMS114_MAX_TOUCHKEYS];
int num_keycodes;
/* Use cache data for mode control register(write only) */
u8 cache_mode_control;
};
struct mms114_touch {
u8 id:4, reserved_bit4:1, type:2, pressed:1;
u8 x_hi:4, y_hi:4;
u8 x_lo;
u8 y_lo;
u8 width;
u8 strength;
u8 reserved[2];
} __packed;
static int __mms114_read_reg(struct mms114_data *data, unsigned int reg,
unsigned int len, u8 *val)
{
struct i2c_client *client = data->client;
struct i2c_msg xfer[2];
u8 buf = reg & 0xff;
int error;
if (reg <= MMS114_MODE_CONTROL && reg + len > MMS114_MODE_CONTROL)
BUG();
/* Write register */
xfer[0].addr = client->addr;
xfer[0].flags = client->flags & I2C_M_TEN;
xfer[0].len = 1;
xfer[0].buf = &buf;
/* Read data */
xfer[1].addr = client->addr;
xfer[1].flags = (client->flags & I2C_M_TEN) | I2C_M_RD;
xfer[1].len = len;
xfer[1].buf = val;
error = i2c_transfer(client->adapter, xfer, 2);
if (error != 2) {
dev_err(&client->dev,
"%s: i2c transfer failed (%d)\n", __func__, error);
return error < 0 ? error : -EIO;
}
udelay(MMS114_I2C_DELAY);
return 0;
}
static int mms114_read_reg(struct mms114_data *data, unsigned int reg)
{
u8 val;
int error;
if (reg == MMS114_MODE_CONTROL)
return data->cache_mode_control;
error = __mms114_read_reg(data, reg, 1, &val);
return error < 0 ? error : val;
}
static int mms114_write_reg(struct mms114_data *data, unsigned int reg,
unsigned int val)
{
struct i2c_client *client = data->client;
u8 buf[2];
int error;
buf[0] = reg & 0xff;
buf[1] = val & 0xff;
error = i2c_master_send(client, buf, 2);
if (error != 2) {
dev_err(&client->dev,
"%s: i2c send failed (%d)\n", __func__, error);
return error < 0 ? error : -EIO;
}
udelay(MMS114_I2C_DELAY);
Annotation
- Immediate include surface: `linux/module.h`, `linux/delay.h`, `linux/of.h`, `linux/i2c.h`, `linux/input/mt.h`, `linux/input/touchscreen.h`, `linux/interrupt.h`, `linux/regulator/consumer.h`.
- Detected declarations: `struct mms114_data`, `struct mms114_touch`, `enum mms_type`, `function __mms114_read_reg`, `function mms114_read_reg`, `function mms114_write_reg`, `function mms114_process_mt`, `function mms114_process_touchkey`, `function mms114_interrupt`, `function mms114_set_active`.
- 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.