[PATCH 06/18] CLK: clk-divider: Introduce clk_divider_alloc() and *_free() routines.
Andrey Panov
rockford at yandex.ru
Mon Mar 2 12:21:50 PST 2015
Signed-off-by: Andrey Panov <rockford at yandex.ru>
---
drivers/clk/clk-divider.c | 27 ++++++++++++++++++++++-----
include/linux/clk.h | 3 +++
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index eb48334..82b11ad 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -212,11 +212,10 @@ struct clk_ops clk_divider_ops = {
.round_rate = clk_divider_round_rate,
};
-struct clk *clk_divider(const char *name, const char *parent,
+struct clk *clk_divider_alloc(const char *name, const char *parent,
void __iomem *reg, u8 shift, u8 width, unsigned flags)
{
struct clk_divider *div = xzalloc(sizeof(*div));
- int ret;
div->shift = shift;
div->reg = reg;
@@ -228,13 +227,31 @@ struct clk *clk_divider(const char *name, const char *parent,
div->clk.parent_names = &div->parent;
div->clk.num_parents = 1;
- ret = clk_register(&div->clk);
+ return &div->clk;
+}
+
+void clk_divider_free(struct clk *clk_divider)
+{
+ struct clk_divider *d = container_of(clk_divider, struct clk_divider, clk);
+
+ free(d);
+}
+
+struct clk *clk_divider(const char *name, const char *parent,
+ void __iomem *reg, u8 shift, u8 width, unsigned flags)
+{
+ struct clk *d;
+ int ret;
+
+ d = clk_divider_alloc(name , parent, reg, shift, width, flags);
+
+ ret = clk_register(d);
if (ret) {
- free(div);
+ clk_divider_free(d);
return ERR_PTR(ret);
}
- return &div->clk;
+ return d;
}
struct clk *clk_divider_one_based(const char *name, const char *parent,
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 258bbe3..65d3e99 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -254,6 +254,9 @@ struct clk_divider {
extern struct clk_ops clk_divider_ops;
+struct clk *clk_divider_alloc(const char *name, const char *parent,
+ void __iomem *reg, u8 shift, u8 width, unsigned flags);
+void clk_divider_free(struct clk *clk_divider);
struct clk *clk_divider(const char *name, const char *parent,
void __iomem *reg, u8 shift, u8 width, unsigned flags);
struct clk *clk_divider_one_based(const char *name, const char *parent,
--
2.1.4
More information about the barebox
mailing list