Skip to content

Commit 9962fb0

Browse files
claudiubezneabebarino
authored andcommitted
clk: at91: usb: introduce num_parents in driver's structure
SAM9X60 USB clock may have up to 3 parents. Save the number of parents in driver's data structure and validate against it when setting parent. Signed-off-by: Claudiu Beznea <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Acked-by: Alexandre Belloni <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent d7a83d6 commit 9962fb0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/clk/at91/clk-usb.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct at91sam9x5_clk_usb {
2525
struct clk_hw hw;
2626
struct regmap *regmap;
2727
u32 usbs_mask;
28+
u8 num_parents;
2829
};
2930

3031
#define to_at91sam9x5_clk_usb(hw) \
@@ -110,7 +111,7 @@ static int at91sam9x5_clk_usb_set_parent(struct clk_hw *hw, u8 index)
110111
{
111112
struct at91sam9x5_clk_usb *usb = to_at91sam9x5_clk_usb(hw);
112113

113-
if (index > 1)
114+
if (index >= usb->num_parents)
114115
return -EINVAL;
115116

116117
regmap_update_bits(usb->regmap, AT91_PMC_USB, usb->usbs_mask, index);
@@ -215,6 +216,7 @@ _at91sam9x5_clk_register_usb(struct regmap *regmap, const char *name,
215216
usb->hw.init = &init;
216217
usb->regmap = regmap;
217218
usb->usbs_mask = usbs_mask;
219+
usb->num_parents = num_parents;
218220

219221
hw = &usb->hw;
220222
ret = clk_hw_register(NULL, &usb->hw);

0 commit comments

Comments
 (0)