Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1409472pxb; Wed, 10 Feb 2021 07:47:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQpBM3YGNNFliMFgJeNQE4zZdQ5MoIxVSM++v4PJt0ovGv/685nEToFmSmOswJ72GLz1c4 X-Received: by 2002:a05:6402:306c:: with SMTP id bs12mr3683052edb.348.1612972023471; Wed, 10 Feb 2021 07:47:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612972023; cv=none; d=google.com; s=arc-20160816; b=LXpQgbXCq1Np9AdSQVlyyy0LNrdmN32ejRJFJutUGOV8yXD5qwkY1ExfDp0FS7yyRd GNoxlXrQSk20wqp5VDg9Jyt0ywQY5eGvrWxFA/inVQ3g4bXkPmlTKVTRl5h234mj90zi pmQAElS4JRsWsJ88VZdOf7r4aUNT1vMIq1NYfHX0qMJYJ33/bM9y0L6BHKwaxPDDiSKf mR5ijMsO649AcTjnp9uE74xyZ5j+8njY2HZoaMa53avKurRVRdLUfgexnqQX1bmHBUV2 4L4hn1SfrPI5WGe3Ywvf8H1mxbDrPUvdIlk6ecv6zKiQeIditwZxAsHvt9QVZQ5Eb50q 4yDQ== 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=j3IPwBT8xxvQKPsxmgcOMrR2P9ZRaO11bj6/TdKvl14=; b=x5V0CRirXFFEAQu450ByenbgS+hhyoxJyuX6/9LvXkepzGZbWxlTQT2/DOaYIRVDVL 7eW+OU4ejiMBrvSJeph3xkUiZTsbQneNZ7gTD/IQr1Dsal0sxSc48AI8Rwj/k7K69cKJ tlgrLJY9aTtvzVhbeCFsMtak2agXlEfUfKFOWr8txfwSTae3SwcYNZFCD2tu4sFREIc/ gz/msjwvb9feae4nckkK15wd6RS73vAySXa8alUNrfrx9fAGDIdk4yRBtiJDYktF8Xv5 o/ddtUHGeD0qV6Qk4V6uNmkQWAGpXXvSrw7LIxELzuyalqRImtiIcGRvy2xhE0/U68/h lchw== 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 j22si1462224edh.496.2021.02.10.07.46.39; Wed, 10 Feb 2021 07:47:03 -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 S231801AbhBJPpa (ORCPT + 99 others); Wed, 10 Feb 2021 10:45:30 -0500 Received: from mail-oi1-f177.google.com ([209.85.167.177]:44753 "EHLO mail-oi1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231744AbhBJPp0 (ORCPT ); Wed, 10 Feb 2021 10:45:26 -0500 Received: by mail-oi1-f177.google.com with SMTP id r75so2447756oie.11; Wed, 10 Feb 2021 07:45:10 -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=j3IPwBT8xxvQKPsxmgcOMrR2P9ZRaO11bj6/TdKvl14=; b=ri7vQIgBlBoYJFTpvEilEbgGpEJAJfgX4hZfJjFPeHnVr/wWRkMvT25Z0vp0UrIssz JXfpIa3vJIbmd58Hd2aDp7kdAZoHqzJgZQJ1T9ZGfNqL/ieM24WlfKMJyPjjrrdm0/ct 3+KSoGgmsEiRp3SAHHm/vHEpoulF8DIIuoNrC/KHFyPzbxQTs8wh+nXnWFX1UFwYedNY hZATs+mslT3JjpjEsSraWz8+o0+3LHAXpxNhqhU5cN8QEPeLTbMbLKTMc3JTbG4wER5T vkKDYmxuzkJJEqv5rA2Wg6d4jcXNA0CWgnFam0AKQSkt8OXa4fgmA4sWuxJL6v1oZuop lrdA== X-Gm-Message-State: AOAM533OtLOjLV0PPobEWtS+9LK9hPOQ6RmGtqlAnn4yf1h1UzhUQR/S ySCda5HOaoy9oVn1ML8k/2+nYksAQNTF9/bSeAk= X-Received: by 2002:a54:400b:: with SMTP id x11mr2548700oie.71.1612971885498; Wed, 10 Feb 2021 07:44:45 -0800 (PST) MIME-Version: 1.0 References: <20210210114320.3478-1-andriy.shevchenko@linux.intel.com> <3881654.NPl3a4M0kB@kreacher> <1946478.1QpZic6vku@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Wed, 10 Feb 2021 16:44:34 +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: "Rafael J. Wysocki" , "Rafael J. Wysocki" , ACPI Devel Maling List , Linux Kernel Mailing List , 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 4:42 PM Andy Shevchenko wrote: > > On Wed, Feb 10, 2021 at 04:01:16PM +0100, Rafael J. Wysocki wrote: > > On Wed, Feb 10, 2021 at 3:48 PM Andy Shevchenko > > wrote: > > > On Wed, Feb 10, 2021 at 02:48:09PM +0100, Rafael J. Wysocki wrote: > > > > On Wednesday, February 10, 2021 2:31:48 PM CET Rafael J. Wysocki wrote: > > > > > On Wednesday, February 10, 2021 1:36:00 PM CET Rafael J. Wysocki wrote: > > > > > > On Wed, Feb 10, 2021 at 12:51 PM Andy Shevchenko > > > > > > wrote: > > ... > > > > > > > > - 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. > > > > > > Nope. That's why it's a patch 7. Patch 6 solves this. > > > > That's my point. Patch 7 should be the first one in the series. > > Ah, okay. Since you want this let me rebase. Thanks! > > > > > > > if (ret >= 0) > > > > > > > - return ret; > > > > > > > + return val ? ret : 1; > > > > > > > > > > > > So val cannot be NULL here. > > > > > > Why not? I have changed conditional. > > > > > > > > > > } > > > > > > > > > To me, acpi_fwnode_property_read_string_array() needs to special-case > > > > > > val == NULL and nval == 0. > > > > > > nval can be anything in the case of val==NULL. So far neither of your proposals > > > conform this. > > > > That is if !val and nval != 0 is regarded as a valid combination of > > arguments, but is it? > > I believe nobody tested that. > > > If that is the case, the check in acpi_data_prop_read() in the last > > patch that I posted needs to be (!val || nval == 1), but that would be > > it, no? > > I think it also needs the conditional at return as in my patch. I'm not sure why. acpi_data_prop_read_single() would return 1 for !val if it finds the property with a single value and that should be sufficient, shouldn't it?