From patchwork Wed Apr 18 14:50:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 10348305 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9C69660365 for ; Wed, 18 Apr 2018 14:52:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8687828749 for ; Wed, 18 Apr 2018 14:52:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84CCE28777; Wed, 18 Apr 2018 14:52:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6955028777 for ; Wed, 18 Apr 2018 14:51:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753168AbeDROu0 (ORCPT ); Wed, 18 Apr 2018 10:50:26 -0400 Received: from michel.telenet-ops.be ([195.130.137.88]:43096 "EHLO michel.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752786AbeDROuV (ORCPT ); Wed, 18 Apr 2018 10:50:21 -0400 Received: from ayla.of.borg ([84.194.111.163]) by michel.telenet-ops.be with bizsmtp id bqq91x0053XaVaC06qq92U; Wed, 18 Apr 2018 16:50:20 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.86_2) (envelope-from ) id 1f8oPR-0006E2-05; Wed, 18 Apr 2018 16:50:09 +0200 Received: from geert by ramsan with local (Exim 4.86_2) (envelope-from ) id 1f8oPQ-0000Sp-Uy; Wed, 18 Apr 2018 16:50:08 +0200 From: Geert Uytterhoeven To: Michael Turquette , Stephen Boyd Cc: Rob Herring , Frank Rowand , Daniel Lezcano , Thomas Gleixner , Maxime Ripard , Chen-Yu Tsai , Linus Walleij , Heiko Stuebner , Thierry Reding , Jonathan Hunter , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-tegra@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v3 4/5] soc/tegra: pmc: Use of_clk_get_parent_count() instead of open coding Date: Wed, 18 Apr 2018 16:50:04 +0200 Message-Id: <1524063005-1716-5-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524063005-1716-1-git-send-email-geert+renesas@glider.be> References: <1524063005-1716-1-git-send-email-geert+renesas@glider.be> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Jon Hunter Reviewed-by: Daniel Lezcano --- This depends on "[PATCH v3 1/5] clk: Extract OF clock helpers in ". v3: - Add Acked-by, v2: - of_clk_get_parent_count() was moved to . --- 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 d9fcdb592b3966a5..d8cb48a4b8eb1b78 100644 --- a/drivers/soc/tegra/pmc.c +++ b/drivers/soc/tegra/pmc.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -725,7 +726,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;