From patchwork Wed Aug 9 01:50:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 9889421 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 42BD4601EB for ; Wed, 9 Aug 2017 01:52:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3421E28908 for ; Wed, 9 Aug 2017 01:52:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28FF0289C0; Wed, 9 Aug 2017 01:52:34 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE 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 9F52D28908 for ; Wed, 9 Aug 2017 01:52:33 +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: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:In-Reply-To: References:List-Owner; bh=0j8rzEGE1ito0dWV6Dk6U/6nbiaBbmpPFmXH9eIrj30=; b=la/ LpAubbam9GXuLVYOSexZXQdTqKL9U5TCC/uXytcP3vwAoM7IHvMR91hj4uwS7bV2yY2nCQR1jPxdo mBEft+HdyFpST0Ak37xxll9C0KtS2m86LHBH7p6zt5wKgXoSWWgDY5VY7vJ31lW1/f8g5TfYK3+Hi ryR6WuDMBREdPFYBU9lpb9wBKI3qbUesO4AapTHjERu5BPvooAv67z0YSzYOySCcnEa3UlmYkm76v LPkFhR129wjycvsk24Xnjtlgy3hn0zVUT+irS5DHJpFxtfWTFfhnCZjxuVqakjy9VSHI61+RR8pAv DQbnHLfcuFhWhti5yTTsl5mdxCXEcgA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dfGAi-00036K-6q; Wed, 09 Aug 2017 01:52:32 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dfGAb-00033j-4r for linux-arm-kernel@lists.infradead.org; Wed, 09 Aug 2017 01:52:30 +0000 Received: from localhost.localdomain (unknown [106.187.91.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 51DF622B5D; Wed, 9 Aug 2017 01:52:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51DF622B5D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=shawnguo@kernel.org From: Shawn Guo To: Stephen Boyd , Michael Turquette Subject: [PATCH] clk: bulk: call of_clk_get() when id is NULL Date: Wed, 9 Aug 2017 09:50:42 +0800 Message-Id: <1502243442-28055-1-git-send-email-shawnguo@kernel.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170808_185225_211578_8E0974FF X-CRM114-Status: GOOD ( 10.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Aisheng , Shawn Guo , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Shawn Guo Most of clk API users have their clocks defined in device tree, and client drivers will have to parse clk ids from DT 'clock-names' property before using clk_bulk_get(). This is a burden for client driver code. And 'clock-names' being an optional DT property makes it even worse. The client driver will have no way to provide clock id. The patch makes a little improvement on clk_bulk_get() to call of_clk_get() with index for DT users, if clock id is not available, so that client drivers working with DT can use clk_bulk_get() to retrieve clocks more easily. Signed-off-by: Shawn Guo --- drivers/clk/clk-bulk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk-bulk.c b/drivers/clk/clk-bulk.c index c834f5abfc49..65cee595a67e 100644 --- a/drivers/clk/clk-bulk.c +++ b/drivers/clk/clk-bulk.c @@ -39,7 +39,10 @@ int __must_check clk_bulk_get(struct device *dev, int num_clks, clks[i].clk = NULL; for (i = 0; i < num_clks; i++) { - clks[i].clk = clk_get(dev, clks[i].id); + if (clks[i].id) + clks[i].clk = clk_get(dev, clks[i].id); + else if (dev->of_node) + clks[i].clk = of_clk_get(dev->of_node, i); if (IS_ERR(clks[i].clk)) { ret = PTR_ERR(clks[i].clk); dev_err(dev, "Failed to get clk '%s': %d\n",