drivers/hid/i2c-hid/i2c-hid-of-elan.c
Source file repositories/reference/linux-study-clean/drivers/hid/i2c-hid/i2c-hid-of-elan.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/i2c-hid/i2c-hid-of-elan.c- Extension
.c- Size
- 6613 bytes
- Lines
- 232
- Domain
- Driver Families
- Bucket
- drivers/hid
- 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/delay.hlinux/device.hlinux/gpio/consumer.hlinux/hid.hlinux/i2c.hlinux/kernel.hlinux/module.hlinux/of.hlinux/pm.hlinux/regulator/consumer.hi2c-hid.h
Detected Declarations
struct elan_i2c_hid_chip_datastruct i2c_hid_of_elanfunction elan_i2c_hid_power_upfunction elan_i2c_hid_power_downfunction i2c_hid_of_elan_probe
Annotated Snippet
struct elan_i2c_hid_chip_data {
unsigned int post_gpio_reset_on_delay_ms;
unsigned int post_gpio_reset_off_delay_ms;
unsigned int post_power_delay_ms;
u16 hid_descriptor_address;
const char *main_supply_name;
bool power_after_backlight;
};
struct i2c_hid_of_elan {
struct i2chid_ops ops;
struct regulator *vcc33;
struct regulator *vccio;
struct gpio_desc *reset_gpio;
bool no_reset_on_power_off;
const struct elan_i2c_hid_chip_data *chip_data;
};
static int elan_i2c_hid_power_up(struct i2chid_ops *ops)
{
struct i2c_hid_of_elan *ihid_elan =
container_of(ops, struct i2c_hid_of_elan, ops);
int ret;
gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);
if (ihid_elan->vcc33) {
ret = regulator_enable(ihid_elan->vcc33);
if (ret)
goto err_deassert_reset;
}
ret = regulator_enable(ihid_elan->vccio);
if (ret)
goto err_disable_vcc33;
if (ihid_elan->chip_data->post_power_delay_ms)
msleep(ihid_elan->chip_data->post_power_delay_ms);
gpiod_set_value_cansleep(ihid_elan->reset_gpio, 0);
if (ihid_elan->chip_data->post_gpio_reset_on_delay_ms)
msleep(ihid_elan->chip_data->post_gpio_reset_on_delay_ms);
return 0;
err_disable_vcc33:
if (ihid_elan->vcc33)
regulator_disable(ihid_elan->vcc33);
err_deassert_reset:
if (ihid_elan->no_reset_on_power_off)
gpiod_set_value_cansleep(ihid_elan->reset_gpio, 0);
return ret;
}
static void elan_i2c_hid_power_down(struct i2chid_ops *ops)
{
struct i2c_hid_of_elan *ihid_elan =
container_of(ops, struct i2c_hid_of_elan, ops);
/*
* Do not assert reset when the hardware allows for it to remain
* deasserted regardless of the state of the (shared) power supply to
* avoid wasting power when the supply is left on.
*/
if (!ihid_elan->no_reset_on_power_off)
gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);
if (ihid_elan->chip_data->post_gpio_reset_off_delay_ms)
msleep(ihid_elan->chip_data->post_gpio_reset_off_delay_ms);
regulator_disable(ihid_elan->vccio);
if (ihid_elan->vcc33)
regulator_disable(ihid_elan->vcc33);
}
static int i2c_hid_of_elan_probe(struct i2c_client *client)
{
struct i2c_hid_of_elan *ihid_elan;
int ret;
u32 quirks = 0;
ihid_elan = devm_kzalloc(&client->dev, sizeof(*ihid_elan), GFP_KERNEL);
if (!ihid_elan)
return -ENOMEM;
ihid_elan->ops.power_up = elan_i2c_hid_power_up;
ihid_elan->ops.power_down = elan_i2c_hid_power_down;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/device.h`, `linux/gpio/consumer.h`, `linux/hid.h`, `linux/i2c.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct elan_i2c_hid_chip_data`, `struct i2c_hid_of_elan`, `function elan_i2c_hid_power_up`, `function elan_i2c_hid_power_down`, `function i2c_hid_of_elan_probe`.
- Atlas domain: Driver Families / drivers/hid.
- 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.