Skip to content

Commit 3bca66b

Browse files
lucaceresolibebarino
authored andcommitted
clk: vc5: use a dedicated struct to describe the output drivers
Reusing the generic struct vc5_hw_data for all blocks is handy. However it implies we allocate space the div_int and div_frc fields even for the output drivers where they are unused, and the clk_output_cfg0 and clk_output_cfg0_mask fields for all components even though they are used only for the output drivers. Use a dedicated struct for the output drivers so that each block uses exactly the fields it needs, not more. Signed-off-by: Luca Ceresoli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 45c9401 commit 3bca66b

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

drivers/clk/clk-versaclock5.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ struct vc5_hw_data {
167167
u32 div_int;
168168
u32 div_frc;
169169
unsigned int num;
170+
};
171+
172+
struct vc5_out_data {
173+
struct clk_hw hw;
174+
struct vc5_driver_data *vc5;
175+
unsigned int num;
170176
unsigned int clk_output_cfg0;
171177
unsigned int clk_output_cfg0_mask;
172178
};
@@ -184,7 +190,7 @@ struct vc5_driver_data {
184190
struct clk_hw clk_pfd;
185191
struct vc5_hw_data clk_pll;
186192
struct vc5_hw_data clk_fod[VC5_MAX_FOD_NUM];
187-
struct vc5_hw_data clk_out[VC5_MAX_CLK_OUT_NUM];
193+
struct vc5_out_data clk_out[VC5_MAX_CLK_OUT_NUM];
188194
};
189195

190196
/*
@@ -567,7 +573,7 @@ static const struct clk_ops vc5_fod_ops = {
567573

568574
static int vc5_clk_out_prepare(struct clk_hw *hw)
569575
{
570-
struct vc5_hw_data *hwdata = container_of(hw, struct vc5_hw_data, hw);
576+
struct vc5_out_data *hwdata = container_of(hw, struct vc5_out_data, hw);
571577
struct vc5_driver_data *vc5 = hwdata->vc5;
572578
const u8 mask = VC5_OUT_DIV_CONTROL_SELB_NORM |
573579
VC5_OUT_DIV_CONTROL_SEL_EXT |
@@ -609,7 +615,7 @@ static int vc5_clk_out_prepare(struct clk_hw *hw)
609615

610616
static void vc5_clk_out_unprepare(struct clk_hw *hw)
611617
{
612-
struct vc5_hw_data *hwdata = container_of(hw, struct vc5_hw_data, hw);
618+
struct vc5_out_data *hwdata = container_of(hw, struct vc5_out_data, hw);
613619
struct vc5_driver_data *vc5 = hwdata->vc5;
614620

615621
/* Disable the clock buffer */
@@ -619,7 +625,7 @@ static void vc5_clk_out_unprepare(struct clk_hw *hw)
619625

620626
static unsigned char vc5_clk_out_get_parent(struct clk_hw *hw)
621627
{
622-
struct vc5_hw_data *hwdata = container_of(hw, struct vc5_hw_data, hw);
628+
struct vc5_out_data *hwdata = container_of(hw, struct vc5_out_data, hw);
623629
struct vc5_driver_data *vc5 = hwdata->vc5;
624630
const u8 mask = VC5_OUT_DIV_CONTROL_SELB_NORM |
625631
VC5_OUT_DIV_CONTROL_SEL_EXT |
@@ -649,7 +655,7 @@ static unsigned char vc5_clk_out_get_parent(struct clk_hw *hw)
649655

650656
static int vc5_clk_out_set_parent(struct clk_hw *hw, u8 index)
651657
{
652-
struct vc5_hw_data *hwdata = container_of(hw, struct vc5_hw_data, hw);
658+
struct vc5_out_data *hwdata = container_of(hw, struct vc5_out_data, hw);
653659
struct vc5_driver_data *vc5 = hwdata->vc5;
654660
const u8 mask = VC5_OUT_DIV_CONTROL_RESET |
655661
VC5_OUT_DIV_CONTROL_SELB_NORM |
@@ -704,7 +710,7 @@ static int vc5_map_index_to_output(const enum vc5_model model,
704710
}
705711

706712
static int vc5_update_mode(struct device_node *np_output,
707-
struct vc5_hw_data *clk_out)
713+
struct vc5_out_data *clk_out)
708714
{
709715
u32 value;
710716

@@ -729,7 +735,7 @@ static int vc5_update_mode(struct device_node *np_output,
729735
}
730736

731737
static int vc5_update_power(struct device_node *np_output,
732-
struct vc5_hw_data *clk_out)
738+
struct vc5_out_data *clk_out)
733739
{
734740
u32 value;
735741

@@ -754,7 +760,7 @@ static int vc5_update_power(struct device_node *np_output,
754760
}
755761

756762
static int vc5_update_slew(struct device_node *np_output,
757-
struct vc5_hw_data *clk_out)
763+
struct vc5_out_data *clk_out)
758764
{
759765
u32 value;
760766

@@ -782,7 +788,7 @@ static int vc5_update_slew(struct device_node *np_output,
782788
}
783789

784790
static int vc5_get_output_config(struct i2c_client *client,
785-
struct vc5_hw_data *clk_out)
791+
struct vc5_out_data *clk_out)
786792
{
787793
struct device_node *np_output;
788794
char *child_name;

0 commit comments

Comments
 (0)