drivers/input/mouse/cyapa.c
Source file repositories/reference/linux-study-clean/drivers/input/mouse/cyapa.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/mouse/cyapa.c- Extension
.c- Size
- 37764 bytes
- Lines
- 1500
- 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.
- 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/delay.hlinux/i2c.hlinux/input.hlinux/input/mt.hlinux/interrupt.hlinux/module.hlinux/mutex.hlinux/regulator/consumer.hlinux/slab.hlinux/uaccess.hlinux/pm_runtime.hlinux/acpi.hlinux/of.hcyapa.h
Detected Declarations
function cyapa_is_pip_bl_modefunction cyapa_is_pip_app_modefunction cyapa_is_bootloader_modefunction cyapa_is_operational_modefunction cyapa_i2c_readfunction cyapa_i2c_writefunction cyapa_check_adapter_functionalityfunction cyapa_get_statefunction cyapa_poll_statefunction cyapa_check_is_operationalfunction cyapa_detectfunction cyapa_openfunction cyapa_closefunction cyapa_create_input_devfunction cyapa_enable_irq_for_cmdfunction cyapa_disable_irq_for_cmdfunction cyapa_sleep_time_to_pwr_cmdfunction cyapa_pwr_cmd_to_sleep_timefunction cyapa_initializefunction cyapa_reinitializefunction cyapa_irqfunction cyapa_show_suspend_scanratefunction cyapa_update_suspend_scanratefunction cyapa_remove_power_wakeup_groupfunction cyapa_prepare_wakeup_controlsfunction cyapa_prepare_wakeup_controlsfunction cyapa_show_rt_suspend_scanratefunction cyapa_update_rt_suspend_scanratefunction cyapa_remove_power_runtime_groupfunction cyapa_start_runtimefunction cyapa_start_runtimefunction cyapa_show_fm_verfunction cyapa_show_product_idfunction cyapa_firmwarefunction cyapa_update_fw_storefunction cyapa_calibrate_storefunction cyapa_show_baselinefunction cyapa_show_modefunction cyapa_disable_regulatorfunction cyapa_probefunction cyapa_suspendfunction cyapa_resumefunction cyapa_runtime_suspendfunction cyapa_runtime_resume
Annotated Snippet
if (!smbus) {
cmd[0] = 0x00;
cmd[1] = 0x00;
error = cyapa_i2c_write(cyapa, 0, 2, cmd);
if (error)
goto error;
msleep(50);
error = cyapa_i2c_read(cyapa, BL_HEAD_OFFSET,
BL_STATUS_SIZE, status);
if (error)
goto error;
}
} while (--retries > 0 && !smbus);
goto error;
out_detected:
if (cyapa->state <= CYAPA_STATE_BL_BUSY)
return -EAGAIN;
return 0;
error:
return (error < 0) ? error : -EAGAIN;
}
/*
* Poll device for its status in a loop, waiting up to timeout for a response.
*
* When the device switches state, it usually takes ~300 ms.
* However, when running a new firmware image, the device must calibrate its
* sensors, which can take as long as 2 seconds.
*
* Note: The timeout has granularity of the polling rate, which is 100 ms.
*
* Returns:
* 0 when the device eventually responds with a valid non-busy state.
* -ETIMEDOUT if device never responds (too many -EAGAIN)
* -EAGAIN if bootload is busy, or unknown state.
* < 0 other errors
*/
int cyapa_poll_state(struct cyapa *cyapa, unsigned int timeout)
{
int error;
int tries = timeout / 100;
do {
error = cyapa_get_state(cyapa);
if (!error && cyapa->state > CYAPA_STATE_BL_BUSY)
return 0;
msleep(100);
} while (tries--);
return (error == -EAGAIN || error == -ETIMEDOUT) ? -ETIMEDOUT : error;
}
/*
* Check if device is operational.
*
* An operational device is responding, has exited bootloader, and has
* firmware supported by this driver.
*
* Returns:
* -ENODEV no device
* -EBUSY no device or in bootloader
* -EIO failure while reading from device
* -ETIMEDOUT timeout failure for bus idle or bus no response
* -EAGAIN device is still in bootloader
* if ->state = CYAPA_STATE_BL_IDLE, device has invalid firmware
* -EINVAL device is in operational mode, but not supported by this driver
* 0 device is supported
*/
static int cyapa_check_is_operational(struct cyapa *cyapa)
{
int error;
error = cyapa_poll_state(cyapa, 4000);
if (error)
return error;
switch (cyapa->gen) {
case CYAPA_GEN6:
cyapa->ops = &cyapa_gen6_ops;
break;
case CYAPA_GEN5:
cyapa->ops = &cyapa_gen5_ops;
break;
case CYAPA_GEN3:
Annotation
- Immediate include surface: `linux/delay.h`, `linux/i2c.h`, `linux/input.h`, `linux/input/mt.h`, `linux/interrupt.h`, `linux/module.h`, `linux/mutex.h`, `linux/regulator/consumer.h`.
- Detected declarations: `function cyapa_is_pip_bl_mode`, `function cyapa_is_pip_app_mode`, `function cyapa_is_bootloader_mode`, `function cyapa_is_operational_mode`, `function cyapa_i2c_read`, `function cyapa_i2c_write`, `function cyapa_check_adapter_functionality`, `function cyapa_get_state`, `function cyapa_poll_state`, `function cyapa_check_is_operational`.
- 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.
- 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.