From patchwork Fri Sep 8 12:21:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 9943797 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 7A375604D4 for ; Fri, 8 Sep 2017 12:22:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B06F286AB for ; Fri, 8 Sep 2017 12:22:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E6EE286C8; Fri, 8 Sep 2017 12:22:01 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31BF4286AB for ; Fri, 8 Sep 2017 12:22:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754965AbdIHMV7 (ORCPT ); Fri, 8 Sep 2017 08:21:59 -0400 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:46548 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754951AbdIHMV6 (ORCPT ); Fri, 8 Sep 2017 08:21:58 -0400 Received: from lanttu.localdomain (unknown [IPv6:2001:1bc8:1a6:d3d5::e1:1002]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id C0496600F4; Fri, 8 Sep 2017 15:21:56 +0300 (EEST) From: Sakari Ailus To: linux-pm@vger.kernel.org Cc: mika.westerberg@intel.com Subject: [PATCH 1/1] device property: Align return codes of acpi_fwnode_get_reference_with_args Date: Fri, 8 Sep 2017 15:21:56 +0300 Message-Id: <20170908122156.2493-1-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.11.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP acpi_fwnode_get_reference_with_args(), the function implementing ACPI support for fwnode_property_get_reference_with_args(), returns directly error codes from __acpi_node_get_property_reference(). The latter uses different error codes than the OF implementation. In particular, the OF implementation uses -ENOENT to indicate there are no more entries whereas the former uses -ENODATA for the purpose. To make matters more complicated, the ACPI implementation uses -ENOENT but for a different purpose --- when an entry exists but contains no reference. This isn't recognised by OF. Document and align the error codes for property for fwnode_property_get_reference_with_args() so that they match with of_parse_phandle_with_args(), with the difference that -ENODATA is returned whenever an entry exists but contains no reference. Fixes: 3e3119d3088f ("device property: Introduce fwnode_property_get_reference_args") Signed-off-by: Sakari Ailus --- drivers/acpi/property.c | 4 ++++ drivers/base/property.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index a65c09cc223f..17d760b89908 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -1207,6 +1207,10 @@ acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode, ret = __acpi_node_get_property_reference(fwnode, prop, index, args_count, &acpi_args); + if (ret == -ENODATA) + return -ENOENT; + if (ret == -ENOENT) + return -ENODATA; if (ret < 0) return ret; if (!args) diff --git a/drivers/base/property.c b/drivers/base/property.c index d0b65bbe7e15..686e48f3a617 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -682,6 +682,10 @@ EXPORT_SYMBOL_GPL(fwnode_property_match_string); * Caller is responsible to call fwnode_handle_put() on the returned * args->fwnode pointer. * + * Returns: %0 on success + * %-EINVAL on parse error + * %-ENODATA when an entry exists but contains no reference + * %-ENOENT when the index is out of bounds */ int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode, const char *prop, const char *nargs_prop,