From patchwork Fri Feb 12 14:11:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 381896 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44C1AC433E0 for ; Fri, 12 Feb 2021 14:16:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1679964E3D for ; Fri, 12 Feb 2021 14:16:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231622AbhBLOQK (ORCPT ); Fri, 12 Feb 2021 09:16:10 -0500 Received: from mga07.intel.com ([134.134.136.100]:44203 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231571AbhBLOQJ (ORCPT ); Fri, 12 Feb 2021 09:16:09 -0500 IronPort-SDR: vkN1Yn4D1SP2TQwRaKUt/HpTc0fhwgnOM4VlfqQsYtiPoNfvCPKgGT6msQhA3UoweVRe+kubCW WAVcyrcPWSaw== X-IronPort-AV: E=McAfee;i="6000,8403,9892"; a="246483866" X-IronPort-AV: E=Sophos;i="5.81,173,1610438400"; d="scan'208";a="246483866" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2021 06:11:37 -0800 IronPort-SDR: Vnbi98rWZkRC5kJFiofmHLLfUjTgbAT93qCiMWpT+49pc/1njkt/Cy+CxapPOw1FqsC6NJyYfw vM7FGNIhVd0Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,173,1610438400"; d="scan'208";a="360386122" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 12 Feb 2021 06:11:36 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 87D161FA; Fri, 12 Feb 2021 16:11:34 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Rafael J. Wysocki" , Len Brown Subject: [PATCH v2 1/5] ACPI: property: Remove dead code Date: Fri, 12 Feb 2021 16:11:17 +0200 Message-Id: <20210212141121.62115-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org After the commit 3a7a2ab839ad couple of functions became a dead code. Moreover, for all these years nobody used them. Remove. Fixes: 3a7a2ab839ad ("ACPI / property: Extend fwnode_property_* to data-only subnodes") Signed-off-by: Andy Shevchenko --- drivers/acpi/property.c | 20 -------------------- include/linux/acpi.h | 21 --------------------- 2 files changed, 41 deletions(-) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 16b28084c1ca..22ccab4e7c6d 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -841,20 +841,6 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data, return ret; } -int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname, - enum dev_prop_type proptype, void *val) -{ - int ret; - - if (!adev || !val) - return -EINVAL; - - ret = acpi_data_prop_read_single(&adev->data, propname, proptype, val); - if (ret < 0 || proptype != ACPI_TYPE_STRING) - return ret; - return 0; -} - static int acpi_copy_property_array_u8(const union acpi_object *items, u8 *val, size_t nval) { @@ -995,12 +981,6 @@ static int acpi_data_prop_read(const struct acpi_device_data *data, return ret; } -int acpi_dev_prop_read(const struct acpi_device *adev, const char *propname, - enum dev_prop_type proptype, void *val, size_t nval) -{ - return adev ? acpi_data_prop_read(&adev->data, propname, proptype, val, nval) : -EINVAL; -} - /** * acpi_node_prop_read - retrieve the value of an ACPI property with given name. * @fwnode: Firmware node to get the property from. diff --git a/include/linux/acpi.h b/include/linux/acpi.h index ea296289a94c..14ac25165ae1 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1121,14 +1121,9 @@ acpi_data_add_props(struct acpi_device_data *data, const guid_t *guid, int acpi_node_prop_get(const struct fwnode_handle *fwnode, const char *propname, void **valptr); -int acpi_dev_prop_read_single(struct acpi_device *adev, - const char *propname, enum dev_prop_type proptype, - void *val); int acpi_node_prop_read(const struct fwnode_handle *fwnode, const char *propname, enum dev_prop_type proptype, void *val, size_t nval); -int acpi_dev_prop_read(const struct acpi_device *adev, const char *propname, - enum dev_prop_type proptype, void *val, size_t nval); struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode, struct fwnode_handle *child); @@ -1230,14 +1225,6 @@ static inline int acpi_node_prop_get(const struct fwnode_handle *fwnode, return -ENXIO; } -static inline int acpi_dev_prop_read_single(const struct acpi_device *adev, - const char *propname, - enum dev_prop_type proptype, - void *val) -{ - return -ENXIO; -} - static inline int acpi_node_prop_read(const struct fwnode_handle *fwnode, const char *propname, enum dev_prop_type proptype, @@ -1246,14 +1233,6 @@ static inline int acpi_node_prop_read(const struct fwnode_handle *fwnode, return -ENXIO; } -static inline int acpi_dev_prop_read(const struct acpi_device *adev, - const char *propname, - enum dev_prop_type proptype, - void *val, size_t nval) -{ - return -ENXIO; -} - static inline struct fwnode_handle * acpi_get_next_subnode(const struct fwnode_handle *fwnode, struct fwnode_handle *child) From patchwork Fri Feb 12 14:11:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 381897 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21650C433E0 for ; Fri, 12 Feb 2021 14:14:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ECC7564E6C for ; Fri, 12 Feb 2021 14:14:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231842AbhBLOOY (ORCPT ); Fri, 12 Feb 2021 09:14:24 -0500 Received: from mga07.intel.com ([134.134.136.100]:44070 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231940AbhBLOOH (ORCPT ); Fri, 12 Feb 2021 09:14:07 -0500 IronPort-SDR: JJcxaZJOXb/1c2UFZvjyMewnRB79iOAL1gKXcj0q6484UFjWhUS6vt9qDDiOZOfZyzBGPWv6AD ya4cv/br1Z4w== X-IronPort-AV: E=McAfee;i="6000,8403,9892"; a="246483854" X-IronPort-AV: E=Sophos;i="5.81,173,1610438400"; d="scan'208";a="246483854" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2021 06:11:36 -0800 IronPort-SDR: sAy79xcTxwAb2fsnOOT57eigZ/hCy3V6uK5MaCAOcBJtB1iXPwkaSFFZQYpXVUSOhwA/+dDEoP YrxAiTFZSMCw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,173,1610438400"; d="scan'208";a="437596732" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 12 Feb 2021 06:11:35 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id B46954BE; Fri, 12 Feb 2021 16:11:34 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Rafael J. Wysocki" , Len Brown Subject: [PATCH v2 5/5] ACPI: property: Refactor acpi_data_prop_read_single() Date: Fri, 12 Feb 2021 16:11:21 +0200 Message-Id: <20210212141121.62115-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210212141121.62115-1-andriy.shevchenko@linux.intel.com> References: <20210212141121.62115-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Refactor acpi_data_prop_read_single() for less LOCs and better maintenance. Signed-off-by: Andy Shevchenko --- drivers/acpi/property.c | 80 ++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 46 deletions(-) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index e312ebaed8db..494cf283a573 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -785,60 +785,48 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data, enum dev_prop_type proptype, void *val) { const union acpi_object *obj; - int ret; + int ret = 0; - if (proptype >= DEV_PROP_U8 && proptype <= DEV_PROP_U64) { + if (proptype >= DEV_PROP_U8 && proptype <= DEV_PROP_U64) ret = acpi_data_get_property(data, propname, ACPI_TYPE_INTEGER, &obj); - if (ret) - return ret; - - switch (proptype) { - case DEV_PROP_U8: - if (obj->integer.value > U8_MAX) - return -EOVERFLOW; - - if (val) - *(u8 *)val = obj->integer.value; - - break; - case DEV_PROP_U16: - if (obj->integer.value > U16_MAX) - return -EOVERFLOW; - - if (val) - *(u16 *)val = obj->integer.value; - - break; - case DEV_PROP_U32: - if (obj->integer.value > U32_MAX) - return -EOVERFLOW; - - if (val) - *(u32 *)val = obj->integer.value; - - break; - default: - if (val) - *(u64 *)val = obj->integer.value; - - break; - } - - if (!val) - return 1; - } else if (proptype == DEV_PROP_STRING) { + else if (proptype == DEV_PROP_STRING) ret = acpi_data_get_property(data, propname, ACPI_TYPE_STRING, &obj); - if (ret) - return ret; + if (ret) + return ret; + switch (proptype) { + case DEV_PROP_U8: + if (obj->integer.value > U8_MAX) + return -EOVERFLOW; + if (val) + *(u8 *)val = obj->integer.value; + break; + case DEV_PROP_U16: + if (obj->integer.value > U16_MAX) + return -EOVERFLOW; + if (val) + *(u16 *)val = obj->integer.value; + break; + case DEV_PROP_U32: + if (obj->integer.value > U32_MAX) + return -EOVERFLOW; + if (val) + *(u32 *)val = obj->integer.value; + break; + case DEV_PROP_U64: + if (val) + *(u64 *)val = obj->integer.value; + break; + case DEV_PROP_STRING: if (val) *(char **)val = obj->string.pointer; - return 1; - } else { - ret = -EINVAL; + default: + return -EINVAL; } - return ret; + + /* When no storage provided return number of available values */ + return val ? 0 : 1; } static int acpi_copy_property_array_u8(const union acpi_object *items, u8 *val,