From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753264AbbIAP2j (ORCPT ); Tue, 1 Sep 2015 11:28:39 -0400 Received: from smtp2-g21.free.fr ([212.27.42.2]:37912 "EHLO smtp2-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751901AbbIAP2i (ORCPT ); Tue, 1 Sep 2015 11:28:38 -0400 From: Alban Bedel To: Philipp Zabel Cc: linux-kernel@vger.kernel.org, Alban Bedel Subject: [PATCH] reset: Fix of_reset_control_get() for consistent return values Date: Tue, 1 Sep 2015 17:28:31 +0200 Message-Id: <1441121311-31628-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 When of_reset_control_get() is called without connection ID it returns -ENOENT when the 'resets' property doesn't exists or is an empty entry. However when a connection ID is given it returns -EINVAL when the 'resets' property doesn't exists or the requested name can't be found. This is because the error code returned by of_property_match_string() is just passed down as an index to of_parse_phandle_with_args(), which then 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/reset/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/reset/core.c b/drivers/reset/core.c index 3cbc764..fd6ac9b 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c @@ -265,9 +265,12 @@ struct reset_control *of_reset_control_get(struct device_node *node, int rstc_id; int ret; - if (id) + if (id) { index = of_property_match_string(node, "reset-names", id); + if (index < 0) + return ERR_PTR(-ENOENT); + } ret = of_parse_phandle_with_args(node, "resets", "#reset-cells", index, &args); if (ret) -- 2.0.0