drivers/input/ff-core.c
Source file repositories/reference/linux-study-clean/drivers/input/ff-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/ff-core.c- Extension
.c- Size
- 8551 bytes
- Lines
- 358
- 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.
- 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/export.hlinux/input.hlinux/limits.hlinux/mutex.hlinux/overflow.hlinux/sched.hlinux/slab.h
Detected Declarations
function Copyrightfunction check_effects_compatiblefunction compat_effectfunction input_ff_uploadfunction scoped_guardfunction erase_effectfunction scoped_guardfunction input_ff_erasefunction input_ff_flushfunction input_ff_eventfunction input_ff_createfunction input_ff_destroyexport input_ff_uploadexport input_ff_eraseexport input_ff_flushexport input_ff_eventexport input_ff_createexport input_ff_destroy
Annotated Snippet
if (error) {
scoped_guard(spinlock_irq, &dev->event_lock)
ff->effect_owners[effect_id] = file;
return error;
}
}
return 0;
}
/**
* input_ff_erase - erase a force-feedback effect from device
* @dev: input device to erase effect from
* @effect_id: id of the effect to be erased
* @file: purported owner of the request
*
* This function erases a force-feedback effect from specified device.
* The effect will only be erased if it was uploaded through the same
* file handle that is requesting erase.
*/
int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file)
{
struct ff_device *ff = dev->ff;
if (!test_bit(EV_FF, dev->evbit))
return -ENOSYS;
guard(mutex)(&ff->mutex);
return erase_effect(dev, effect_id, file);
}
EXPORT_SYMBOL_GPL(input_ff_erase);
/*
* input_ff_flush - erase all effects owned by a file handle
* @dev: input device to erase effect from
* @file: purported owner of the effects
*
* This function erases all force-feedback effects associated with
* the given owner from specified device. Note that @file may be %NULL,
* in which case all effects will be erased.
*/
int input_ff_flush(struct input_dev *dev, struct file *file)
{
struct ff_device *ff = dev->ff;
int i;
dev_dbg(&dev->dev, "flushing now\n");
guard(mutex)(&ff->mutex);
for (i = 0; i < ff->max_effects; i++)
erase_effect(dev, i, file);
return 0;
}
EXPORT_SYMBOL_GPL(input_ff_flush);
/**
* input_ff_event() - generic handler for force-feedback events
* @dev: input device to send the effect to
* @type: event type (anything but EV_FF is ignored)
* @code: event code
* @value: event value
*/
int input_ff_event(struct input_dev *dev, unsigned int type,
unsigned int code, int value)
{
struct ff_device *ff = dev->ff;
if (type != EV_FF)
return 0;
switch (code) {
case FF_GAIN:
if (!test_bit(FF_GAIN, dev->ffbit) || value > 0xffffU)
break;
ff->set_gain(dev, value);
break;
case FF_AUTOCENTER:
if (!test_bit(FF_AUTOCENTER, dev->ffbit) || value > 0xffffU)
break;
ff->set_autocenter(dev, value);
break;
default:
if (check_effect_access(ff, code, NULL) == 0)
Annotation
- Immediate include surface: `linux/export.h`, `linux/input.h`, `linux/limits.h`, `linux/mutex.h`, `linux/overflow.h`, `linux/sched.h`, `linux/slab.h`.
- Detected declarations: `function Copyright`, `function check_effects_compatible`, `function compat_effect`, `function input_ff_upload`, `function scoped_guard`, `function erase_effect`, `function scoped_guard`, `function input_ff_erase`, `function input_ff_flush`, `function input_ff_event`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: integration 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.