Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1273506pxb; Wed, 10 Feb 2021 04:42:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwiwj00oZm9+6miBwAWaWnDH1KT/NzF9aJiQfHpwYJhxjXlmJ4jVql/O9gpdTMhHR48nABV X-Received: by 2002:a05:6402:215:: with SMTP id t21mr2970213edv.363.1612960961816; Wed, 10 Feb 2021 04:42:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612960961; cv=none; d=google.com; s=arc-20160816; b=y5/yZ4lQnh5rgR/UPJu7V44vWIlBQcm7+qHGwvKguX9JuV9a5GJI13EfcuR1SDQcGg M8yIC5sYpsgRnHWcmkh28jGKUDSb2g5FQEG5NtElBX/5exfREUJRggH6z8S10aW00Tpj PUN/JuOsYKUfKPeSjHP3JmJ1+voiISo86kT44jruhn9oCiZfoeGsgnluyZVyFnb1UEZz wE6XH0wOCeqrDaAKYxAqDkOoso2nahcrpTTzhOQ75p3VSfhbNrUZ35jrAu60SlRcFtmW l1bpQcOCRorfkJBglxiBlLhplmgu3Nvh59Y3lWcztJMRo4e3uSpIXr2UoBkTOQ3hEdFo Nxxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=noDcsWaRDbhoMOrwm+bLWYK4ZXNDvbSi80w2AVwrvj8=; b=n1BEoszH6zLcrLiy0byQf1c5Em/nbzZiYR0y1VJ9Amf9+bm2CWu+UuEjCK5aAqkcn5 To/xVcDb3Fjbzo+3r0YzkCsKRKywmFpMPQDlbA5BlO3iX/tsYhO/TchK0rMfis/rhqdO F9Dj9PyPWiZVUTIXZEDG5YkpwFG++FgVPSF5ZrCXF2gsBwzK3pJOyELu8zuziDK6kCkZ pK7TN94wAHBKDJgec1xL1ibVFjZZoW9qpILg7phheM6PX3/IJD6ScKjBIbDQB8hC0xP3 BUI3kvjs6hVz3OMdKMeUiocMnliadObeFpn/vZ1jRqQE0fCnYH/e4nyGIhAECi65tf5P afJQ== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q23si58873edb.260.2021.02.10.04.42.18; Wed, 10 Feb 2021 04:42:41 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231706AbhBJMjZ (ORCPT + 99 others); Wed, 10 Feb 2021 07:39:25 -0500 Received: from mail-oi1-f179.google.com ([209.85.167.179]:34741 "EHLO mail-oi1-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230119AbhBJMgy (ORCPT ); Wed, 10 Feb 2021 07:36:54 -0500 Received: by mail-oi1-f179.google.com with SMTP id i3so1828282oif.1; Wed, 10 Feb 2021 04:36:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=noDcsWaRDbhoMOrwm+bLWYK4ZXNDvbSi80w2AVwrvj8=; b=GQinjsUhzoi4vx50jO8K8NhIP79Lkglp+lJoXnVc6K8HfHCoAe4hMr66ZuERXDVUFs A+dvYOvppxt3wmXG+wPeUXfkmbKF2vN+tlLcCWSDeL31FmkBRxAT/NJRiU6zFMr8E33G TLPg9nWM1ZesbuQY5B/SVHMjH6XdYc/TNFi5VWP/bF2z+XQARkoafVHZlSDMfRx5xneK uOdGezXS7uCTj+/UOsu9RGvSR7OO1kHd2bJ62+Qdloe3bhXXD5lIW9Hho7lLafJEANpI cOGkWIwDYH+pWQU7eoasBEWt8cRhJaLUKXjJEsfgeftZWEh8+cE9gHm6oWRsXTpIKwJb kQvw== X-Gm-Message-State: AOAM531M4zdsBVXO5EOFJeOTlXu0oURVEYFGurtkbnhGtsRBuMmVE66y 85f8dTfLR1bLum/k/okI2SzNzvWrBbEU7FIU4KU= X-Received: by 2002:aca:3d85:: with SMTP id k127mr1966585oia.157.1612960573735; Wed, 10 Feb 2021 04:36:13 -0800 (PST) MIME-Version: 1.0 References: <20210210114320.3478-1-andriy.shevchenko@linux.intel.com> <20210210114320.3478-7-andriy.shevchenko@linux.intel.com> In-Reply-To: <20210210114320.3478-7-andriy.shevchenko@linux.intel.com> From: "Rafael J. Wysocki" Date: Wed, 10 Feb 2021 13:36:00 +0100 Message-ID: Subject: Re: [PATCH v1 7/7] ACPI: property: Allow counting a single value as an array of 1 element To: Andy Shevchenko Cc: ACPI Devel Maling List , Linux Kernel Mailing List , "Rafael J. Wysocki" , Len Brown , Calvin Johnson Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 10, 2021 at 12:51 PM Andy Shevchenko wrote: > > 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. It would be good to mention what the symptom of the issue is here. > 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 This is a bug fix, so it should go in before the cleanups in this series IMO. Also it looks like stable@vger material. > --- > 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); This returns -EINVAL if val is NULL. > if (ret >= 0) > - return ret; > + return val ? ret : 1; So val cannot be NULL here. > } > > + /* 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; > -- To me, acpi_fwnode_property_read_string_array() needs to special-case val == NULL and nval == 0.