mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-05-05 23:04:09 +00:00
clk: sunxi: factors: Add unregister function
sunxi's factors clk did not have an unregister function. This means multiple structs were leaked whenever a factors clk was unregistered. Add an unregister function for it. Also keep pointers to the mux and gate structs so they can be freed. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
This commit is contained in:
parent
78ca95c769
commit
4cbeaebb8a
2 changed files with 30 additions and 0 deletions
|
@ -202,6 +202,8 @@ struct clk *sunxi_factors_register(struct device_node *node,
|
||||||
if (!gate)
|
if (!gate)
|
||||||
goto err_gate;
|
goto err_gate;
|
||||||
|
|
||||||
|
factors->gate = gate;
|
||||||
|
|
||||||
/* set up gate properties */
|
/* set up gate properties */
|
||||||
gate->reg = reg;
|
gate->reg = reg;
|
||||||
gate->bit_idx = data->enable;
|
gate->bit_idx = data->enable;
|
||||||
|
@ -215,6 +217,8 @@ struct clk *sunxi_factors_register(struct device_node *node,
|
||||||
if (!mux)
|
if (!mux)
|
||||||
goto err_mux;
|
goto err_mux;
|
||||||
|
|
||||||
|
factors->mux = mux;
|
||||||
|
|
||||||
/* set up gate properties */
|
/* set up gate properties */
|
||||||
mux->reg = reg;
|
mux->reg = reg;
|
||||||
mux->shift = data->mux;
|
mux->shift = data->mux;
|
||||||
|
@ -255,3 +259,24 @@ err_gate:
|
||||||
err_factors:
|
err_factors:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sunxi_factors_unregister(struct device_node *node, struct clk *clk)
|
||||||
|
{
|
||||||
|
struct clk_hw *hw = __clk_get_hw(clk);
|
||||||
|
struct clk_factors *factors;
|
||||||
|
const char *name;
|
||||||
|
|
||||||
|
if (!hw)
|
||||||
|
return;
|
||||||
|
|
||||||
|
factors = to_clk_factors(hw);
|
||||||
|
name = clk_hw_get_name(hw);
|
||||||
|
|
||||||
|
/* No unregister call for clkdev_* */
|
||||||
|
of_clk_del_provider(node);
|
||||||
|
/* TODO: The composite clock stuff will leak a bit here. */
|
||||||
|
clk_unregister(clk);
|
||||||
|
kfree(factors->mux);
|
||||||
|
kfree(factors->gate);
|
||||||
|
kfree(factors);
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,9 @@ struct clk_factors {
|
||||||
const struct clk_factors_config *config;
|
const struct clk_factors_config *config;
|
||||||
void (*get_factors) (u32 *rate, u32 parent, u8 *n, u8 *k, u8 *m, u8 *p);
|
void (*get_factors) (u32 *rate, u32 parent, u8 *n, u8 *k, u8 *m, u8 *p);
|
||||||
spinlock_t *lock;
|
spinlock_t *lock;
|
||||||
|
/* for cleanup */
|
||||||
|
struct clk_mux *mux;
|
||||||
|
struct clk_gate *gate;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct clk *sunxi_factors_register(struct device_node *node,
|
struct clk *sunxi_factors_register(struct device_node *node,
|
||||||
|
@ -41,4 +44,6 @@ struct clk *sunxi_factors_register(struct device_node *node,
|
||||||
spinlock_t *lock,
|
spinlock_t *lock,
|
||||||
void __iomem *reg);
|
void __iomem *reg);
|
||||||
|
|
||||||
|
void sunxi_factors_unregister(struct device_node *node, struct clk *clk);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue