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: 10175561 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 24E3B60392 for ; Fri, 19 Jan 2018 15:19:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A4A5286C6 for ; Fri, 19 Jan 2018 15:19:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D11E286C8; Fri, 19 Jan 2018 15:19:04 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 9CA27286C7 for ; Fri, 19 Jan 2018 15:19:03 +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=+Qa1kncVrnCMMbZBFcMt4kjSctO3kqMqH4jQH0jbNDg=; b=OLRCJP5xLKH5VmLDVXJNTjJGge x/mdv1G+wSA2P4CzpT8lToBZPt6H93g3CGhkeVtzZci/LuXhJRO2Ls/Fy3nXZVUEECRgcZdjM4JT2 PyHtf0OB6RlcFV3v+gcZgE8othgEid6EvKiyWaGHOGSdXLyTOMpJFDTU4QvmG9zAlVDkepLQItQXj lz10N4vtGjnGsFKGzvkdYuG2juuJvWXdG3RtFOFfVeFazID3wOxF/NRjWi6x0vqFx4IyLcsWRUxju l130dNG4xjTpM/DIpg9+5yylHBh/RbPCzhNwEU1c+zubQ4pXWcuwmHHSZxZdEKVSmozWmZD8uUlZh s7qkjo9g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ecYRZ-0002Y1-OG; Fri, 19 Jan 2018 15:19:01 +0000 Received: from albert.telenet-ops.be ([2a02:1800:110:4::f00:1a]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ecYRJ-0002JH-P8 for linux-rockchip@lists.infradead.org; Fri, 19 Jan 2018 15:18:49 +0000 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 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> 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: Geert Uytterhoeven , linux-rockchip@lists.infradead.org, Linus Walleij , linux-gpio@vger.kernel.org, linux-tegra@vger.kernel.org, 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 --- 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);