sound/i2c/i2c.c
Source file repositories/reference/linux-study-clean/sound/i2c/i2c.c
File Facts
- System
- Linux kernel
- Corpus path
sound/i2c/i2c.c- Extension
.c- Size
- 7647 bytes
- Lines
- 327
- Domain
- Driver Families
- Bucket
- sound/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/init.hlinux/slab.hlinux/module.hlinux/string.hlinux/errno.hsound/core.hsound/i2c.h
Detected Declarations
function snd_i2c_bus_freefunction snd_i2c_bus_dev_freefunction snd_i2c_bus_createfunction snd_i2c_device_createfunction snd_i2c_device_freefunction snd_i2c_sendbytesfunction snd_i2c_readbytesfunction snd_i2c_probeaddrfunction snd_i2c_bit_hw_startfunction snd_i2c_bit_hw_stopfunction snd_i2c_bit_directionfunction snd_i2c_bit_setfunction snd_i2c_bit_clockfunction snd_i2c_bit_datafunction snd_i2c_bit_startfunction snd_i2c_bit_stopfunction snd_i2c_bit_sendfunction snd_i2c_bit_ackfunction snd_i2c_bit_sendbytefunction snd_i2c_bit_readbytefunction snd_i2c_bit_sendbytesfunction snd_i2c_bit_readbytesfunction snd_i2c_bit_probeaddrexport snd_i2c_bus_createexport snd_i2c_device_createexport snd_i2c_device_freeexport snd_i2c_sendbytesexport snd_i2c_readbytesexport snd_i2c_probeaddr
Annotated Snippet
while (!list_empty(&bus->buses)) {
slave = snd_i2c_slave_bus(bus->buses.next);
snd_device_free(bus->card, slave);
}
}
if (bus->private_free)
bus->private_free(bus);
kfree(bus);
return 0;
}
static int snd_i2c_bus_dev_free(struct snd_device *device)
{
struct snd_i2c_bus *bus = device->device_data;
return snd_i2c_bus_free(bus);
}
int snd_i2c_bus_create(struct snd_card *card, const char *name,
struct snd_i2c_bus *master, struct snd_i2c_bus **ri2c)
{
struct snd_i2c_bus *bus;
int err;
static const struct snd_device_ops ops = {
.dev_free = snd_i2c_bus_dev_free,
};
*ri2c = NULL;
bus = kzalloc_obj(*bus);
if (bus == NULL)
return -ENOMEM;
mutex_init(&bus->lock_mutex);
INIT_LIST_HEAD(&bus->devices);
INIT_LIST_HEAD(&bus->buses);
bus->card = card;
bus->ops = &snd_i2c_bit_ops;
if (master) {
list_add_tail(&bus->buses, &master->buses);
bus->master = master;
}
strscpy(bus->name, name, sizeof(bus->name));
err = snd_device_new(card, SNDRV_DEV_BUS, bus, &ops);
if (err < 0) {
snd_i2c_bus_free(bus);
return err;
}
*ri2c = bus;
return 0;
}
EXPORT_SYMBOL(snd_i2c_bus_create);
int snd_i2c_device_create(struct snd_i2c_bus *bus, const char *name,
unsigned char addr, struct snd_i2c_device **rdevice)
{
struct snd_i2c_device *device;
*rdevice = NULL;
if (snd_BUG_ON(!bus))
return -EINVAL;
device = kzalloc_obj(*device);
if (device == NULL)
return -ENOMEM;
device->addr = addr;
strscpy(device->name, name, sizeof(device->name));
list_add_tail(&device->list, &bus->devices);
device->bus = bus;
*rdevice = device;
return 0;
}
EXPORT_SYMBOL(snd_i2c_device_create);
int snd_i2c_device_free(struct snd_i2c_device *device)
{
if (device->bus)
list_del(&device->list);
if (device->private_free)
device->private_free(device);
kfree(device);
return 0;
}
EXPORT_SYMBOL(snd_i2c_device_free);
int snd_i2c_sendbytes(struct snd_i2c_device *device, unsigned char *bytes, int count)
{
return device->bus->ops->sendbytes(device, bytes, count);
}
EXPORT_SYMBOL(snd_i2c_sendbytes);
Annotation
- Immediate include surface: `linux/init.h`, `linux/slab.h`, `linux/module.h`, `linux/string.h`, `linux/errno.h`, `sound/core.h`, `sound/i2c.h`.
- Detected declarations: `function snd_i2c_bus_free`, `function snd_i2c_bus_dev_free`, `function snd_i2c_bus_create`, `function snd_i2c_device_create`, `function snd_i2c_device_free`, `function snd_i2c_sendbytes`, `function snd_i2c_readbytes`, `function snd_i2c_probeaddr`, `function snd_i2c_bit_hw_start`, `function snd_i2c_bit_hw_stop`.
- Atlas domain: Driver Families / sound/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.