提交 182f9e8c 编写于 作者: V Viresh Kumar 提交者: Mike Turquette

clk: clk-private: Add DEFINE_CLK macro

All macros used for creating different kind of clocks have similar code for
initializing struct clk. This patch removes those redundant lines and create
another macro DEFINE_CLK.
Signed-off-by: NViresh Kumar <viresh.kumar@st.com>
Signed-off-by: NMike Turquette <mturquette@linaro.org>
上级 fbc42aab
...@@ -55,6 +55,18 @@ struct clk { ...@@ -55,6 +55,18 @@ struct clk {
* alternative macro for static initialization * alternative macro for static initialization
*/ */
#define DEFINE_CLK(_name, _ops, _flags, _parent_names, \
_parents) \
static struct clk _name = { \
.name = #_name, \
.ops = &_ops, \
.hw = &_name##_hw.hw, \
.parent_names = _parent_names, \
.num_parents = ARRAY_SIZE(_parent_names), \
.parents = _parents, \
.flags = _flags, \
}
#define DEFINE_CLK_FIXED_RATE(_name, _flags, _rate, \ #define DEFINE_CLK_FIXED_RATE(_name, _flags, _rate, \
_fixed_rate_flags) \ _fixed_rate_flags) \
static struct clk _name; \ static struct clk _name; \
...@@ -66,15 +78,8 @@ struct clk { ...@@ -66,15 +78,8 @@ struct clk {
.fixed_rate = _rate, \ .fixed_rate = _rate, \
.flags = _fixed_rate_flags, \ .flags = _fixed_rate_flags, \
}; \ }; \
static struct clk _name = { \ DEFINE_CLK(_name, clk_fixed_rate_ops, _flags, \
.name = #_name, \ _name##_parent_names, NULL);
.ops = &clk_fixed_rate_ops, \
.hw = &_name##_hw.hw, \
.parent_names = _name##_parent_names, \
.num_parents = \
ARRAY_SIZE(_name##_parent_names), \
.flags = _flags, \
};
#define DEFINE_CLK_GATE(_name, _parent_name, _parent_ptr, \ #define DEFINE_CLK_GATE(_name, _parent_name, _parent_ptr, \
_flags, _reg, _bit_idx, \ _flags, _reg, _bit_idx, \
...@@ -95,16 +100,8 @@ struct clk { ...@@ -95,16 +100,8 @@ struct clk {
.flags = _gate_flags, \ .flags = _gate_flags, \
.lock = _lock, \ .lock = _lock, \
}; \ }; \
static struct clk _name = { \ DEFINE_CLK(_name, clk_gate_ops, _flags, \
.name = #_name, \ _name##_parent_names, _name##_parents);
.ops = &clk_gate_ops, \
.hw = &_name##_hw.hw, \
.parent_names = _name##_parent_names, \
.num_parents = \
ARRAY_SIZE(_name##_parent_names), \
.parents = _name##_parents, \
.flags = _flags, \
};
#define DEFINE_CLK_DIVIDER(_name, _parent_name, _parent_ptr, \ #define DEFINE_CLK_DIVIDER(_name, _parent_name, _parent_ptr, \
_flags, _reg, _shift, _width, \ _flags, _reg, _shift, _width, \
...@@ -126,16 +123,8 @@ struct clk { ...@@ -126,16 +123,8 @@ struct clk {
.flags = _divider_flags, \ .flags = _divider_flags, \
.lock = _lock, \ .lock = _lock, \
}; \ }; \
static struct clk _name = { \ DEFINE_CLK(_name, clk_divider_ops, _flags, \
.name = #_name, \ _name##_parent_names, _name##_parents);
.ops = &clk_divider_ops, \
.hw = &_name##_hw.hw, \
.parent_names = _name##_parent_names, \
.num_parents = \
ARRAY_SIZE(_name##_parent_names), \
.parents = _name##_parents, \
.flags = _flags, \
};
#define DEFINE_CLK_MUX(_name, _parent_names, _parents, _flags, \ #define DEFINE_CLK_MUX(_name, _parent_names, _parents, _flags, \
_reg, _shift, _width, \ _reg, _shift, _width, \
...@@ -151,16 +140,8 @@ struct clk { ...@@ -151,16 +140,8 @@ struct clk {
.flags = _mux_flags, \ .flags = _mux_flags, \
.lock = _lock, \ .lock = _lock, \
}; \ }; \
static struct clk _name = { \ DEFINE_CLK(_name, clk_mux_ops, _flags, _parent_names, \
.name = #_name, \ _parents);
.ops = &clk_mux_ops, \
.hw = &_name##_hw.hw, \
.parent_names = _parent_names, \
.num_parents = \
ARRAY_SIZE(_parent_names), \
.parents = _parents, \
.flags = _flags, \
};
/** /**
* __clk_init - initialize the data structures in a struct clk * __clk_init - initialize the data structures in a struct clk
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册