Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1243915pxb; Wed, 10 Feb 2021 03:55:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyRr4ztnGAOCFSmEhySZZEwzklYxC99HclhlcqhcSTlDdjCxL3PgM5gwG/d9scAfZxFyWwO X-Received: by 2002:a05:6402:1c0f:: with SMTP id ck15mr2702952edb.16.1612958137707; Wed, 10 Feb 2021 03:55:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612958137; cv=none; d=google.com; s=arc-20160816; b=AL1Ioetxhahsun9l6M9Z2i3aVjVnVcc4gMpmah1MRfvAsJu7cFqF+3wGDazXLzym08 w28dfRWrB2ZnCLgi+Z3VU/d2B8dVdYlSxp3o85ZG4M75uq8uGrHSPLjcNaTpa1ZJJ1Gq xgBPtbmhqJ1pCHwiaJRkfyuBZ5EJBQqLIQcfqiRBFR40gnm91yJuvWAoPwQJFF+GoFts UvljvrRDR/uXItfZhwVV2MexJtD922+VrrlYR3uOA8i/SA8eko+s2iWtQ+Xl+6cokWrC lM5f9w43kvYJedPKaRL0adocFrPK+KJn84TugojmqUTDc9oWZvPRSDUgUgzkRu3EaGi+ ht/w== 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=mdmoR8ZzlSNm9OciO2ATixwOAZsucpl37vd/fbpIed0=; b=nqZhSotiYxlCPkBXoAfoiFLjeJjlpULGvQKxe+6IQSxQP5lnE8zSbNYWKGa/DUxxA5 6I4DelS2hx6wepQZhkGcvao/Dr+YL14OqZRcrEDEF0L2sRSIVbhWwzXA0dJfGw2xMSXx Gc6N9d1B08SrSXizyhigoWNyM9jb0IDYEjsDEtrkjCbYe1HwSuyvcLLSnZpHnhnhUwQT q9Q53YRCKWD32Z6+S80qRgw24RSSSECZDHnTcVCdUaT5bNG0WZtULxuy7YN9NhFyXD+6 2QxoXQsP/FifVOvL3XJsbHGhmtMeGt/AlPloBTVVk4xB/yk7K2GJSyv2kac1NqyCa9FY DwmA== 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 d19si1191725edt.189.2021.02.10.03.55.14; Wed, 10 Feb 2021 03:55:37 -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 S230315AbhBJLyo (ORCPT + 99 others); Wed, 10 Feb 2021 06:54:44 -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 S230412AbhBJLtB (ORCPT ); Wed, 10 Feb 2021 06:49:01 -0500 IronPort-SDR: SSi05y+sTmDcrqvLKPVbUwy0FDgO97qkKbu+fLxx+EMnPUfI+8F2xbkBx+eGsWLn5aMMO1G8nq eRAKblJNDHgg== X-IronPort-AV: E=McAfee;i="6000,8403,9890"; a="169181917" X-IronPort-AV: E=Sophos;i="5.81,168,1610438400"; d="scan'208";a="169181917" 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:36 -0800 IronPort-SDR: vsAvMH9/oRNgKCElQhKCw64FRSzP8p8ckNi6QPc3GTgVrLW0AKEOMExsh94BJpuvuHS/1LhcvH Am/cYDa4ZyYg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,168,1610438400"; d="scan'208";a="488729862" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 10 Feb 2021 03:43:35 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 71064525; 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 , Calvin Johnson Subject: [PATCH v1 7/7] ACPI: property: Allow counting a single value as an array of 1 element Date: Wed, 10 Feb 2021 13:43:20 +0200 Message-Id: <20210210114320.3478-7-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 We allow to read the single value as a first element in the array. Unfortunately the counting doesn't work in this case and we can't call fwnode_property_count_*() API without getting an error. Modify acpi_data_prop_read() to always try the single value read and thus allow counting the single value as an array of 1 element. Reported-by: Calvin Johnson Signed-off-by: Andy Shevchenko --- drivers/acpi/property.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 236316ee0e25..d6100585fceb 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -913,12 +913,14 @@ static int acpi_data_prop_read(const struct acpi_device_data *data, const union acpi_object *items; int ret; - if (val && nval == 1) { + /* Try to read as a single value first */ + if (!val || nval == 1) { ret = acpi_data_prop_read_single(data, propname, proptype, val); if (ret >= 0) - return ret; + return val ? ret : 1; } + /* It's not the single value, get an array instead */ ret = acpi_data_get_property_array(data, propname, ACPI_TYPE_ANY, &obj); if (ret) return ret; -- 2.30.0