Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752880AbbK2NRE (ORCPT ); Sun, 29 Nov 2015 08:17:04 -0500 Received: from smtp2-g21.free.fr ([212.27.42.2]:64497 "EHLO smtp2-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752795AbbK2NQc (ORCPT ); Sun, 29 Nov 2015 08:16:32 -0500 From: Alban Bedel To: linux-kernel@vger.kernel.org Cc: Alban Bedel , Russell King , linux-arm-kernel@lists.infradead.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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1297 Lines: 37 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) { -- 2.0.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/