Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1242075pxb; Wed, 10 Feb 2021 03:51:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJyD/d9spNCdiQYOSAtHrzn9An/kvFxUJVTa9qXoaPHwkBFvbk1Riw3x9WRxMA3h4zowclWt X-Received: by 2002:a17:906:2acf:: with SMTP id m15mr2571652eje.118.1612957903208; Wed, 10 Feb 2021 03:51:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612957903; cv=none; d=google.com; s=arc-20160816; b=plqemPIVI+E330ABAG9BTXk4mvrtQQ6XB9w/ym//HR47ZuUoGbzbqM2bYEK9fS/qIt QCpklbbjRJAwVzaEfoVA1ApINgxz0AQGBHBzCz93UaZX2hCGw2Pop9l5UdqpiQ/asGDp 3EWO5m6EFy8urxp9e7ZcW6WGNh0XF+5LtWtdpVVdl6PB6DwX7ju9MLpHKHSR5+BtIrA1 VBqvN/P+cHzR3xKiW9DHyho5GgoNJY5vz1g0ZRzJXJ0HV3AByUcC8cwP9Ycz/G+lY4Xm 4JixufiDezljDHVe5s79crYnBXWcje+GkDjod4oxtixN8kiMuCxGeru4bKCIK3GcXKy/ C25A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=iP6SfbUUnqJv8rSE7efBlg0z93chP966xROVsn/6p/Q=; b=Zm+qWj/nYq3apwFpaxKT/FqLfqf2D5ZaluG3+Hr1hA8MYLe2oLJ2yQxb67/5j2/nhZ 9nTbZowWFCqpwWPxx429BaiRtetDha5N07+R9k142j6OePItF8sx7LTQ/wN9mQCSd50l ORpAMBYA24UeLVhnDtuR2oLCEwG5kE2QL9OAhcddUQY/VShFJRcLmh7COBMIDNWBQsQy EELy6OoHw01WWDY9RZRYcsGYso0Swv5Y//H68URUNQTghl0Ba7VWMr+ecRH6PNNumZ5e wpGSXcXplr0bsHpmrkewuFKSfmQL4Rp71nSId0AXQHbWZRWjnwR8Ls6fGNBW1cTQbbs1 DZlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bx22si1193608edb.142.2021.02.10.03.51.19; Wed, 10 Feb 2021 03:51:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230161AbhBJLuN (ORCPT + 99 others); Wed, 10 Feb 2021 06:50:13 -0500 Received: from mga02.intel.com ([134.134.136.20]:64430 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230388AbhBJLpk (ORCPT ); Wed, 10 Feb 2021 06:45:40 -0500 IronPort-SDR: wSheto1sOsf4cVLgtdomFFgtfAe3a8Tg6kX3ts0pqY0nNi6j5Ip5Ivlyg4sEE4v3B0Qr1kK4Yf KmkvHIpb53wg== X-IronPort-AV: E=McAfee;i="6000,8403,9890"; a="169181911" X-IronPort-AV: E=Sophos;i="5.81,168,1610438400"; d="scan'208";a="169181911" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2021 03:43:34 -0800 IronPort-SDR: 1EEOWmLHG9eeh7iZ+/W2gJzwBCcl3cmva7DnQ3zFVjiueCBigrBqOO6PdDMNCgiP5ZazAIjcOv mkz29nzXwLew== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,168,1610438400"; d="scan'208";a="488729858" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 10 Feb 2021 03:43:33 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5FDF235E; Wed, 10 Feb 2021 13:43:32 +0200 (EET) From: Andy Shevchenko To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Rafael J. Wysocki" , Len Brown , Andy Shevchenko Subject: [PATCH v1 5/7] ACPI: property: Refactor acpi_data_prop_read_single() Date: Wed, 10 Feb 2021 13:43:18 +0200 Message-Id: <20210210114320.3478-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210114320.3478-1-andriy.shevchenko@linux.intel.com> References: <20210210114320.3478-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Refactor acpi_data_prop_read_single() for less LOCs and better maintenance. Signed-off-by: Andy Shevchenko --- drivers/acpi/property.c | 59 +++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 167338fe9b04..f2386ef32ff1 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -785,47 +785,44 @@ 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 (!val) return -EINVAL; - 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; - *(u8 *)val = obj->integer.value; - break; - case DEV_PROP_U16: - if (obj->integer.value > U16_MAX) - return -EOVERFLOW; - *(u16 *)val = obj->integer.value; - break; - case DEV_PROP_U32: - if (obj->integer.value > U32_MAX) - return -EOVERFLOW; - *(u32 *)val = obj->integer.value; - break; - default: - *(u64 *)val = obj->integer.value; - break; - } - } 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; + *(u8 *)val = obj->integer.value; + break; + case DEV_PROP_U16: + if (obj->integer.value > U16_MAX) + return -EOVERFLOW; + *(u16 *)val = obj->integer.value; + break; + case DEV_PROP_U32: + if (obj->integer.value > U32_MAX) + return -EOVERFLOW; + *(u32 *)val = obj->integer.value; + break; + case DEV_PROP_U64: + *(u64 *)val = obj->integer.value; + break; + case DEV_PROP_STRING: *(char **)val = obj->string.pointer; - return 1; - } else { - ret = -EINVAL; + default: + return -EINVAL; } + return ret; } -- 2.30.0