sound/ac97/bus.c
Source file repositories/reference/linux-study-clean/sound/ac97/bus.c
File Facts
- System
- Linux kernel
- Corpus path
sound/ac97/bus.c- Extension
.c- Size
- 12576 bytes
- Lines
- 527
- Domain
- Driver Families
- Bucket
- sound/ac97
- 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.
- 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/module.hlinux/bitops.hlinux/clk.hlinux/device.hlinux/idr.hlinux/list.hlinux/mutex.hlinux/of.hlinux/pm.hlinux/pm_runtime.hlinux/slab.hlinux/sysfs.hsound/ac97_codec.hsound/ac97/codec.hsound/ac97/controller.hsound/ac97/regs.hac97_core.h
Detected Declarations
function to_ac97_controllerfunction ac97_unbound_ctrl_writefunction ac97_unbound_ctrl_readfunction ac97_codec_findfunction ac97_of_get_child_devicefunction for_each_child_of_nodefunction ac97_codec_releasefunction ac97_codec_addfunction snd_ac97_bus_scan_onefunction ac97_bus_scanfunction ac97_bus_resetfunction snd_ac97_codec_driver_registerfunction snd_ac97_codec_driver_unregisterfunction ac97_ctrl_codecs_unregisterfunction cold_reset_storefunction warm_reset_storefunction ac97_del_adapterfunction ac97_adapter_releasefunction ac97_add_adapterfunction snd_ac97_controller_unregisterfunction ac97_pm_runtime_suspendfunction ac97_pm_runtime_resumefunction ac97_get_enable_clkfunction ac97_put_disable_clkfunction vendor_id_showfunction ac97_bus_matchfunction ac97_bus_probefunction ac97_bus_removefunction ac97_bus_initfunction ac97_bus_exitmodule init ac97_bus_initexport snd_ac97_codec_driver_registerexport snd_ac97_codec_driver_unregisterexport snd_ac97_controller_registerexport snd_ac97_controller_unregister
Annotated Snippet
static int ac97_bus_match(struct device *dev, const struct device_driver *drv)
{
struct ac97_codec_device *adev = to_ac97_device(dev);
const struct ac97_codec_driver *adrv = to_ac97_driver(drv);
const struct ac97_id *id = adrv->id_table;
int i = 0;
if (adev->vendor_id == 0x0 || adev->vendor_id == 0xffffffff)
return false;
do {
if (ac97_ids_match(id[i].id, adev->vendor_id, id[i].mask))
return true;
} while (id[i++].id);
return false;
}
static int ac97_bus_probe(struct device *dev)
{
struct ac97_codec_device *adev = to_ac97_device(dev);
struct ac97_codec_driver *adrv = to_ac97_driver(dev->driver);
int ret;
ret = ac97_get_enable_clk(adev);
if (ret)
return ret;
pm_runtime_get_noresume(dev);
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
ret = adrv->probe(adev);
if (ret == 0)
return 0;
pm_runtime_disable(dev);
pm_runtime_set_suspended(dev);
pm_runtime_put_noidle(dev);
ac97_put_disable_clk(adev);
return ret;
}
static void ac97_bus_remove(struct device *dev)
{
struct ac97_codec_device *adev = to_ac97_device(dev);
struct ac97_codec_driver *adrv = to_ac97_driver(dev->driver);
int ret;
ret = pm_runtime_resume_and_get(dev);
if (ret < 0)
return;
adrv->remove(adev);
pm_runtime_put_noidle(dev);
ac97_put_disable_clk(adev);
pm_runtime_disable(dev);
}
const struct bus_type ac97_bus_type = {
.name = "ac97bus",
.dev_groups = ac97_dev_groups,
.match = ac97_bus_match,
.pm = pm_ptr(&ac97_pm),
.probe = ac97_bus_probe,
.remove = ac97_bus_remove,
};
static int __init ac97_bus_init(void)
{
return bus_register(&ac97_bus_type);
}
subsys_initcall(ac97_bus_init);
static void __exit ac97_bus_exit(void)
{
bus_unregister(&ac97_bus_type);
}
module_exit(ac97_bus_exit);
MODULE_DESCRIPTION("AC97 bus interface");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Robert Jarzmik <robert.jarzmik@free.fr>");
Annotation
- Immediate include surface: `linux/module.h`, `linux/bitops.h`, `linux/clk.h`, `linux/device.h`, `linux/idr.h`, `linux/list.h`, `linux/mutex.h`, `linux/of.h`.
- Detected declarations: `function to_ac97_controller`, `function ac97_unbound_ctrl_write`, `function ac97_unbound_ctrl_read`, `function ac97_codec_find`, `function ac97_of_get_child_device`, `function for_each_child_of_node`, `function ac97_codec_release`, `function ac97_codec_add`, `function snd_ac97_bus_scan_one`, `function ac97_bus_scan`.
- Atlas domain: Driver Families / sound/ac97.
- Implementation status: pattern 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.