clk: ti: divider: try to fix ti_clk_register_divider

Commit 6c0afb5039 ("clk: ti: convert to use proper register
definition for all accesses") converted all register accesses in
the TI clk driver to use a proper struct instead of a void
pointer casted struct that fits into a u32. Unfortunately, it
missed a conversion here in the didivder code, leading to a
compiler warning like so:

drivers/clk/ti/divider.c: In function 'ti_clk_register_divider':
drivers/clk/ti/divider.c:460:8: error: 'reg' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Treating a 'u32' variable as a structure leads to a stack
overflow here, and the register address we pass down is never
initialized. Convert this part of the code as well so things
work properly.

Fixes: 6c0afb5039 ("clk: ti: convert to use proper register definition for all accesses")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
[sboyd@codeaurora.org: Fixed fixes tag, rewrote commit message,
s/reg_setup/reg/]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
This commit is contained in:
Arnd Bergmann 2017-04-19 19:44:55 +02:00 committed by Stephen Boyd
parent ee7d74339d
commit 3417f3528a
1 changed files with 6 additions and 11 deletions

View File

@ -428,22 +428,17 @@ struct clk_hw *ti_clk_build_component_div(struct ti_clk_divider *setup)
struct clk *ti_clk_register_divider(struct ti_clk *setup) struct clk *ti_clk_register_divider(struct ti_clk *setup)
{ {
struct ti_clk_divider *div; struct ti_clk_divider *div = setup->data;
struct clk_omap_reg *reg_setup; struct clk_omap_reg reg = {
u32 reg; .index = div->module,
.offset = div->reg,
};
u8 width; u8 width;
u32 flags = 0; u32 flags = 0;
u8 div_flags = 0; u8 div_flags = 0;
const struct clk_div_table *table; const struct clk_div_table *table;
struct clk *clk; struct clk *clk;
div = setup->data;
reg_setup = (struct clk_omap_reg *)&reg;
reg_setup->index = div->module;
reg_setup->offset = div->reg;
if (div->flags & CLKF_INDEX_STARTS_AT_ONE) if (div->flags & CLKF_INDEX_STARTS_AT_ONE)
div_flags |= CLK_DIVIDER_ONE_BASED; div_flags |= CLK_DIVIDER_ONE_BASED;
@ -458,7 +453,7 @@ struct clk *ti_clk_register_divider(struct ti_clk *setup)
return (struct clk *)table; return (struct clk *)table;
clk = _register_divider(NULL, setup->name, div->parent, clk = _register_divider(NULL, setup->name, div->parent,
flags, (void __iomem *)reg, div->bit_shift, flags, &reg, div->bit_shift,
width, div_flags, table); width, div_flags, table);
if (IS_ERR(clk)) if (IS_ERR(clk))