drivers/input/joystick/iforce/iforce-main.c
Source file repositories/reference/linux-study-clean/drivers/input/joystick/iforce/iforce-main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/joystick/iforce/iforce-main.c- Extension
.c- Size
- 11253 bytes
- Lines
- 401
- Domain
- Driver Families
- Bucket
- drivers/input
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/unaligned.hiforce.h
Detected Declarations
function iforce_playbackfunction iforce_set_gainfunction iforce_set_autocenterfunction iforce_upload_effectfunction iforce_erase_effectfunction iforce_openfunction iforce_closefunction iforce_init_deviceexport iforce_init_device
Annotated Snippet
if (test_bit(FF_CORE_IS_USED, iforce->core_effects[i].flags)) {
dev_warn(&dev->dev,
"%s: Device still owns effects\n",
__func__);
break;
}
}
/* Disable force feedback playback */
iforce_send_packet(iforce, FF_CMD_ENABLE, "\001");
/* Wait for the command to complete */
wait_event_interruptible(iforce->wait,
!test_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags));
}
iforce->xport_ops->stop_io(iforce);
}
int iforce_init_device(struct device *parent, u16 bustype,
struct iforce *iforce)
{
struct input_dev *input_dev;
struct ff_device *ff;
u8 c[] = "CEOV";
u8 buf[IFORCE_MAX_LENGTH];
size_t len;
int i, error;
int ff_effects = 0;
input_dev = input_allocate_device();
if (!input_dev)
return -ENOMEM;
init_waitqueue_head(&iforce->wait);
spin_lock_init(&iforce->xmit_lock);
mutex_init(&iforce->mem_mutex);
iforce->xmit.buf = iforce->xmit_data;
iforce->dev = input_dev;
/*
* Input device fields.
*/
input_dev->id.bustype = bustype;
input_dev->dev.parent = parent;
input_set_drvdata(input_dev, iforce);
input_dev->name = "Unknown I-Force device";
input_dev->open = iforce_open;
input_dev->close = iforce_close;
/*
* On-device memory allocation.
*/
iforce->device_memory.name = "I-Force device effect memory";
iforce->device_memory.start = 0;
iforce->device_memory.end = 200;
iforce->device_memory.flags = IORESOURCE_MEM;
iforce->device_memory.parent = NULL;
iforce->device_memory.child = NULL;
iforce->device_memory.sibling = NULL;
/*
* Wait until device ready - until it sends its first response.
*/
for (i = 0; i < 20; i++)
if (!iforce_get_id_packet(iforce, 'O', buf, &len))
break;
if (i == 20) { /* 5 seconds */
dev_err(&input_dev->dev,
"Timeout waiting for response from device.\n");
error = -ENODEV;
goto fail;
}
/*
* Get device info.
*/
if (!iforce_get_id_packet(iforce, 'M', buf, &len) && len >= 3)
input_dev->id.vendor = get_unaligned_le16(buf + 1);
else
dev_warn(&iforce->dev->dev, "Device does not respond to id packet M\n");
if (!iforce_get_id_packet(iforce, 'P', buf, &len) && len >= 3)
input_dev->id.product = get_unaligned_le16(buf + 1);
Annotation
- Immediate include surface: `linux/export.h`, `linux/unaligned.h`, `iforce.h`.
- Detected declarations: `function iforce_playback`, `function iforce_set_gain`, `function iforce_set_autocenter`, `function iforce_upload_effect`, `function iforce_erase_effect`, `function iforce_open`, `function iforce_close`, `function iforce_init_device`, `export iforce_init_device`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: integration 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.