drivers/i2c/i2c-atr.c
Source file repositories/reference/linux-study-clean/drivers/i2c/i2c-atr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/i2c-atr.c- Extension
.c- Size
- 23630 bytes
- Lines
- 946
- 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.
- 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/i2c-atr.hlinux/i2c.hlinux/kernel.hlinux/module.hlinux/mutex.hlinux/property.hlinux/slab.hlinux/spinlock.hlinux/lockdep.h
Detected Declarations
struct i2c_atr_alias_pairstruct i2c_atr_alias_poolstruct i2c_atr_chanstruct i2c_atrfunction i2c_atr_free_alias_poolfunction i2c_atr_destroy_c2afunction i2c_atr_reserve_aliasfunction i2c_atr_release_aliasfunction i2c_atr_find_mapping_by_addrfunction list_for_each_entryfunction i2c_atr_create_mapping_by_addrfunction i2c_atr_replace_mapping_by_addrfunction list_for_each_entry_reversefunction i2c_atr_get_mapping_by_addrfunction i2c_atr_master_xferfunction i2c_atr_master_xferfunction i2c_atr_master_xferfunction i2c_atr_smbus_xferfunction i2c_atr_functionalityfunction i2c_atr_lock_busfunction i2c_atr_trylock_busfunction i2c_atr_unlock_busfunction i2c_atr_attach_addrfunction i2c_atr_detach_addrfunction i2c_atr_bus_notifier_callfunction i2c_atr_parse_alias_poolfunction i2c_atr_deletefunction i2c_atr_add_adapterfunction fwnode_for_each_child_nodefunction i2c_atr_del_adapterfunction i2c_atr_set_driver_data
Annotated Snippet
struct i2c_atr_alias_pair {
struct list_head node;
bool fixed;
u16 addr;
u16 alias;
};
/**
* struct i2c_atr_alias_pool - Pool of client aliases available for an ATR.
* @size: Total number of aliases
* @shared: Indicates if this alias pool is shared by multiple channels
*
* @lock: Lock protecting @aliases and @use_mask
* @use_mask: Mask of used aliases
* @aliases: Array of aliases, must hold exactly @size elements
*/
struct i2c_atr_alias_pool {
size_t size;
bool shared;
/* Protects aliases and use_mask */
spinlock_t lock;
unsigned long *use_mask;
u16 aliases[] __counted_by(size);
};
/**
* struct i2c_atr_chan - Data for a channel.
* @adap: The &struct i2c_adapter for the channel
* @atr: The parent I2C ATR
* @chan_id: The ID of this channel
* @alias_pairs_lock: Mutex protecting @alias_pairs
* @alias_pairs_lock_key: Lock key for @alias_pairs_lock
* @alias_pairs: List of @struct i2c_atr_alias_pair containing the
* assigned aliases
* @alias_pool: Pool of available client aliases
*
* @orig_addrs_lock: Mutex protecting @orig_addrs
* @orig_addrs_lock_key: Lock key for @orig_addrs_lock
* @orig_addrs: Buffer used to store the original addresses during transmit
* @orig_addrs_size: Size of @orig_addrs
*/
struct i2c_atr_chan {
struct i2c_adapter adap;
struct i2c_atr *atr;
u32 chan_id;
/* Lock alias_pairs during attach/detach */
struct mutex alias_pairs_lock;
struct lock_class_key alias_pairs_lock_key;
struct list_head alias_pairs;
struct i2c_atr_alias_pool *alias_pool;
/* Lock orig_addrs during xfer */
struct mutex orig_addrs_lock;
struct lock_class_key orig_addrs_lock_key;
u16 *orig_addrs;
unsigned int orig_addrs_size;
};
/**
* struct i2c_atr - The I2C ATR instance
* @parent: The parent &struct i2c_adapter
* @dev: The device that owns the I2C ATR instance
* @ops: &struct i2c_atr_ops
* @priv: Private driver data, set with i2c_atr_set_driver_data()
* @algo: The &struct i2c_algorithm for adapters
* @lock: Lock for the I2C bus segment (see &struct i2c_lock_operations)
* @lock_key: Lock key for @lock
* @max_adapters: Maximum number of adapters this I2C ATR can have
* @flags: Flags for ATR
* @alias_pool: Optional common pool of available client aliases
* @i2c_nb: Notifier for remote client add & del events
* @adapter: Array of adapters
*/
struct i2c_atr {
struct i2c_adapter *parent;
struct device *dev;
const struct i2c_atr_ops *ops;
void *priv;
struct i2c_algorithm algo;
/* lock for the I2C bus segment (see struct i2c_lock_operations) */
struct mutex lock;
struct lock_class_key lock_key;
int max_adapters;
u32 flags;
struct i2c_atr_alias_pool *alias_pool;
Annotation
- Immediate include surface: `linux/i2c-atr.h`, `linux/i2c.h`, `linux/kernel.h`, `linux/module.h`, `linux/mutex.h`, `linux/property.h`, `linux/slab.h`, `linux/spinlock.h`.
- Detected declarations: `struct i2c_atr_alias_pair`, `struct i2c_atr_alias_pool`, `struct i2c_atr_chan`, `struct i2c_atr`, `function i2c_atr_free_alias_pool`, `function i2c_atr_destroy_c2a`, `function i2c_atr_reserve_alias`, `function i2c_atr_release_alias`, `function i2c_atr_find_mapping_by_addr`, `function list_for_each_entry`.
- Atlas domain: Driver Families / drivers/i2c.
- Implementation status: integration implementation candidate.
- 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.