Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1279334 > unrolled thread

[PATCH] clkdev: Fix of_clk_get_by_name() for consistent return values

Started byAlban Bedel <albeu@free.fr>
First post2015-11-29 14:20 +0100
Last post2015-11-29 14:20 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] clkdev: Fix of_clk_get_by_name() for consistent return values Alban Bedel <albeu@free.fr> - 2015-11-29 14:20 +0100

#1279334 — [PATCH] clkdev: Fix of_clk_get_by_name() for consistent return values

FromAlban Bedel <albeu@free.fr>
Date2015-11-29 14:20 +0100
Subject[PATCH] clkdev: Fix of_clk_get_by_name() for consistent return values
Message-ID<qAa3w-6CS-19@gated-at.bofh.it>
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 <albeu@free.fr>
---
 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/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web