mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
clk: fixed-factor: Rework initialization with parent clocks
Use the same sequence as clk-divider, clk-gate and other to set the parent_names, parent_hws and parent_data in the init struct when registering a fixed-factor clock. The number of parent clocks is now only set to one if a parent clock is provided. Previously the number of parent clocks was always one, forcing callers of __clk_hw_register_fixed_factor() to provide a dummy parent_data struct with an invalid clock index in case they were not provided with a non-NULL parent_name or parent_hw. Drop this dummy parent_data as is not necessary anymore. This change only has a small impact on mis-configured fixed-factor. Now a call to clk_hw_register_fixed_factor() with a NULL parent will register a fixed-factor with zero parent while previously it was registered with one invalid parent. In both cases the rate of the fixed-factor is 0Hz but it is no longer shown as orphaned. This has no impact on properly configured fixed-factors clocks which have a valid parent set. In clk_factor_determine_rate(), make sure the parent clock is valid before accessing it because the mis-configured fixed-factor now have a NULL parent. Reviewed-by: Brian Masney <bmasney@redhat.com> Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
This commit is contained in:
parent
379fc3b26b
commit
46dda4d975
|
|
@ -36,10 +36,14 @@ static int clk_factor_determine_rate(struct clk_hw *hw,
|
|||
struct clk_fixed_factor *fix = to_clk_fixed_factor(hw);
|
||||
|
||||
if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) {
|
||||
struct clk_hw *parent_hw = clk_hw_get_parent(hw);
|
||||
unsigned long best_parent;
|
||||
|
||||
if (!parent_hw)
|
||||
return -EINVAL;
|
||||
|
||||
best_parent = (req->rate / fix->mult) * fix->div;
|
||||
req->best_parent_rate = clk_hw_round_rate(clk_hw_get_parent(hw), best_parent);
|
||||
req->best_parent_rate = clk_hw_round_rate(parent_hw, best_parent);
|
||||
}
|
||||
|
||||
req->rate = (req->best_parent_rate / fix->div) * fix->mult;
|
||||
|
|
@ -124,13 +128,13 @@ __clk_hw_register_fixed_factor(struct device *dev, struct device_node *np,
|
|||
init.name = name;
|
||||
init.ops = &clk_fixed_factor_ops;
|
||||
init.flags = flags;
|
||||
if (parent_name)
|
||||
init.parent_names = &parent_name;
|
||||
else if (parent_hw)
|
||||
init.parent_hws = &parent_hw;
|
||||
init.parent_names = parent_name ? &parent_name : NULL;
|
||||
init.parent_hws = parent_hw ? &parent_hw : NULL;
|
||||
init.parent_data = pdata;
|
||||
if (parent_name || parent_hw || pdata)
|
||||
init.num_parents = 1;
|
||||
else
|
||||
init.parent_data = pdata;
|
||||
init.num_parents = 1;
|
||||
init.num_parents = 0;
|
||||
|
||||
hw = &fix->hw;
|
||||
if (dev)
|
||||
|
|
@ -190,10 +194,8 @@ struct clk_hw *devm_clk_hw_register_fixed_factor_parent_hw(struct device *dev,
|
|||
const char *name, const struct clk_hw *parent_hw,
|
||||
unsigned long flags, unsigned int mult, unsigned int div)
|
||||
{
|
||||
const struct clk_parent_data pdata = { .index = -1 };
|
||||
|
||||
return __clk_hw_register_fixed_factor(dev, NULL, name, NULL, parent_hw,
|
||||
&pdata, flags, mult, div, 0, 0, true);
|
||||
NULL, flags, mult, div, 0, 0, true);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_clk_hw_register_fixed_factor_parent_hw);
|
||||
|
||||
|
|
@ -201,10 +203,8 @@ struct clk_hw *clk_hw_register_fixed_factor_parent_hw(struct device *dev,
|
|||
const char *name, const struct clk_hw *parent_hw,
|
||||
unsigned long flags, unsigned int mult, unsigned int div)
|
||||
{
|
||||
const struct clk_parent_data pdata = { .index = -1 };
|
||||
|
||||
return __clk_hw_register_fixed_factor(dev, NULL, name, NULL, parent_hw,
|
||||
&pdata, flags, mult, div, 0, 0, false);
|
||||
NULL, flags, mult, div, 0, 0, false);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(clk_hw_register_fixed_factor_parent_hw);
|
||||
|
||||
|
|
@ -212,10 +212,8 @@ struct clk_hw *clk_hw_register_fixed_factor(struct device *dev,
|
|||
const char *name, const char *parent_name, unsigned long flags,
|
||||
unsigned int mult, unsigned int div)
|
||||
{
|
||||
const struct clk_parent_data pdata = { .index = -1 };
|
||||
|
||||
return __clk_hw_register_fixed_factor(dev, NULL, name, parent_name, NULL,
|
||||
&pdata, flags, mult, div, 0, 0, false);
|
||||
NULL, flags, mult, div, 0, 0, false);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(clk_hw_register_fixed_factor);
|
||||
|
||||
|
|
@ -296,10 +294,8 @@ struct clk_hw *devm_clk_hw_register_fixed_factor(struct device *dev,
|
|||
const char *name, const char *parent_name, unsigned long flags,
|
||||
unsigned int mult, unsigned int div)
|
||||
{
|
||||
const struct clk_parent_data pdata = { .index = -1 };
|
||||
|
||||
return __clk_hw_register_fixed_factor(dev, NULL, name, parent_name, NULL,
|
||||
&pdata, flags, mult, div, 0, 0, true);
|
||||
NULL, flags, mult, div, 0, 0, true);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_clk_hw_register_fixed_factor);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user