From patchwork Thu Oct 5 06:04:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 9986445 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 EA1B3602B8 for ; Thu, 5 Oct 2017 06:04:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3790223C7 for ; Thu, 5 Oct 2017 06:04:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C71A1267EC; Thu, 5 Oct 2017 06:04:28 +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 AB30F223C7 for ; Thu, 5 Oct 2017 06:04:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751221AbdJEGE1 (ORCPT ); Thu, 5 Oct 2017 02:04:27 -0400 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:44726 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750860AbdJEGE0 (ORCPT ); Thu, 5 Oct 2017 02:04:26 -0400 Received: from lanttu.localdomain (unknown [IPv6:2001:1bc8:1a6:d3d5::e1:1002]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id 861B2600D8; Thu, 5 Oct 2017 09:04:24 +0300 (EEST) From: Sakari Ailus To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, mika.westerberg@intel.com, hyungwoo.yang@intel.com Subject: [PATCH 1/1] device properties: Fix return codes for __acpi_node_get_property_reference Date: Thu, 5 Oct 2017 09:04:24 +0300 Message-Id: <20171005060424.16780-1-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.11.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix more return codes for device property: Align return codes of __acpi_node_get_property_reference. In particular what was missed previously: -EPROTO could be returned in certain cases, now -EINVAL; -EINVAL was returned if the property was not found, now -ENOENT; -EINVAL was returned also if the index was higher than the number of entries in a package, now -ENOENT. Fixes: ("device property: Align return codes of __acpi_node_get_property_reference") Signed-off-by: Sakari Ailus Tested-by: Hyungwoo Yang --- Hi Rafael, Unfortunately the patch I posted the previous time to remedy the issue ("device property: Align return codes of _acpi_node_get_property_reference") did not fully fix the issue. drivers/acpi/property.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 5a8ac5e1081b..8c28c516e7ec 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -592,8 +592,16 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, return -ENOENT; ret = acpi_data_get_property(data, propname, ACPI_TYPE_ANY, &obj); - if (ret) - return ret; + switch (ret) { + case -EINVAL: + return -ENOENT; + case -EPROTO: + return -EINVAL; + default: + if (ret) + return ret; + break; + } /* * The simplest case is when the value is a single reference. Just @@ -605,7 +613,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, ret = acpi_bus_get_device(obj->reference.handle, &device); if (ret) - return ret; + return ret == -ENODEV ? -EINVAL : ret; args->adev = device; args->nargs = 0; @@ -621,8 +629,10 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, * The index argument is then used to determine which reference * the caller wants (along with the arguments). */ - if (obj->type != ACPI_TYPE_PACKAGE || index >= obj->package.count) - return -EPROTO; + if (obj->type != ACPI_TYPE_PACKAGE) + return -EINVAL; + if (index >= obj->package.count) + return -ENOENT; element = obj->package.elements; end = element + obj->package.count;