Skip to content

Commit 43a354a

Browse files
Dan Carpenterbebarino
authored andcommitted
clk: at91: remove unnecessary conditions
This code checks "if (parent_hw)" is non-NULL, but then it has more checks if parent_hw is non-NULL on the lines inside the if statement. It is a bit confusing. For the else statement, keep in mind that at the start of the function we checked: if (!(parent_name || parent_hw)) return ERR_PTR(-EINVAL); That check ensures that if parent_hw is NULL that means that parent_name is non-NULL. At least one must always be non-NULL. So here again, the checks inside the if statement can be removed. In the original code, it was a bit confusing and you could easily get the impression that "init.num_parents" could be zero. When we remove the unnecessary checking it's more obvious that it's always set to 1. Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://lore.kernel.org/r/7782b4f1-deed-49dc-8207-b6ea06d7602f@moroto.mountain Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 7af5b9e commit 43a354a

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

drivers/clk/at91/clk-utmi.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,11 @@ at91_clk_register_utmi_internal(struct regmap *regmap_pmc,
161161

162162
init.name = name;
163163
init.ops = ops;
164-
if (parent_hw) {
165-
init.parent_hws = parent_hw ? (const struct clk_hw **)&parent_hw : NULL;
166-
init.num_parents = parent_hw ? 1 : 0;
167-
} else {
168-
init.parent_names = parent_name ? &parent_name : NULL;
169-
init.num_parents = parent_name ? 1 : 0;
170-
}
164+
if (parent_hw)
165+
init.parent_hws = (const struct clk_hw **)&parent_hw;
166+
else
167+
init.parent_names = &parent_name;
168+
init.num_parents = 1;
171169
init.flags = flags;
172170

173171
utmi->hw.init = &init;

0 commit comments

Comments
 (0)