From patchwork Fri Jan 19 15:18:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 863604 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zNPc36GXDz9s7F for ; Sat, 20 Jan 2018 02:18:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755864AbeASPSm (ORCPT ); Fri, 19 Jan 2018 10:18:42 -0500 Received: from baptiste.telenet-ops.be ([195.130.132.51]:57050 "EHLO baptiste.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755748AbeASPSb (ORCPT ); Fri, 19 Jan 2018 10:18:31 -0500 Received: from ayla.of.borg ([84.195.106.246]) by baptiste.telenet-ops.be with bizsmtp id 0FJS1x0225JzmfG01FJS0Y; Fri, 19 Jan 2018 16:18:29 +0100 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.86_2) (envelope-from ) id 1ecYR0-0005Qv-ND; Fri, 19 Jan 2018 16:18:26 +0100 Received: from geert by ramsan with local (Exim 4.86_2) (envelope-from ) id 1ecYR0-0007nA-I4; Fri, 19 Jan 2018 16:18:26 +0100 From: Geert Uytterhoeven To: Maxime Ripard , Chen-Yu Tsai , Heiko Stuebner , Thierry Reding , Jonathan Hunter Cc: Linus Walleij , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-tegra@vger.kernel.org, linux-clk@vger.kernel.org, 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> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516375101-29836-1-git-send-email-geert+renesas@glider.be> References: <1516375101-29836-1-git-send-email-geert+renesas@glider.be> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@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;