drivers/clk/clk-bulk.c
Source file repositories/reference/linux-study-clean/drivers/clk/clk-bulk.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/clk-bulk.c- Extension
.c- Size
- 5126 bytes
- Lines
- 249
- Domain
- Driver Families
- Bucket
- drivers/clk
- 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/clk.hlinux/clk-provider.hlinux/device.hlinux/export.hlinux/of.hlinux/slab.h
Detected Declarations
function of_clk_bulk_getfunction of_clk_bulk_get_allfunction clk_bulk_putfunction __clk_bulk_getfunction clk_bulk_getfunction clk_bulk_get_optionalfunction clk_bulk_put_allfunction clk_bulk_get_allfunction clk_bulk_unpreparefunction clk_bulk_preparefunction clk_bulk_disablefunction clk_bulk_enableexport clk_bulk_putexport clk_bulk_getexport clk_bulk_get_optionalexport clk_bulk_put_allexport clk_bulk_get_allexport clk_bulk_unprepareexport clk_bulk_prepareexport clk_bulk_disableexport clk_bulk_enable
Annotated Snippet
if (IS_ERR(clks[i].clk)) {
ret = PTR_ERR(clks[i].clk);
pr_err("%pOF: Failed to get clk index: %d ret: %d\n",
np, i, ret);
clks[i].clk = NULL;
goto err;
}
}
return 0;
err:
clk_bulk_put(i, clks);
return ret;
}
static int __must_check of_clk_bulk_get_all(struct device_node *np,
struct clk_bulk_data **clks)
{
struct clk_bulk_data *clk_bulk;
int num_clks;
int ret;
num_clks = of_clk_get_parent_count(np);
if (!num_clks)
return 0;
clk_bulk = kmalloc_objs(*clk_bulk, num_clks);
if (!clk_bulk)
return -ENOMEM;
ret = of_clk_bulk_get(np, num_clks, clk_bulk);
if (ret) {
kfree(clk_bulk);
return ret;
}
*clks = clk_bulk;
return num_clks;
}
void clk_bulk_put(int num_clks, struct clk_bulk_data *clks)
{
while (--num_clks >= 0) {
clk_put(clks[num_clks].clk);
clks[num_clks].clk = NULL;
}
}
EXPORT_SYMBOL_GPL(clk_bulk_put);
static int __clk_bulk_get(struct device *dev, int num_clks,
struct clk_bulk_data *clks, bool optional)
{
int ret;
int i;
for (i = 0; i < num_clks; i++)
clks[i].clk = NULL;
for (i = 0; i < num_clks; i++) {
clks[i].clk = clk_get(dev, clks[i].id);
if (IS_ERR(clks[i].clk)) {
ret = PTR_ERR(clks[i].clk);
clks[i].clk = NULL;
if (ret == -ENOENT && optional)
continue;
dev_err_probe(dev, ret,
"Failed to get clk '%s'\n",
clks[i].id);
goto err;
}
}
return 0;
err:
clk_bulk_put(i, clks);
return ret;
}
int __must_check clk_bulk_get(struct device *dev, int num_clks,
struct clk_bulk_data *clks)
{
return __clk_bulk_get(dev, num_clks, clks, false);
}
Annotation
- Immediate include surface: `linux/clk.h`, `linux/clk-provider.h`, `linux/device.h`, `linux/export.h`, `linux/of.h`, `linux/slab.h`.
- Detected declarations: `function of_clk_bulk_get`, `function of_clk_bulk_get_all`, `function clk_bulk_put`, `function __clk_bulk_get`, `function clk_bulk_get`, `function clk_bulk_get_optional`, `function clk_bulk_put_all`, `function clk_bulk_get_all`, `function clk_bulk_unprepare`, `function clk_bulk_prepare`.
- Atlas domain: Driver Families / drivers/clk.
- 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.