mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
clk: ti: change ti_clk_register[_omap_hw]() API
[ Upstream commit 3400d546a7 ]
The ti_clk_register() and ti_clk_register_omap_hw() functions are always
called with the parameter of type "struct device" set to NULL, since the
functions from which they are called always have a parameter of type
"struct device_node". Replacing "struct device" type parameter with
"struct device_node" will allow you to register a TI clock to the common
clock framework by taking advantage of the facilities provided by the
"struct device_node" type. Further, adding the "of_" prefix to the name
of these functions explicitly binds them to the "struct device_node"
type.
The patch has been tested on a Beaglebone board.
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Tony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/r/20221113181147.1626585-1-dario.binacchi@amarulasolutions.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Stable-dep-of: 7af5b9eadd64 ("clk: ti: fix double free in of_ti_divider_clk_setup()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
cb6c38995f
commit
e4df931fb4
@@ -160,7 +160,7 @@ static void __init omap_clk_register_apll(void *user,
|
|||||||
ad->clk_bypass = __clk_get_hw(clk);
|
ad->clk_bypass = __clk_get_hw(clk);
|
||||||
|
|
||||||
name = ti_dt_clk_name(node);
|
name = ti_dt_clk_name(node);
|
||||||
clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name);
|
clk = of_ti_clk_register_omap_hw(node, &clk_hw->hw, name);
|
||||||
if (!IS_ERR(clk)) {
|
if (!IS_ERR(clk)) {
|
||||||
of_clk_add_provider(node, of_clk_src_simple_get, clk);
|
of_clk_add_provider(node, of_clk_src_simple_get, clk);
|
||||||
kfree(init->parent_names);
|
kfree(init->parent_names);
|
||||||
@@ -400,7 +400,7 @@ static void __init of_omap2_apll_setup(struct device_node *node)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
name = ti_dt_clk_name(node);
|
name = ti_dt_clk_name(node);
|
||||||
clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name);
|
clk = of_ti_clk_register_omap_hw(node, &clk_hw->hw, name);
|
||||||
if (!IS_ERR(clk)) {
|
if (!IS_ERR(clk)) {
|
||||||
of_clk_add_provider(node, of_clk_src_simple_get, clk);
|
of_clk_add_provider(node, of_clk_src_simple_get, clk);
|
||||||
kfree(init);
|
kfree(init);
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ static void __init of_dra7_atl_clock_setup(struct device_node *node)
|
|||||||
|
|
||||||
init.parent_names = parent_names;
|
init.parent_names = parent_names;
|
||||||
|
|
||||||
clk = ti_clk_register(NULL, &clk_hw->hw, name);
|
clk = of_ti_clk_register(node, &clk_hw->hw, name);
|
||||||
|
|
||||||
if (!IS_ERR(clk)) {
|
if (!IS_ERR(clk)) {
|
||||||
of_clk_add_provider(node, of_clk_src_simple_get, clk);
|
of_clk_add_provider(node, of_clk_src_simple_get, clk);
|
||||||
|
|||||||
@@ -475,7 +475,7 @@ void __init ti_clk_add_aliases(void)
|
|||||||
clkspec.np = np;
|
clkspec.np = np;
|
||||||
clk = of_clk_get_from_provider(&clkspec);
|
clk = of_clk_get_from_provider(&clkspec);
|
||||||
|
|
||||||
ti_clk_add_alias(NULL, clk, ti_dt_clk_name(np));
|
ti_clk_add_alias(clk, ti_dt_clk_name(np));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,7 +528,6 @@ void omap2_clk_enable_init_clocks(const char **clk_names, u8 num_clocks)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ti_clk_add_alias - add a clock alias for a TI clock
|
* ti_clk_add_alias - add a clock alias for a TI clock
|
||||||
* @dev: device alias for this clock
|
|
||||||
* @clk: clock handle to create alias for
|
* @clk: clock handle to create alias for
|
||||||
* @con: connection ID for this clock
|
* @con: connection ID for this clock
|
||||||
*
|
*
|
||||||
@@ -536,7 +535,7 @@ void omap2_clk_enable_init_clocks(const char **clk_names, u8 num_clocks)
|
|||||||
* and assigns the data to it. Returns 0 if successful, negative error
|
* and assigns the data to it. Returns 0 if successful, negative error
|
||||||
* value otherwise.
|
* value otherwise.
|
||||||
*/
|
*/
|
||||||
int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con)
|
int ti_clk_add_alias(struct clk *clk, const char *con)
|
||||||
{
|
{
|
||||||
struct clk_lookup *cl;
|
struct clk_lookup *cl;
|
||||||
|
|
||||||
@@ -550,8 +549,6 @@ int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con)
|
|||||||
if (!cl)
|
if (!cl)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (dev)
|
|
||||||
cl->dev_id = dev_name(dev);
|
|
||||||
cl->con_id = con;
|
cl->con_id = con;
|
||||||
cl->clk = clk;
|
cl->clk = clk;
|
||||||
|
|
||||||
@@ -561,8 +558,8 @@ int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ti_clk_register - register a TI clock to the common clock framework
|
* of_ti_clk_register - register a TI clock to the common clock framework
|
||||||
* @dev: device for this clock
|
* @node: device node for this clock
|
||||||
* @hw: hardware clock handle
|
* @hw: hardware clock handle
|
||||||
* @con: connection ID for this clock
|
* @con: connection ID for this clock
|
||||||
*
|
*
|
||||||
@@ -570,17 +567,18 @@ int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con)
|
|||||||
* alias for it. Returns a handle to the registered clock if successful,
|
* alias for it. Returns a handle to the registered clock if successful,
|
||||||
* ERR_PTR value in failure.
|
* ERR_PTR value in failure.
|
||||||
*/
|
*/
|
||||||
struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw,
|
struct clk *of_ti_clk_register(struct device_node *node, struct clk_hw *hw,
|
||||||
const char *con)
|
const char *con)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
clk = clk_register(dev, hw);
|
ret = of_clk_hw_register(node, hw);
|
||||||
if (IS_ERR(clk))
|
if (ret)
|
||||||
return clk;
|
return ERR_PTR(ret);
|
||||||
|
|
||||||
ret = ti_clk_add_alias(dev, clk, con);
|
clk = hw->clk;
|
||||||
|
ret = ti_clk_add_alias(clk, con);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
clk_unregister(clk);
|
clk_unregister(clk);
|
||||||
return ERR_PTR(ret);
|
return ERR_PTR(ret);
|
||||||
@@ -590,8 +588,8 @@ struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ti_clk_register_omap_hw - register a clk_hw_omap to the clock framework
|
* of_ti_clk_register_omap_hw - register a clk_hw_omap to the clock framework
|
||||||
* @dev: device for this clock
|
* @node: device node for this clock
|
||||||
* @hw: hardware clock handle
|
* @hw: hardware clock handle
|
||||||
* @con: connection ID for this clock
|
* @con: connection ID for this clock
|
||||||
*
|
*
|
||||||
@@ -600,13 +598,13 @@ struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw,
|
|||||||
* Returns a handle to the registered clock if successful, ERR_PTR value
|
* Returns a handle to the registered clock if successful, ERR_PTR value
|
||||||
* in failure.
|
* in failure.
|
||||||
*/
|
*/
|
||||||
struct clk *ti_clk_register_omap_hw(struct device *dev, struct clk_hw *hw,
|
struct clk *of_ti_clk_register_omap_hw(struct device_node *node,
|
||||||
const char *con)
|
struct clk_hw *hw, const char *con)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
struct clk_hw_omap *oclk;
|
struct clk_hw_omap *oclk;
|
||||||
|
|
||||||
clk = ti_clk_register(dev, hw, con);
|
clk = of_ti_clk_register(node, hw, con);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(clk))
|
||||||
return clk;
|
return clk;
|
||||||
|
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ _ti_clkctrl_clk_register(struct omap_clkctrl_provider *provider,
|
|||||||
init.ops = ops;
|
init.ops = ops;
|
||||||
init.flags = 0;
|
init.flags = 0;
|
||||||
|
|
||||||
clk = ti_clk_register(NULL, clk_hw, init.name);
|
clk = of_ti_clk_register(node, clk_hw, init.name);
|
||||||
if (IS_ERR_OR_NULL(clk)) {
|
if (IS_ERR_OR_NULL(clk)) {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@@ -689,7 +689,7 @@ clkdm_found:
|
|||||||
init.ops = &omap4_clkctrl_clk_ops;
|
init.ops = &omap4_clkctrl_clk_ops;
|
||||||
hw->hw.init = &init;
|
hw->hw.init = &init;
|
||||||
|
|
||||||
clk = ti_clk_register_omap_hw(NULL, &hw->hw, init.name);
|
clk = of_ti_clk_register_omap_hw(node, &hw->hw, init.name);
|
||||||
if (IS_ERR_OR_NULL(clk))
|
if (IS_ERR_OR_NULL(clk))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
|||||||
@@ -199,12 +199,12 @@ extern const struct omap_clkctrl_data dm816_clkctrl_data[];
|
|||||||
|
|
||||||
typedef void (*ti_of_clk_init_cb_t)(void *, struct device_node *);
|
typedef void (*ti_of_clk_init_cb_t)(void *, struct device_node *);
|
||||||
|
|
||||||
struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw,
|
struct clk *of_ti_clk_register(struct device_node *node, struct clk_hw *hw,
|
||||||
const char *con);
|
const char *con);
|
||||||
struct clk *ti_clk_register_omap_hw(struct device *dev, struct clk_hw *hw,
|
struct clk *of_ti_clk_register_omap_hw(struct device_node *node,
|
||||||
const char *con);
|
struct clk_hw *hw, const char *con);
|
||||||
const char *ti_dt_clk_name(struct device_node *np);
|
const char *ti_dt_clk_name(struct device_node *np);
|
||||||
int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con);
|
int ti_clk_add_alias(struct clk *clk, const char *con);
|
||||||
void ti_clk_add_aliases(void);
|
void ti_clk_add_aliases(void);
|
||||||
|
|
||||||
void ti_clk_latch(struct clk_omap_reg *reg, s8 shift);
|
void ti_clk_latch(struct clk_omap_reg *reg, s8 shift);
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ static void __init _register_composite(void *user,
|
|||||||
&ti_composite_gate_ops, 0);
|
&ti_composite_gate_ops, 0);
|
||||||
|
|
||||||
if (!IS_ERR(clk)) {
|
if (!IS_ERR(clk)) {
|
||||||
ret = ti_clk_add_alias(NULL, clk, name);
|
ret = ti_clk_add_alias(clk, name);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
clk_unregister(clk);
|
clk_unregister(clk);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ static struct clk *_register_divider(struct device_node *node,
|
|||||||
div->hw.init = &init;
|
div->hw.init = &init;
|
||||||
|
|
||||||
/* register the clock */
|
/* register the clock */
|
||||||
clk = ti_clk_register(NULL, &div->hw, name);
|
clk = of_ti_clk_register(node, &div->hw, name);
|
||||||
|
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(clk))
|
||||||
kfree(div);
|
kfree(div);
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ static void __init _register_dpll(void *user,
|
|||||||
|
|
||||||
/* register the clock */
|
/* register the clock */
|
||||||
name = ti_dt_clk_name(node);
|
name = ti_dt_clk_name(node);
|
||||||
clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name);
|
clk = of_ti_clk_register_omap_hw(node, &clk_hw->hw, name);
|
||||||
|
|
||||||
if (!IS_ERR(clk)) {
|
if (!IS_ERR(clk)) {
|
||||||
of_clk_add_provider(node, of_clk_src_simple_get, clk);
|
of_clk_add_provider(node, of_clk_src_simple_get, clk);
|
||||||
@@ -259,7 +259,7 @@ static void _register_dpll_x2(struct device_node *node,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* register the clock */
|
/* register the clock */
|
||||||
clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name);
|
clk = of_ti_clk_register_omap_hw(node, &clk_hw->hw, name);
|
||||||
|
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(clk))
|
||||||
kfree(clk_hw);
|
kfree(clk_hw);
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ static void __init of_ti_fixed_factor_clk_setup(struct device_node *node)
|
|||||||
if (!IS_ERR(clk)) {
|
if (!IS_ERR(clk)) {
|
||||||
of_clk_add_provider(node, of_clk_src_simple_get, clk);
|
of_clk_add_provider(node, of_clk_src_simple_get, clk);
|
||||||
of_ti_clk_autoidle_setup(node);
|
of_ti_clk_autoidle_setup(node);
|
||||||
ti_clk_add_alias(NULL, clk, clk_name);
|
ti_clk_add_alias(clk, clk_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CLK_OF_DECLARE(ti_fixed_factor_clk, "ti,fixed-factor-clock",
|
CLK_OF_DECLARE(ti_fixed_factor_clk, "ti,fixed-factor-clock",
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ static int omap36xx_gate_clk_enable_with_hsdiv_restore(struct clk_hw *hw)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct clk *_register_gate(struct device *dev, const char *name,
|
static struct clk *_register_gate(struct device_node *node, const char *name,
|
||||||
const char *parent_name, unsigned long flags,
|
const char *parent_name, unsigned long flags,
|
||||||
struct clk_omap_reg *reg, u8 bit_idx,
|
struct clk_omap_reg *reg, u8 bit_idx,
|
||||||
u8 clk_gate_flags, const struct clk_ops *ops,
|
u8 clk_gate_flags, const struct clk_ops *ops,
|
||||||
@@ -115,7 +115,7 @@ static struct clk *_register_gate(struct device *dev, const char *name,
|
|||||||
|
|
||||||
init.flags = flags;
|
init.flags = flags;
|
||||||
|
|
||||||
clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name);
|
clk = of_ti_clk_register_omap_hw(node, &clk_hw->hw, name);
|
||||||
|
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(clk))
|
||||||
kfree(clk_hw);
|
kfree(clk_hw);
|
||||||
@@ -158,7 +158,7 @@ static void __init _of_ti_gate_clk_setup(struct device_node *node,
|
|||||||
clk_gate_flags |= INVERT_ENABLE;
|
clk_gate_flags |= INVERT_ENABLE;
|
||||||
|
|
||||||
name = ti_dt_clk_name(node);
|
name = ti_dt_clk_name(node);
|
||||||
clk = _register_gate(NULL, name, parent_name, flags, ®,
|
clk = _register_gate(node, name, parent_name, flags, ®,
|
||||||
enable_bit, clk_gate_flags, ops, hw_ops);
|
enable_bit, clk_gate_flags, ops, hw_ops);
|
||||||
|
|
||||||
if (!IS_ERR(clk))
|
if (!IS_ERR(clk))
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ static const struct clk_ops ti_interface_clk_ops = {
|
|||||||
.is_enabled = &omap2_dflt_clk_is_enabled,
|
.is_enabled = &omap2_dflt_clk_is_enabled,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk *_register_interface(struct device *dev, const char *name,
|
static struct clk *_register_interface(struct device_node *node,
|
||||||
|
const char *name,
|
||||||
const char *parent_name,
|
const char *parent_name,
|
||||||
struct clk_omap_reg *reg, u8 bit_idx,
|
struct clk_omap_reg *reg, u8 bit_idx,
|
||||||
const struct clk_hw_omap_ops *ops)
|
const struct clk_hw_omap_ops *ops)
|
||||||
@@ -49,7 +50,7 @@ static struct clk *_register_interface(struct device *dev, const char *name,
|
|||||||
init.num_parents = 1;
|
init.num_parents = 1;
|
||||||
init.parent_names = &parent_name;
|
init.parent_names = &parent_name;
|
||||||
|
|
||||||
clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name);
|
clk = of_ti_clk_register_omap_hw(node, &clk_hw->hw, name);
|
||||||
|
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(clk))
|
||||||
kfree(clk_hw);
|
kfree(clk_hw);
|
||||||
@@ -80,7 +81,7 @@ static void __init _of_ti_interface_clk_setup(struct device_node *node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
name = ti_dt_clk_name(node);
|
name = ti_dt_clk_name(node);
|
||||||
clk = _register_interface(NULL, name, parent_name, ®,
|
clk = _register_interface(node, name, parent_name, ®,
|
||||||
enable_bit, ops);
|
enable_bit, ops);
|
||||||
|
|
||||||
if (!IS_ERR(clk))
|
if (!IS_ERR(clk))
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ const struct clk_ops ti_clk_mux_ops = {
|
|||||||
.restore_context = clk_mux_restore_context,
|
.restore_context = clk_mux_restore_context,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk *_register_mux(struct device *dev, const char *name,
|
static struct clk *_register_mux(struct device_node *node, const char *name,
|
||||||
const char * const *parent_names,
|
const char * const *parent_names,
|
||||||
u8 num_parents, unsigned long flags,
|
u8 num_parents, unsigned long flags,
|
||||||
struct clk_omap_reg *reg, u8 shift, u32 mask,
|
struct clk_omap_reg *reg, u8 shift, u32 mask,
|
||||||
@@ -148,7 +148,7 @@ static struct clk *_register_mux(struct device *dev, const char *name,
|
|||||||
mux->table = table;
|
mux->table = table;
|
||||||
mux->hw.init = &init;
|
mux->hw.init = &init;
|
||||||
|
|
||||||
clk = ti_clk_register(dev, &mux->hw, name);
|
clk = of_ti_clk_register(node, &mux->hw, name);
|
||||||
|
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(clk))
|
||||||
kfree(mux);
|
kfree(mux);
|
||||||
@@ -207,7 +207,7 @@ static void of_mux_clk_setup(struct device_node *node)
|
|||||||
mask = (1 << fls(mask)) - 1;
|
mask = (1 << fls(mask)) - 1;
|
||||||
|
|
||||||
name = ti_dt_clk_name(node);
|
name = ti_dt_clk_name(node);
|
||||||
clk = _register_mux(NULL, name, parent_names, num_parents,
|
clk = _register_mux(node, name, parent_names, num_parents,
|
||||||
flags, ®, shift, mask, latch, clk_mux_flags,
|
flags, ®, shift, mask, latch, clk_mux_flags,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user