From mboxrd@z Thu Jan 1 00:00:00 1970 From: Geert Uytterhoeven Subject: [PATCH 3/3] soc/tegra: pmc: Use of_clk_get_parent_count() instead of open coding Date: Fri, 19 Jan 2018 16:18:21 +0100 Message-ID: <1516375101-29836-4-git-send-email-geert+renesas@glider.be> References: <1516375101-29836-1-git-send-email-geert+renesas@glider.be> Return-path: In-Reply-To: <1516375101-29836-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org> Sender: linux-tegra-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Maxime Ripard , Chen-Yu Tsai , Heiko Stuebner , Thierry Reding , Jonathan Hunter Cc: Linus Walleij , linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-clk-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Geert Uytterhoeven List-Id: linux-gpio@vger.kernel.org As of_clk_get_parent_count() returns zero on failure, while of_count_phandle_with_args() might return a negative error code, this also fixes the issue of possibly using a very big number in the allocation below. Signed-off-by: Geert Uytterhoeven --- drivers/soc/tegra/pmc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c index ce62a47a6647a817..4379e4d602bc5428 100644 --- a/drivers/soc/tegra/pmc.c +++ b/drivers/soc/tegra/pmc.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -743,7 +744,7 @@ static int tegra_powergate_of_get_clks(struct tegra_powergate *pg, unsigned int i, count; int err; - count = of_count_phandle_with_args(np, "clocks", "#clock-cells"); + count = of_clk_get_parent_count(np); if (count == 0) return -ENODEV; -- 2.7.4