Skip to content

Commit 67d4c87

Browse files
committed
Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux
Pull clk fixes from Stephen Boyd: "Three fixes, one for the clk framework and two for clk drivers: - Avoid an oops in possible_parent_show() by checking for no parent properly when a DT index based lookup is used - Handle errors returned from divider_ro_round_rate() in clk_stm32_composite_determine_rate() - Fix clk_ops::determine_rate() implementation of socfpga's gateclk_ops that was ruining uart output because the divider was forgotten about" * tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux: clk: stm32: Fix a signedness issue in clk_stm32_composite_determine_rate() clk: Sanitize possible_parent_show to Handle Return Value of of_clk_get_parent_name clk: socfpga: gate: Account for the divider in determine_rate
2 parents d1b0949 + 790437b commit 67d4c87

File tree

3 files changed

+36
-14
lines changed

3 files changed

+36
-14
lines changed

drivers/clk/clk.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3416,6 +3416,7 @@ static void possible_parent_show(struct seq_file *s, struct clk_core *core,
34163416
unsigned int i, char terminator)
34173417
{
34183418
struct clk_core *parent;
3419+
const char *name = NULL;
34193420

34203421
/*
34213422
* Go through the following options to fetch a parent's name.
@@ -3430,18 +3431,20 @@ static void possible_parent_show(struct seq_file *s, struct clk_core *core,
34303431
* registered (yet).
34313432
*/
34323433
parent = clk_core_get_parent_by_index(core, i);
3433-
if (parent)
3434+
if (parent) {
34343435
seq_puts(s, parent->name);
3435-
else if (core->parents[i].name)
3436+
} else if (core->parents[i].name) {
34363437
seq_puts(s, core->parents[i].name);
3437-
else if (core->parents[i].fw_name)
3438+
} else if (core->parents[i].fw_name) {
34383439
seq_printf(s, "<%s>(fw)", core->parents[i].fw_name);
3439-
else if (core->parents[i].index >= 0)
3440-
seq_puts(s,
3441-
of_clk_get_parent_name(core->of_node,
3442-
core->parents[i].index));
3443-
else
3444-
seq_puts(s, "(missing)");
3440+
} else {
3441+
if (core->parents[i].index >= 0)
3442+
name = of_clk_get_parent_name(core->of_node, core->parents[i].index);
3443+
if (!name)
3444+
name = "(missing)";
3445+
3446+
seq_puts(s, name);
3447+
}
34453448

34463449
seq_putc(s, terminator);
34473450
}

drivers/clk/socfpga/clk-gate.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,8 @@ static int socfpga_clk_set_parent(struct clk_hw *hwclk, u8 parent)
8787
return 0;
8888
}
8989

90-
static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
91-
unsigned long parent_rate)
90+
static u32 socfpga_clk_get_div(struct socfpga_gate_clk *socfpgaclk)
9291
{
93-
struct socfpga_gate_clk *socfpgaclk = to_socfpga_gate_clk(hwclk);
9492
u32 div = 1, val;
9593

9694
if (socfpgaclk->fixed_div)
@@ -105,12 +103,33 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
105103
div = (1 << val);
106104
}
107105

106+
return div;
107+
}
108+
109+
static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
110+
unsigned long parent_rate)
111+
{
112+
struct socfpga_gate_clk *socfpgaclk = to_socfpga_gate_clk(hwclk);
113+
u32 div = socfpga_clk_get_div(socfpgaclk);
114+
108115
return parent_rate / div;
109116
}
110117

118+
119+
static int socfpga_clk_determine_rate(struct clk_hw *hwclk,
120+
struct clk_rate_request *req)
121+
{
122+
struct socfpga_gate_clk *socfpgaclk = to_socfpga_gate_clk(hwclk);
123+
u32 div = socfpga_clk_get_div(socfpgaclk);
124+
125+
req->rate = req->best_parent_rate / div;
126+
127+
return 0;
128+
}
129+
111130
static struct clk_ops gateclk_ops = {
112131
.recalc_rate = socfpga_clk_recalc_rate,
113-
.determine_rate = clk_hw_determine_rate_no_reparent,
132+
.determine_rate = socfpga_clk_determine_rate,
114133
.get_parent = socfpga_clk_get_parent,
115134
.set_parent = socfpga_clk_set_parent,
116135
};

drivers/clk/stm32/clk-stm32-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ static int clk_stm32_composite_determine_rate(struct clk_hw *hw,
431431
{
432432
struct clk_stm32_composite *composite = to_clk_stm32_composite(hw);
433433
const struct stm32_div_cfg *divider;
434-
unsigned long rate;
434+
long rate;
435435

436436
if (composite->div_id == NO_STM32_DIV)
437437
return 0;

0 commit comments

Comments
 (0)