drivers/staging/nvec/nvec_ps2.c
Source file repositories/reference/linux-study-clean/drivers/staging/nvec/nvec_ps2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/nvec/nvec_ps2.c- Extension
.c- Size
- 3979 bytes
- Lines
- 179
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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/module.hlinux/slab.hlinux/serio.hlinux/delay.hlinux/platform_device.hnvec.h
Detected Declarations
struct nvec_ps2enum ps2_subcmdsfunction ps2_startstreamingfunction ps2_stopstreamingfunction nvec_ps2_notifierfunction ps2_sendcommandfunction nvec_mouse_probefunction nvec_mouse_removefunction nvec_mouse_suspendfunction nvec_mouse_resume
Annotated Snippet
struct nvec_ps2 {
struct serio *ser_dev;
struct notifier_block notifier;
struct nvec_chip *nvec;
};
static struct nvec_ps2 ps2_dev;
static int ps2_startstreaming(struct serio *ser_dev)
{
unsigned char buf[] = { NVEC_PS2, AUTO_RECEIVE_N, PACKET_SIZE };
return nvec_write_async(ps2_dev.nvec, buf, sizeof(buf));
}
static void ps2_stopstreaming(struct serio *ser_dev)
{
unsigned char buf[] = { NVEC_PS2, CANCEL_AUTO_RECEIVE };
nvec_write_async(ps2_dev.nvec, buf, sizeof(buf));
}
static int nvec_ps2_notifier(struct notifier_block *nb,
unsigned long event_type, void *data)
{
int i;
unsigned char *msg = data;
switch (event_type) {
case NVEC_PS2_EVT:
for (i = 0; i < msg[1]; i++)
serio_interrupt(ps2_dev.ser_dev, msg[2 + i], 0);
return NOTIFY_STOP;
case NVEC_PS2:
if (msg[2] == 1) {
for (i = 0; i < (msg[1] - 2); i++)
serio_interrupt(ps2_dev.ser_dev, msg[i + 4], 0);
}
return NOTIFY_STOP;
}
return NOTIFY_DONE;
}
static int ps2_sendcommand(struct serio *ser_dev, unsigned char cmd)
{
unsigned char buf[] = { NVEC_PS2, SEND_COMMAND, ENABLE_MOUSE, 1 };
struct nvec_msg *msg;
int ret;
buf[2] = cmd & 0xff;
dev_dbg(&ser_dev->dev, "Sending ps2 cmd %02x\n", cmd);
ret = nvec_write_sync(ps2_dev.nvec, buf, sizeof(buf), &msg);
if (ret < 0)
return ret;
nvec_ps2_notifier(NULL, NVEC_PS2, msg->data);
nvec_msg_free(ps2_dev.nvec, msg);
return 0;
}
static int nvec_mouse_probe(struct platform_device *pdev)
{
struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent);
struct serio *ser_dev;
ser_dev = kzalloc_obj(*ser_dev);
if (!ser_dev)
return -ENOMEM;
ser_dev->id.type = SERIO_8042;
ser_dev->write = ps2_sendcommand;
ser_dev->start = ps2_startstreaming;
ser_dev->stop = ps2_stopstreaming;
strscpy(ser_dev->name, "nvec mouse", sizeof(ser_dev->name));
strscpy(ser_dev->phys, "nvec", sizeof(ser_dev->phys));
ps2_dev.ser_dev = ser_dev;
ps2_dev.notifier.notifier_call = nvec_ps2_notifier;
ps2_dev.nvec = nvec;
nvec_register_notifier(nvec, &ps2_dev.notifier, 0);
serio_register_port(ser_dev);
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/serio.h`, `linux/delay.h`, `linux/platform_device.h`, `nvec.h`.
- Detected declarations: `struct nvec_ps2`, `enum ps2_subcmds`, `function ps2_startstreaming`, `function ps2_stopstreaming`, `function nvec_ps2_notifier`, `function ps2_sendcommand`, `function nvec_mouse_probe`, `function nvec_mouse_remove`, `function nvec_mouse_suspend`, `function nvec_mouse_resume`.
- Atlas domain: Driver Families / drivers/staging.
- 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.