From patchwork Sun Nov 29 13:15:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Bedel X-Patchwork-Id: 7718691 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E4253BEEE1 for ; Sun, 29 Nov 2015 13:19:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 328D920562 for ; Sun, 29 Nov 2015 13:19:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 658A920561 for ; Sun, 29 Nov 2015 13:19:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a31qc-0005iA-Br; Sun, 29 Nov 2015 13:16:58 +0000 Received: from smtp2-g21.free.fr ([212.27.42.2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a31qY-0005ev-LI for linux-arm-kernel@lists.infradead.org; Sun, 29 Nov 2015 13:16:55 +0000 Received: from localhost.localdomain (unknown [78.54.102.0]) (Authenticated sender: albeu) by smtp2-g21.free.fr (Postfix) with ESMTPA id 488B04B0081; Sun, 29 Nov 2015 14:15:47 +0100 (CET) From: Alban Bedel To: linux-kernel@vger.kernel.org Subject: [PATCH] clkdev: Fix of_clk_get_by_name() for consistent return values Date: Sun, 29 Nov 2015 14:15:09 +0100 Message-Id: <1448802909-8490-1-git-send-email-albeu@free.fr> X-Mailer: git-send-email 2.0.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151129_051654_879153_219C84C8 X-CRM114-Status: UNSURE ( 9.75 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Russell King , Alban Bedel , 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When of_clk_get_by_name() is called without name it returns -ENOENT when the 'clocks' property doesn't exists or is an empty entry. However when a name is given and the 'clock-names' property doesn't exists or doesn't contains the requested name it returns -EINVAL. To get a consistent return value with both code paths we must return -ENOENT when of_property_match_string() fails. Signed-off-by: Alban Bedel --- drivers/clk/clkdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 779b6ff..99a8803 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -72,7 +72,10 @@ static struct clk *__of_clk_get_by_name(struct device_node *np, */ if (name) index = of_property_match_string(np, "clock-names", name); - clk = __of_clk_get(np, index, dev_id, name); + if (index >= 0) + clk = __of_clk_get(np, index, dev_id, name); + else + clk = ERR_PTR(-ENOENT); if (!IS_ERR(clk)) { break; } else if (name && index >= 0) {