Commit 67d4c879 authored by Linus Torvalds's avatar Linus Torvalds

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
parents d1b0949f 790437bb
...@@ -3416,6 +3416,7 @@ static void possible_parent_show(struct seq_file *s, struct clk_core *core, ...@@ -3416,6 +3416,7 @@ static void possible_parent_show(struct seq_file *s, struct clk_core *core,
unsigned int i, char terminator) unsigned int i, char terminator)
{ {
struct clk_core *parent; struct clk_core *parent;
const char *name = NULL;
/* /*
* Go through the following options to fetch a parent's name. * 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, ...@@ -3430,18 +3431,20 @@ static void possible_parent_show(struct seq_file *s, struct clk_core *core,
* registered (yet). * registered (yet).
*/ */
parent = clk_core_get_parent_by_index(core, i); parent = clk_core_get_parent_by_index(core, i);
if (parent) if (parent) {
seq_puts(s, parent->name); seq_puts(s, parent->name);
else if (core->parents[i].name) } else if (core->parents[i].name) {
seq_puts(s, core->parents[i].name); seq_puts(s, core->parents[i].name);
else if (core->parents[i].fw_name) } else if (core->parents[i].fw_name) {
seq_printf(s, "<%s>(fw)", core->parents[i].fw_name); seq_printf(s, "<%s>(fw)", core->parents[i].fw_name);
else if (core->parents[i].index >= 0) } else {
seq_puts(s, if (core->parents[i].index >= 0)
of_clk_get_parent_name(core->of_node, name = of_clk_get_parent_name(core->of_node, core->parents[i].index);
core->parents[i].index)); if (!name)
else name = "(missing)";
seq_puts(s, "(missing)");
seq_puts(s, name);
}
seq_putc(s, terminator); seq_putc(s, terminator);
} }
......
...@@ -87,10 +87,8 @@ static int socfpga_clk_set_parent(struct clk_hw *hwclk, u8 parent) ...@@ -87,10 +87,8 @@ static int socfpga_clk_set_parent(struct clk_hw *hwclk, u8 parent)
return 0; return 0;
} }
static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk, static u32 socfpga_clk_get_div(struct socfpga_gate_clk *socfpgaclk)
unsigned long parent_rate)
{ {
struct socfpga_gate_clk *socfpgaclk = to_socfpga_gate_clk(hwclk);
u32 div = 1, val; u32 div = 1, val;
if (socfpgaclk->fixed_div) if (socfpgaclk->fixed_div)
...@@ -105,12 +103,33 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk, ...@@ -105,12 +103,33 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
div = (1 << val); div = (1 << val);
} }
return div;
}
static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
unsigned long parent_rate)
{
struct socfpga_gate_clk *socfpgaclk = to_socfpga_gate_clk(hwclk);
u32 div = socfpga_clk_get_div(socfpgaclk);
return parent_rate / div; return parent_rate / div;
} }
static int socfpga_clk_determine_rate(struct clk_hw *hwclk,
struct clk_rate_request *req)
{
struct socfpga_gate_clk *socfpgaclk = to_socfpga_gate_clk(hwclk);
u32 div = socfpga_clk_get_div(socfpgaclk);
req->rate = req->best_parent_rate / div;
return 0;
}
static struct clk_ops gateclk_ops = { static struct clk_ops gateclk_ops = {
.recalc_rate = socfpga_clk_recalc_rate, .recalc_rate = socfpga_clk_recalc_rate,
.determine_rate = clk_hw_determine_rate_no_reparent, .determine_rate = socfpga_clk_determine_rate,
.get_parent = socfpga_clk_get_parent, .get_parent = socfpga_clk_get_parent,
.set_parent = socfpga_clk_set_parent, .set_parent = socfpga_clk_set_parent,
}; };
......
...@@ -431,7 +431,7 @@ static int clk_stm32_composite_determine_rate(struct clk_hw *hw, ...@@ -431,7 +431,7 @@ static int clk_stm32_composite_determine_rate(struct clk_hw *hw,
{ {
struct clk_stm32_composite *composite = to_clk_stm32_composite(hw); struct clk_stm32_composite *composite = to_clk_stm32_composite(hw);
const struct stm32_div_cfg *divider; const struct stm32_div_cfg *divider;
unsigned long rate; long rate;
if (composite->div_id == NO_STM32_DIV) if (composite->div_id == NO_STM32_DIV)
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment