Commit 8a53fb2b authored by Dinh Nguyen's avatar Dinh Nguyen Committed by Stephen Boyd
Browse files

clk: sunxi: make use of of_clk_parent_fill helper function



Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: default avatarDinh Nguyen <dinguyen@opensource.altera.com>
Acked-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
Cc: "Emilio López" <emilio@elopez.com.ar>
Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
parent 0b4e7f08
Loading
Loading
Loading
Loading
+1 −3
Original line number Original line Diff line number Diff line
@@ -80,9 +80,7 @@ static void __init sun7i_a20_gmac_clk_setup(struct device_node *node)
		goto free_mux;
		goto free_mux;


	/* gmac clock requires exactly 2 parents */
	/* gmac clock requires exactly 2 parents */
	parents[0] = of_clk_get_parent_name(node, 0);
	if (of_clk_parent_fill(node, parents, 2) != 2)
	parents[1] = of_clk_get_parent_name(node, 1);
	if (!parents[0] || !parents[1])
		goto free_gate;
		goto free_gate;


	reg = of_iomap(node, 0);
	reg = of_iomap(node, 0);
+1 −3
Original line number Original line Diff line number Diff line
@@ -175,9 +175,7 @@ struct clk *sunxi_factors_register(struct device_node *node,
	int i = 0;
	int i = 0;


	/* if we have a mux, we will have >1 parents */
	/* if we have a mux, we will have >1 parents */
	while (i < FACTORS_MAX_PARENTS &&
	i = of_clk_parent_fill(node, parents, FACTORS_MAX_PARENTS);
	       (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
		i++;


	/*
	/*
	 * some factor clocks, such as pll5 and pll6, may have multiple
	 * some factor clocks, such as pll5 and pll6, may have multiple
+1 −3
Original line number Original line Diff line number Diff line
@@ -182,7 +182,6 @@ static int sun6i_a31_ar100_clk_probe(struct platform_device *pdev)
	struct resource *r;
	struct resource *r;
	struct clk *clk;
	struct clk *clk;
	int nparents;
	int nparents;
	int i;


	ar100 = devm_kzalloc(&pdev->dev, sizeof(*ar100), GFP_KERNEL);
	ar100 = devm_kzalloc(&pdev->dev, sizeof(*ar100), GFP_KERNEL);
	if (!ar100)
	if (!ar100)
@@ -197,8 +196,7 @@ static int sun6i_a31_ar100_clk_probe(struct platform_device *pdev)
	if (nparents > SUN6I_AR100_MAX_PARENTS)
	if (nparents > SUN6I_AR100_MAX_PARENTS)
		nparents = SUN6I_AR100_MAX_PARENTS;
		nparents = SUN6I_AR100_MAX_PARENTS;


	for (i = 0; i < nparents; i++)
	of_clk_parent_fill(np, parents, nparents);
		parents[i] = of_clk_get_parent_name(np, i);


	of_property_read_string(np, "clock-output-names", &clk_name);
	of_property_read_string(np, "clock-output-names", &clk_name);


+4 −10
Original line number Original line Diff line number Diff line
@@ -195,17 +195,14 @@ static void __init sun6i_ahb1_clk_setup(struct device_node *node)
	const char *clk_name = node->name;
	const char *clk_name = node->name;
	const char *parents[SUN6I_AHB1_MAX_PARENTS];
	const char *parents[SUN6I_AHB1_MAX_PARENTS];
	void __iomem *reg;
	void __iomem *reg;
	int i = 0;
	int i;


	reg = of_io_request_and_map(node, 0, of_node_full_name(node));
	reg = of_io_request_and_map(node, 0, of_node_full_name(node));
	if (IS_ERR(reg))
	if (IS_ERR(reg))
		return;
		return;


	/* we have a mux, we will have >1 parents */
	/* we have a mux, we will have >1 parents */
	while (i < SUN6I_AHB1_MAX_PARENTS &&
	i = of_clk_parent_fill(node, parents, SUN6I_AHB1_MAX_PARENTS);
	       (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
		i++;

	of_property_read_string(node, "clock-output-names", &clk_name);
	of_property_read_string(node, "clock-output-names", &clk_name);


	ahb1 = kzalloc(sizeof(struct sun6i_ahb1_clk), GFP_KERNEL);
	ahb1 = kzalloc(sizeof(struct sun6i_ahb1_clk), GFP_KERNEL);
@@ -786,14 +783,11 @@ static void __init sunxi_mux_clk_setup(struct device_node *node,
	const char *clk_name = node->name;
	const char *clk_name = node->name;
	const char *parents[SUNXI_MAX_PARENTS];
	const char *parents[SUNXI_MAX_PARENTS];
	void __iomem *reg;
	void __iomem *reg;
	int i = 0;
	int i;


	reg = of_iomap(node, 0);
	reg = of_iomap(node, 0);


	while (i < SUNXI_MAX_PARENTS &&
	i = of_clk_parent_fill(node, parents, SUNXI_MAX_PARENTS);
	       (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
		i++;

	of_property_read_string(node, "clock-output-names", &clk_name);
	of_property_read_string(node, "clock-output-names", &clk_name);


	clk = clk_register_mux(NULL, clk_name, parents, i,
	clk = clk_register_mux(NULL, clk_name, parents, i,