drivers/clk/clk-fixed-rate_test.c
Source file repositories/reference/linux-study-clean/drivers/clk/clk-fixed-rate_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/clk-fixed-rate_test.c- Extension
.c- Size
- 11072 bytes
- Lines
- 381
- Domain
- Driver Families
- Bucket
- drivers/clk
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/completion.hlinux/of.hlinux/platform_device.hkunit/clk.hkunit/of.hkunit/platform_device.hkunit/resource.hkunit/test.hclk-fixed-rate_test.h
Detected Declarations
struct clk_hw_fixed_rate_kunit_paramsstruct clk_fixed_rate_of_test_contextfunction clk_hw_register_fixed_rate_kunit_initfunction clk_hw_register_fixed_rate_kunit_exitfunction clk_hw_register_fixed_rate_kunitfunction clk_hw_unregister_fixed_rate_kunitfunction clk_get_ratefunction clk_get_accuracyfunction clk_get_parentfunction clk_get_ratefunction clk_get_accuracyfunction pdev_to_clk_fixed_rate_of_test_contextfunction of_fixed_clk_setupfunction of_fixed_clk_setupfunction clk_fixed_rate_of_test_probefunction clk_fixed_rate_of_init
Annotated Snippet
struct clk_hw_fixed_rate_kunit_params {
struct device *dev;
struct device_node *np;
const char *name;
const char *parent_name;
const struct clk_hw *parent_hw;
const struct clk_parent_data *parent_data;
unsigned long flags;
unsigned long fixed_rate;
unsigned long fixed_accuracy;
unsigned long clk_fixed_flags;
};
static int
clk_hw_register_fixed_rate_kunit_init(struct kunit_resource *res, void *context)
{
struct clk_hw_fixed_rate_kunit_params *params = context;
struct clk_hw *hw;
hw = __clk_hw_register_fixed_rate(params->dev, params->np,
params->name,
params->parent_name,
params->parent_hw,
params->parent_data,
params->flags,
params->fixed_rate,
params->fixed_accuracy,
params->clk_fixed_flags,
false);
if (IS_ERR(hw))
return PTR_ERR(hw);
res->data = hw;
return 0;
}
static void clk_hw_register_fixed_rate_kunit_exit(struct kunit_resource *res)
{
struct clk_hw *hw = res->data;
clk_hw_unregister_fixed_rate(hw);
}
/**
* clk_hw_register_fixed_rate_kunit() - Test managed __clk_hw_register_fixed_rate()
* @test: The test context
* @params: Arguments to __clk_hw_register_fixed_rate()
*
* Return: Registered fixed rate clk_hw or ERR_PTR on failure
*/
static struct clk_hw *
clk_hw_register_fixed_rate_kunit(struct kunit *test,
struct clk_hw_fixed_rate_kunit_params *params)
{
struct clk_hw *hw;
hw = kunit_alloc_resource(test,
clk_hw_register_fixed_rate_kunit_init,
clk_hw_register_fixed_rate_kunit_exit,
GFP_KERNEL, params);
if (!hw)
return ERR_PTR(-EINVAL);
return hw;
}
/**
* clk_hw_unregister_fixed_rate_kunit() - Test managed clk_hw_unregister_fixed_rate()
* @test: The test context
* @hw: fixed rate clk to unregister upon test completion
*
* Automatically unregister @hw when @test is complete via
* clk_hw_unregister_fixed_rate().
*
* Return: 0 on success or negative errno on failure
*/
static int clk_hw_unregister_fixed_rate_kunit(struct kunit *test, struct clk_hw *hw)
{
if (!kunit_alloc_resource(test, NULL,
clk_hw_register_fixed_rate_kunit_exit,
GFP_KERNEL, hw))
return -ENOMEM;
return 0;
}
/*
* Test that clk_get_rate() on a fixed rate clk registered with
* clk_hw_register_fixed_rate() gets the proper frequency.
Annotation
- Immediate include surface: `linux/clk.h`, `linux/clk-provider.h`, `linux/completion.h`, `linux/of.h`, `linux/platform_device.h`, `kunit/clk.h`, `kunit/of.h`, `kunit/platform_device.h`.
- Detected declarations: `struct clk_hw_fixed_rate_kunit_params`, `struct clk_fixed_rate_of_test_context`, `function clk_hw_register_fixed_rate_kunit_init`, `function clk_hw_register_fixed_rate_kunit_exit`, `function clk_hw_register_fixed_rate_kunit`, `function clk_hw_unregister_fixed_rate_kunit`, `function clk_get_rate`, `function clk_get_accuracy`, `function clk_get_parent`, `function clk_get_rate`.
- Atlas domain: Driver Families / drivers/clk.
- Implementation status: source 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.