drivers/input/joystick/pxrc.c
Source file repositories/reference/linux-study-clean/drivers/input/joystick/pxrc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/joystick/pxrc.c- Extension
.c- Size
- 6518 bytes
- Lines
- 276
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/cleanup.hlinux/errno.hlinux/input.hlinux/kernel.hlinux/module.hlinux/mutex.hlinux/slab.hlinux/uaccess.hlinux/usb.hlinux/usb/input.h
Detected Declarations
struct pxrcfunction pxrc_usb_irqfunction pxrc_openfunction pxrc_closefunction pxrc_free_urbfunction pxrc_probefunction pxrc_disconnectfunction pxrc_resumefunction pxrc_pre_resetfunction pxrc_post_resetfunction pxrc_reset_resume
Annotated Snippet
struct pxrc {
struct input_dev *input;
struct usb_interface *intf;
struct urb *urb;
struct mutex pm_mutex;
bool is_open;
char phys[64];
};
static void pxrc_usb_irq(struct urb *urb)
{
struct pxrc *pxrc = urb->context;
u8 *data = urb->transfer_buffer;
int error;
switch (urb->status) {
case 0:
/* success */
break;
case -ETIME:
/* this urb is timing out */
dev_dbg(&pxrc->intf->dev,
"%s - urb timed out - was the device unplugged?\n",
__func__);
return;
case -ECONNRESET:
case -ENOENT:
case -ESHUTDOWN:
case -EPIPE:
/* this urb is terminated, clean up */
dev_dbg(&pxrc->intf->dev, "%s - urb shutting down with status: %d\n",
__func__, urb->status);
return;
default:
dev_dbg(&pxrc->intf->dev, "%s - nonzero urb status received: %d\n",
__func__, urb->status);
goto exit;
}
if (urb->actual_length == 8) {
input_report_abs(pxrc->input, ABS_X, data[0]);
input_report_abs(pxrc->input, ABS_Y, data[2]);
input_report_abs(pxrc->input, ABS_RX, data[3]);
input_report_abs(pxrc->input, ABS_RY, data[4]);
input_report_abs(pxrc->input, ABS_RUDDER, data[5]);
input_report_abs(pxrc->input, ABS_THROTTLE, data[6]);
input_report_abs(pxrc->input, ABS_MISC, data[7]);
input_report_key(pxrc->input, BTN_A, data[1]);
}
exit:
/* Resubmit to fetch new fresh URBs */
error = usb_submit_urb(urb, GFP_ATOMIC);
if (error && error != -EPERM)
dev_err(&pxrc->intf->dev,
"%s - usb_submit_urb failed with result: %d",
__func__, error);
}
static int pxrc_open(struct input_dev *input)
{
struct pxrc *pxrc = input_get_drvdata(input);
int error;
guard(mutex)(&pxrc->pm_mutex);
error = usb_submit_urb(pxrc->urb, GFP_KERNEL);
if (error) {
dev_err(&pxrc->intf->dev,
"%s - usb_submit_urb failed, error: %d\n",
__func__, error);
return -EIO;
}
pxrc->is_open = true;
return 0;
}
static void pxrc_close(struct input_dev *input)
{
struct pxrc *pxrc = input_get_drvdata(input);
guard(mutex)(&pxrc->pm_mutex);
usb_kill_urb(pxrc->urb);
pxrc->is_open = false;
}
static void pxrc_free_urb(void *_pxrc)
{
struct pxrc *pxrc = _pxrc;
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/errno.h`, `linux/input.h`, `linux/kernel.h`, `linux/module.h`, `linux/mutex.h`, `linux/slab.h`, `linux/uaccess.h`.
- Detected declarations: `struct pxrc`, `function pxrc_usb_irq`, `function pxrc_open`, `function pxrc_close`, `function pxrc_free_urb`, `function pxrc_probe`, `function pxrc_disconnect`, `function pxrc_resume`, `function pxrc_pre_reset`, `function pxrc_post_reset`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.