From patchwork Wed Apr 18 14:50:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 10348319 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 C03D460216 for ; Wed, 18 Apr 2018 14:53:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A00C428705 for ; Wed, 18 Apr 2018 14:53:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99FF1204FF; Wed, 18 Apr 2018 14:53:51 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 51E0A28987 for ; Wed, 18 Apr 2018 14:52:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=OjN0pUizUAcBKddcRT58416dJF5jfpWD+ab9AndhJRw=; b=b53bhUqm8UrIfZ3q0GGiTPnk27 R9vCJw9KDd+QSlvACujOUXFaOrXaFe5ATXD/uQH4rPRALJdFJFLfRx+b8uqwATtv8TBJqyKTXq6DM FpRi61yjvC8ZUyJw5F+tABt2WG6Ofurh6MvhhiPE7vd+AGEry5YXSod/RDzlFQlHOsTLIMq0h53Jg okHqxeBx46js/4LxNvkCMKwCbDNMCLtlsLG5COb6x63A/KFuXKn8hqUE4ZqlQZFGwa6KdTS9OeO2y 9eQO66/zAkNGNpT8y2YrWsLa0PfkJC26d0GGnoPdlx3Y5I+mJjUtsP0aMT5GzFAJQGrcbxxNLtQie keczmuUA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f8oS4-00030K-Nx; Wed, 18 Apr 2018 14:52:52 +0000 Received: from michel.telenet-ops.be ([2a02:1800:110:4::f00:18]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f8oPr-0001vh-US for linux-rockchip@lists.infradead.org; Wed, 18 Apr 2018 14:50:42 +0000 Received: from ayla.of.borg ([84.194.111.163]) by michel.telenet-ops.be with bizsmtp id bqq91x0043XaVaC06qq92T; 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 1f8oPQ-0006Dy-Vb; Wed, 18 Apr 2018 16:50:08 +0200 Received: from geert by ramsan with local (Exim 4.86_2) (envelope-from ) id 1f8oPQ-0000Sk-UA; Wed, 18 Apr 2018 16:50:08 +0200 From: Geert Uytterhoeven To: Michael Turquette , Stephen Boyd Subject: [PATCH v3 3/5] soc: rockchip: power-domain: Use of_clk_get_parent_count() instead of open coding Date: Wed, 18 Apr 2018 16:50:03 +0200 Message-Id: <1524063005-1716-4-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180418_075036_161727_F873947E X-CRM114-Status: GOOD ( 12.37 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Heiko Stuebner , Geert Uytterhoeven , linux-rockchip@lists.infradead.org, Maxime Ripard , Linus Walleij , Daniel Lezcano , linux-kernel@vger.kernel.org, Jonathan Hunter , linux-gpio@vger.kernel.org, Chen-Yu Tsai , Rob Herring , Thierry Reding , linux-tegra@vger.kernel.org, Thomas Gleixner , Frank Rowand , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.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 negative number in the allocation below. Signed-off-by: Geert Uytterhoeven Reviewed-by: Heiko Stuebner Reviewed-by: Daniel Lezcano --- This depends on "[PATCH v3 1/5] clk: Extract OF clock helpers in ". v3: - Add Reviewed-by, v2: - of_clk_get_parent_count() was moved to . --- drivers/soc/rockchip/pm_domains.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/soc/rockchip/pm_domains.c b/drivers/soc/rockchip/pm_domains.c index 53efc386b1ada8cf..13913d40c8213e36 100644 --- a/drivers/soc/rockchip/pm_domains.c +++ b/drivers/soc/rockchip/pm_domains.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -400,8 +401,7 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu, pd->info = pd_info; pd->pmu = pmu; - pd->num_clks = of_count_phandle_with_args(node, "clocks", - "#clock-cells"); + pd->num_clks = of_clk_get_parent_count(node); if (pd->num_clks > 0) { pd->clks = devm_kcalloc(pmu->dev, pd->num_clks, sizeof(*pd->clks), GFP_KERNEL);