From patchwork Fri Jan 19 15:18:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 863599 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 3zNPc019CGz9s7M for ; Sat, 20 Jan 2018 02:18:40 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755862AbeASPSi (ORCPT ); Fri, 19 Jan 2018 10:18:38 -0500 Received: from albert.telenet-ops.be ([195.130.137.90]:35030 "EHLO albert.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755718AbeASPSb (ORCPT ); Fri, 19 Jan 2018 10:18:31 -0500 Received: from ayla.of.borg ([84.195.106.246]) by albert.telenet-ops.be with bizsmtp id 0FJS1x00u5JzmfG06FJS2v; 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-0005Qr-LT; Fri, 19 Jan 2018 16:18:26 +0100 Received: from geert by ramsan with local (Exim 4.86_2) (envelope-from ) id 1ecYR0-0007mX-GP; 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 2/3] soc: rockchip: power-domain: Use of_clk_get_parent_count() instead of open coding Date: Fri, 19 Jan 2018 16:18:20 +0100 Message-Id: <1516375101-29836-3-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 negative number in the allocation below. Signed-off-by: Geert Uytterhoeven --- drivers/soc/rockchip/pm_domains.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/soc/rockchip/pm_domains.c b/drivers/soc/rockchip/pm_domains.c index 5c342167b9db7a16..9936038d38771784 100644 --- a/drivers/soc/rockchip/pm_domains.c +++ b/drivers/soc/rockchip/pm_domains.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -391,7 +392,7 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu, return -EINVAL; } - clk_cnt = of_count_phandle_with_args(node, "clocks", "#clock-cells"); + clk_cnt = of_clk_get_parent_count(node); pd = devm_kzalloc(pmu->dev, sizeof(*pd) + clk_cnt * sizeof(pd->clks[0]), GFP_KERNEL);