drivers/mfd/aat2870-core.c
Source file repositories/reference/linux-study-clean/drivers/mfd/aat2870-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mfd/aat2870-core.c- Extension
.c- Size
- 10601 bytes
- Lines
- 459
- Domain
- Driver Families
- Bucket
- drivers/mfd
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/kernel.hlinux/init.hlinux/debugfs.hlinux/slab.hlinux/uaccess.hlinux/i2c.hlinux/delay.hlinux/gpio.hlinux/mfd/core.hlinux/mfd/aat2870.hlinux/regulator/machine.h
Detected Declarations
function __aat2870_readfunction __aat2870_writefunction aat2870_readfunction aat2870_writefunction aat2870_updatefunction aat2870_enablefunction aat2870_disablefunction aat2870_dump_regfunction aat2870_reg_read_filefunction aat2870_reg_write_filefunction aat2870_init_debugfsfunction aat2870_init_debugfsfunction aat2870_i2c_suspendfunction aat2870_i2c_resumefunction aat2870_initmodule init aat2870_init
Annotated Snippet
static const struct file_operations aat2870_reg_fops = {
.open = simple_open,
.read = aat2870_reg_read_file,
.write = aat2870_reg_write_file,
};
static void aat2870_init_debugfs(struct aat2870_data *aat2870)
{
debugfs_create_file("regs", 0644, aat2870->client->debugfs, aat2870,
&aat2870_reg_fops);
}
#else
static inline void aat2870_init_debugfs(struct aat2870_data *aat2870)
{
}
#endif /* CONFIG_DEBUG_FS */
static int aat2870_i2c_probe(struct i2c_client *client)
{
struct aat2870_platform_data *pdata = dev_get_platdata(&client->dev);
struct aat2870_data *aat2870;
int i, j;
int ret = 0;
aat2870 = devm_kzalloc(&client->dev, sizeof(struct aat2870_data),
GFP_KERNEL);
if (!aat2870)
return -ENOMEM;
aat2870->dev = &client->dev;
aat2870->client = client;
i2c_set_clientdata(client, aat2870);
aat2870->reg_cache = aat2870_regs;
if (pdata->en_pin < 0)
aat2870->en_pin = -1;
else
aat2870->en_pin = pdata->en_pin;
aat2870->init = pdata->init;
aat2870->uninit = pdata->uninit;
aat2870->read = aat2870_read;
aat2870->write = aat2870_write;
aat2870->update = aat2870_update;
mutex_init(&aat2870->io_lock);
if (aat2870->init)
aat2870->init(aat2870);
if (aat2870->en_pin >= 0) {
ret = devm_gpio_request_one(&client->dev, aat2870->en_pin,
GPIOF_OUT_INIT_HIGH, "aat2870-en");
if (ret < 0) {
dev_err(&client->dev,
"Failed to request GPIO %d\n", aat2870->en_pin);
return ret;
}
}
aat2870_enable(aat2870);
for (i = 0; i < pdata->num_subdevs; i++) {
for (j = 0; j < ARRAY_SIZE(aat2870_devs); j++) {
if ((pdata->subdevs[i].id == aat2870_devs[j].id) &&
!strcmp(pdata->subdevs[i].name,
aat2870_devs[j].name)) {
aat2870_devs[j].platform_data =
pdata->subdevs[i].platform_data;
break;
}
}
}
ret = mfd_add_devices(aat2870->dev, 0, aat2870_devs,
ARRAY_SIZE(aat2870_devs), NULL, 0, NULL);
if (ret != 0) {
dev_err(aat2870->dev, "Failed to add subdev: %d\n", ret);
goto out_disable;
}
aat2870_init_debugfs(aat2870);
return 0;
out_disable:
aat2870_disable(aat2870);
return ret;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/debugfs.h`, `linux/slab.h`, `linux/uaccess.h`, `linux/i2c.h`, `linux/delay.h`, `linux/gpio.h`.
- Detected declarations: `function __aat2870_read`, `function __aat2870_write`, `function aat2870_read`, `function aat2870_write`, `function aat2870_update`, `function aat2870_enable`, `function aat2870_disable`, `function aat2870_dump_reg`, `function aat2870_reg_read_file`, `function aat2870_reg_write_file`.
- Atlas domain: Driver Families / drivers/mfd.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.