Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 96a7ed90 authored by Tomasz Figa's avatar Tomasz Figa Committed by Mike Turquette
Browse files

clk: Use kcalloc() to allocate arrays



Instead of calculating sizes of arrays manually, kcalloc() can be used
to allocate arrays of elements with defined size. This is just a cleanup
patch without any functional changes.

Signed-off-by: default avatarTomasz Figa <tomasz.figa@gmail.com>
Signed-off-by: default avatarMike Turquette <mturquette@linaro.org>
parent f1c8b2ed
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -1085,8 +1085,8 @@ static int clk_fetch_parent_index(struct clk *clk, struct clk *parent)
	int i;

	if (!clk->parents) {
		clk->parents = kzalloc((sizeof(struct clk*) * clk->num_parents),
								GFP_KERNEL);
		clk->parents = kcalloc(clk->num_parents,
					sizeof(struct clk *), GFP_KERNEL);
		if (!clk->parents)
			return -ENOMEM;
	}
@@ -1535,7 +1535,7 @@ static struct clk *__clk_init_parent(struct clk *clk)

	if (!clk->parents)
		clk->parents =
			kzalloc((sizeof(struct clk*) * clk->num_parents),
			kcalloc(clk->num_parents, sizeof(struct clk *),
					GFP_KERNEL);

	ret = clk_get_parent_by_index(clk, index);
@@ -1692,7 +1692,7 @@ int __clk_init(struct device *dev, struct clk *clk)
	 * for clock drivers to statically initialize clk->parents.
	 */
	if (clk->num_parents > 1 && !clk->parents) {
		clk->parents = kzalloc((sizeof(struct clk*) * clk->num_parents),
		clk->parents = kcalloc(clk->num_parents, sizeof(struct clk *),
					GFP_KERNEL);
		/*
		 * __clk_lookup returns NULL for parents that have not been
@@ -1833,7 +1833,7 @@ static int _clk_register(struct device *dev, struct clk_hw *hw, struct clk *clk)
	hw->clk = clk;

	/* allocate local copy in case parent_names is __initdata */
	clk->parent_names = kzalloc((sizeof(char*) * clk->num_parents),
	clk->parent_names = kcalloc(clk->num_parents, sizeof(char *),
					GFP_KERNEL);

	if (!clk->parent_names) {