drivers/i2c/i2c-core-acpi.c
Source file repositories/reference/linux-study-clean/drivers/i2c/i2c-core-acpi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/i2c-core-acpi.c- Extension
.c- Size
- 21357 bytes
- Lines
- 851
- Domain
- Driver Families
- Bucket
- drivers/i2c
- 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/acpi.hlinux/device.hlinux/err.hlinux/i2c.hlinux/list.hlinux/module.hlinux/slab.hi2c-core.h
Detected Declarations
struct i2c_acpi_handler_datastruct gsb_bufferstruct i2c_acpi_lookupstruct i2c_acpi_irq_contextfunction i2c_acpi_get_i2c_resourcefunction i2c_acpi_resource_countfunction i2c_acpi_client_countfunction i2c_acpi_fill_infofunction i2c_acpi_do_lookupfunction i2c_acpi_add_irq_resourcefunction i2c_acpi_get_irqfunction i2c_acpi_get_infofunction i2c_acpi_register_devicefunction i2c_acpi_add_devicefunction i2c_acpi_register_devicesfunction i2c_acpi_lookup_speedfunction i2c_acpi_find_bus_speedfunction i2c_acpi_notifyfunction i2c_acpi_waive_d0_probefunction acpi_gsb_i2c_read_bytesfunction acpi_gsb_i2c_write_bytesfunction i2c_acpi_space_handlerfunction i2c_acpi_install_space_handlerfunction i2c_acpi_remove_space_handlerexport i2c_acpi_get_i2c_resourceexport i2c_acpi_client_countexport i2c_acpi_find_bus_speedexport i2c_acpi_find_adapter_by_handleexport i2c_acpi_new_device_by_fwnodeexport i2c_acpi_waive_d0_probe
Annotated Snippet
struct i2c_acpi_handler_data {
struct acpi_connection_info info;
struct i2c_adapter *adapter;
};
struct gsb_buffer {
u8 status;
u8 len;
union {
u16 wdata;
u8 bdata;
DECLARE_FLEX_ARRAY(u8, data);
};
} __packed;
struct i2c_acpi_lookup {
struct i2c_board_info *info;
acpi_handle adapter_handle;
acpi_handle device_handle;
acpi_handle search_handle;
int n;
int index;
u32 speed;
u32 min_speed;
u32 force_speed;
};
/**
* i2c_acpi_get_i2c_resource - Gets I2cSerialBus resource if type matches
* @ares: ACPI resource
* @i2c: Pointer to I2cSerialBus resource will be returned here
*
* Checks if the given ACPI resource is of type I2cSerialBus.
* In this case, returns a pointer to it to the caller.
*
* Returns true if resource type is of I2cSerialBus, otherwise false.
*/
bool i2c_acpi_get_i2c_resource(struct acpi_resource *ares,
struct acpi_resource_i2c_serialbus **i2c)
{
struct acpi_resource_i2c_serialbus *sb;
if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS)
return false;
sb = &ares->data.i2c_serial_bus;
if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C)
return false;
*i2c = sb;
return true;
}
EXPORT_SYMBOL_GPL(i2c_acpi_get_i2c_resource);
static int i2c_acpi_resource_count(struct acpi_resource *ares, void *data)
{
struct acpi_resource_i2c_serialbus *sb;
int *count = data;
if (i2c_acpi_get_i2c_resource(ares, &sb))
*count = *count + 1;
return 1;
}
/**
* i2c_acpi_client_count - Count the number of I2cSerialBus resources
* @adev: ACPI device
*
* Return:
* The number of I2cSerialBus resources in the ACPI-device's
* resource-list; or a negative error code.
*
* Specifically returns -ENOENT when no resources found.
*/
int i2c_acpi_client_count(struct acpi_device *adev)
{
int ret, count = 0;
LIST_HEAD(r);
ret = acpi_dev_get_resources(adev, &r, i2c_acpi_resource_count, &count);
if (ret < 0)
return ret;
acpi_dev_free_resource_list(&r);
return count ?: -ENOENT;
}
EXPORT_SYMBOL_GPL(i2c_acpi_client_count);
static int i2c_acpi_fill_info(struct acpi_resource *ares, void *data)
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/device.h`, `linux/err.h`, `linux/i2c.h`, `linux/list.h`, `linux/module.h`, `linux/slab.h`, `i2c-core.h`.
- Detected declarations: `struct i2c_acpi_handler_data`, `struct gsb_buffer`, `struct i2c_acpi_lookup`, `struct i2c_acpi_irq_context`, `function i2c_acpi_get_i2c_resource`, `function i2c_acpi_resource_count`, `function i2c_acpi_client_count`, `function i2c_acpi_fill_info`, `function i2c_acpi_do_lookup`, `function i2c_acpi_add_irq_resource`.
- Atlas domain: Driver Families / drivers/i2c.
- 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.