From nobody Wed May  7 09:33:15 2025
Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4367B239095;
	Wed,  2 Apr 2025 12:23:09 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
 arc=none smtp.client-ip=198.175.65.21
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1743596590; cv=none;
 b=J77P0+Z2uxzKJM/nh5Ib/7KDQdL24Xbec1HMbxgGcDYk/TozhypDAyZT0gf3qyDWou2kqVaHdNZnrY380EQLR/WATxqdlmI82jsNMIXFMUMoU9dpEegQoRf7QGb7aOcJhklR3cYT1jeDFiuu3EXdrxt1Ief0RwO+wxmlyhp2PDY=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1743596590; c=relaxed/simple;
	bh=JzZ2zxRH5WzmArsIBFNmyYfJ/ZT+m/rFHFyi90jX0UY=;
	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version;
 b=AgETIDxCqdEnwrypN9/75XFXEh0bria/94o/GDBrfVtMcKL6wnlbt86z78GwywZsXn0Q3lV0BmDRP0v86THjjkUhMGY//ioSFMbbK+VzDYFmZKB263GXn5EQVjRM5hK3i77+R8B6I0SOtpVcS9nxbAZK7wewOH+gG+WCJcEW7f0=
ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
 dmarc=pass (p=none dis=none) header.from=linux.intel.com;
 spf=none smtp.mailfrom=linux.intel.com;
 dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com
 header.b=eXcRNqjA; arc=none smtp.client-ip=198.175.65.21
Authentication-Results: smtp.subspace.kernel.org;
 dmarc=pass (p=none dis=none) header.from=linux.intel.com
Authentication-Results: smtp.subspace.kernel.org;
 spf=none smtp.mailfrom=linux.intel.com
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com
 header.b="eXcRNqjA"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
  t=1743596590; x=1775132590;
  h=from:to:cc:subject:date:message-id:in-reply-to:
   references:mime-version:content-transfer-encoding;
  bh=JzZ2zxRH5WzmArsIBFNmyYfJ/ZT+m/rFHFyi90jX0UY=;
  b=eXcRNqjAOE7PBVnqMzZix37UGPFAhlvMY9hwa0ui59ThGeTb0jBIuW41
   dQpO8YEN1r+gMVB8TCR16/FYEFrom0OTPbP3WQ2d+3sjsoNaE1onq0llI
   LvYQkKPjHY+qA6EvPS6Jj23fx606vQW6jfP4ktvEh9CqmcgkQVGeZxsog
   yFtJf186fXYT5nP+DWDfnIKtLZEvDIzVdf+y7ICg3Qz+Ir5ym/KyNNnpR
   axPOF4LdidSlyBGVkoV9M8wTrO3hImUQVVjAyx92hwMYXoAifRaqxvYzi
   +rZyz+5B1+y85DECsPlMR0UEXtFEn+tRdGH+IPTzO2OasRN3zUjhOzul2
   Q==;
X-CSE-ConnectionGUID: NzjHj0TfS8e+9Cv3W/Tibw==
X-CSE-MsgGUID: AUz1hHEcQK6zOE9NFSITqw==
X-IronPort-AV: E=McAfee;i="6700,10204,11392"; a="44865032"
X-IronPort-AV: E=Sophos;i="6.15,182,1739865600";
   d="scan'208";a="44865032"
Received: from orviesa002.jf.intel.com ([10.64.159.142])
  by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 02 Apr 2025 05:23:07 -0700
X-CSE-ConnectionGUID: sh1aI/qYRe2QoO6yG4DGvQ==
X-CSE-MsgGUID: EQSyEldZQceIM0wjM5VOyg==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.15,182,1739865600";
   d="scan'208";a="157635535"
Received: from black.fi.intel.com ([10.237.72.28])
  by orviesa002.jf.intel.com with ESMTP; 02 Apr 2025 05:23:05 -0700
Received: by black.fi.intel.com (Postfix, from userid 1003)
	id 474E915C; Wed, 02 Apr 2025 15:23:03 +0300 (EEST)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
	linux-gpio@vger.kernel.org,
	linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Mika Westerberg <westeri@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>
Subject: [PATCH v1 1/5] gpiolib: acpi: Improve struct acpi_gpio_info memory
 footprint
Date: Wed,  2 Apr 2025 15:21:16 +0300
Message-ID: <20250402122301.1517463-2-andriy.shevchenko@linux.intel.com>
X-Mailer: git-send-email 2.47.2
In-Reply-To: <20250402122301.1517463-1-andriy.shevchenko@linux.intel.com>
References: <20250402122301.1517463-1-andriy.shevchenko@linux.intel.com>
Precedence: bulk
X-Mailing-List: linux-kernel@vger.kernel.org
List-Id: <linux-kernel.vger.kernel.org>
List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8"

The struct acpi_gpio_info has two boolean members that are located
not close to each other making two gaps due to alignment requirements.
Group them to improve memory footprint.

`pahole` difference before and after (on 32-bit):

-       /* size: 36, cachelines: 1, members: 9 */
-       /* sum members: 30, holes: 2, sum holes: 6 */

+       /* size: 32, cachelines: 1, members: 9 */
+       /* sum members: 30, holes: 1, sum holes: 2 */

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpiolib-acpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 69caa35c58df..878b11c81c7b 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -96,10 +96,10 @@ struct acpi_gpio_chip {
  * @adev: reference to ACPI device which consumes GPIO resource
  * @flags: GPIO initialization flags
  * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo
+ * @wake_capable: wake capability as provided by ACPI
  * @pin_config: pin bias as provided by ACPI
  * @polarity: interrupt polarity as provided by ACPI
  * @triggering: triggering type as provided by ACPI
- * @wake_capable: wake capability as provided by ACPI
  * @debounce: debounce timeout as provided by ACPI
  * @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping
  */
@@ -107,10 +107,10 @@ struct acpi_gpio_info {
 	struct acpi_device *adev;
 	enum gpiod_flags flags;
 	bool gpioint;
+	bool wake_capable;
 	int pin_config;
 	int polarity;
 	int triggering;
-	bool wake_capable;
 	unsigned int debounce;
 	unsigned int quirks;
 };
--=20
2.47.2
From nobody Wed May  7 09:33:15 2025
Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id C47C7239581;
	Wed,  2 Apr 2025 12:23:09 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
 arc=none smtp.client-ip=198.175.65.21
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1743596591; cv=none;
 b=UdPEr80dprqSh39gknfADjp+U5lfCSx2kCviQJT9dL4GdpQYIBgwr1OzsCzH0wwzdgVxraBWqjGCRiYn48kJzyKKVDtBjA/2998mvzt6bxTTxgkf65KQKgMpsl402srIt7uF6eJUC8LwnKk+pUNZMy5rukD1KCIBk2ZWedICayM=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1743596591; c=relaxed/simple;
	bh=vF5juCg/6dnuChWLFVdhEXWfPsLDUW9kA6pZwXk5Ffo=;
	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version;
 b=fPLdvbmtgHc79L3E6Qcp2GWTVqWvQbLj9zOuRNjhaqo5nEyJ03sEAOpeVQpxzMmqEJWRmMx98gN4chkYFpvNrTotsOmYP6ZMKKTqLgv1JBma3FxXIRaQ7W3xoO9HiEA1YMqGn9ejQf0jAO5qnyMqZV6ZK7mH+1mrcDKzzTouLyA=
ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
 dmarc=pass (p=none dis=none) header.from=linux.intel.com;
 spf=none smtp.mailfrom=linux.intel.com;
 dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com
 header.b=XEC0IT1e; arc=none smtp.client-ip=198.175.65.21
Authentication-Results: smtp.subspace.kernel.org;
 dmarc=pass (p=none dis=none) header.from=linux.intel.com
Authentication-Results: smtp.subspace.kernel.org;
 spf=none smtp.mailfrom=linux.intel.com
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com
 header.b="XEC0IT1e"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
  t=1743596590; x=1775132590;
  h=from:to:cc:subject:date:message-id:in-reply-to:
   references:mime-version:content-transfer-encoding;
  bh=vF5juCg/6dnuChWLFVdhEXWfPsLDUW9kA6pZwXk5Ffo=;
  b=XEC0IT1eY+Y0m0VQMlfJIt6Qb3jp0obViIPHKA3eSG2WelYGayvpvf3v
   fHVcn1KE2z83GMwxD6ra41bwg86elB8SUgvuUthwdx5r36UCiwpOUnWy3
   ZDhW6vDqlGW6wquiTZEdRWNKlc2um96g/svPQIAWBVJFUDqvG8P7piGW9
   g5AuwMt+l3IrWEsxeJd0DSLDlt7DQzDM5E/j6MpTR7MCR4oTEVwGONCBf
   lZ/DvzuZcdwenOw35LUuWQUmT01yZtfVNU/E8OLQH5f+n81QprN4/DhOd
   LojjQmJQyGfMQNvYRRqo64eRwH55PXZdcM4SEVT9jEAbGzVyJmARXrSr8
   Q==;
X-CSE-ConnectionGUID: hvNlDlooSSOvxMIW4zb0oQ==
X-CSE-MsgGUID: h+epLI7NQh+p1kUtKISDVg==
X-IronPort-AV: E=McAfee;i="6700,10204,11392"; a="44865041"
X-IronPort-AV: E=Sophos;i="6.15,182,1739865600";
   d="scan'208";a="44865041"
Received: from orviesa002.jf.intel.com ([10.64.159.142])
  by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 02 Apr 2025 05:23:07 -0700
X-CSE-ConnectionGUID: kgFN5AjWR9i67zi+ofdETg==
X-CSE-MsgGUID: 4iTbWnQjR9GqKSVfugWG7Q==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.15,182,1739865600";
   d="scan'208";a="157635538"
Received: from black.fi.intel.com ([10.237.72.28])
  by orviesa002.jf.intel.com with ESMTP; 02 Apr 2025 05:23:05 -0700
Received: by black.fi.intel.com (Postfix, from userid 1003)
	id 58674271; Wed, 02 Apr 2025 15:23:03 +0300 (EEST)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
	linux-gpio@vger.kernel.org,
	linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Mika Westerberg <westeri@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>
Subject: [PATCH v1 2/5] gpiolib: acpi: Remove index parameter from
 acpi_gpio_property_lookup()
Date: Wed,  2 Apr 2025 15:21:17 +0300
Message-ID: <20250402122301.1517463-3-andriy.shevchenko@linux.intel.com>
X-Mailer: git-send-email 2.47.2
In-Reply-To: <20250402122301.1517463-1-andriy.shevchenko@linux.intel.com>
References: <20250402122301.1517463-1-andriy.shevchenko@linux.intel.com>
Precedence: bulk
X-Mailing-List: linux-kernel@vger.kernel.org
List-Id: <linux-kernel.vger.kernel.org>
List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8"

In all cases the supplied index is the same as the passed one in
the struct acpi_gpio_lookup. Remove index parameter and reuse one
from the struct acpi_gpio_lookup instead.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpiolib-acpi.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 878b11c81c7b..afeb8d1c7102 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -830,17 +830,17 @@ static int acpi_gpio_resource_lookup(struct acpi_gpio=
_lookup *lookup,
 	return 0;
 }
=20
-static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode,
-				     const char *propname, int index,
+static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode, const c=
har *propname,
 				     struct acpi_gpio_lookup *lookup)
 {
 	struct fwnode_reference_args args;
+	unsigned int index =3D lookup->index;
 	unsigned int quirks =3D 0;
 	int ret;
=20
 	memset(&args, 0, sizeof(args));
-	ret =3D __acpi_node_get_property_reference(fwnode, propname, index, 3,
-						 &args);
+
+	ret =3D __acpi_node_get_property_reference(fwnode, propname, index, 3, &a=
rgs);
 	if (ret) {
 		struct acpi_device *adev;
=20
@@ -905,8 +905,7 @@ static struct gpio_desc *acpi_get_gpiod_by_index(struct=
 acpi_device *adev,
 	if (propname) {
 		dev_dbg(&adev->dev, "GPIO: looking up %s\n", propname);
=20
-		ret =3D acpi_gpio_property_lookup(acpi_fwnode_handle(adev),
-						propname, index, &lookup);
+		ret =3D acpi_gpio_property_lookup(acpi_fwnode_handle(adev), propname, &l=
ookup);
 		if (ret)
 			return ERR_PTR(ret);
=20
@@ -955,7 +954,7 @@ static struct gpio_desc *acpi_get_gpiod_from_data(struc=
t fwnode_handle *fwnode,
 	memset(&lookup, 0, sizeof(lookup));
 	lookup.index =3D index;
=20
-	ret =3D acpi_gpio_property_lookup(fwnode, propname, index, &lookup);
+	ret =3D acpi_gpio_property_lookup(fwnode, propname, &lookup);
 	if (ret)
 		return ERR_PTR(ret);
=20
--=20
2.47.2
From nobody Wed May  7 09:33:15 2025
Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F07C23A562;
	Wed,  2 Apr 2025 12:23:11 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
 arc=none smtp.client-ip=198.175.65.21
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1743596592; cv=none;
 b=aURXfeHzxEicVu78SeX3VSvzxq7OxZp9weB7UTXlJkzhy/XPf6Zj4N8TWknxfxm6/L0V4KAnpHqkV5EsbSsALnGhYWgL1LTbAzZUgt34C3eAL7qunU4mNxn7St6PQ4Pv6z9NMzQLdBCw6dXZYnnFkn+ScYr4Sm8Hb4WA/CW8TZc=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1743596592; c=relaxed/simple;
	bh=KhR+Pky0mFIa3pNQqaREuTbEmqI6wQSqKz8nfeHdwdk=;
	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version;
 b=klEqxNMZu6f6Wa8BQza1ipKHfiSpBV4pwKTBc+rAaSPxXRgjASeR+2SdW17rrMuEV3nvTmXqTZz5T4IT+1oVOR98vHm4B1P8G6WRObHLGSdD5qiWj11V86wz/CAfUHXhUR/TBsjUY5KMko24xG8S7lNbD2jDjvW3PuRYLGWmGUI=
ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
 dmarc=pass (p=none dis=none) header.from=linux.intel.com;
 spf=none smtp.mailfrom=linux.intel.com;
 dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com
 header.b=LLtc0UWx; arc=none smtp.client-ip=198.175.65.21
Authentication-Results: smtp.subspace.kernel.org;
 dmarc=pass (p=none dis=none) header.from=linux.intel.com
Authentication-Results: smtp.subspace.kernel.org;
 spf=none smtp.mailfrom=linux.intel.com
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com
 header.b="LLtc0UWx"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
  t=1743596592; x=1775132592;
  h=from:to:cc:subject:date:message-id:in-reply-to:
   references:mime-version:content-transfer-encoding;
  bh=KhR+Pky0mFIa3pNQqaREuTbEmqI6wQSqKz8nfeHdwdk=;
  b=LLtc0UWxduq1OFjEM7KfaRAnffm/FHSd2VnztKgfNG3X5OATFSkiFBNE
   h43IUqhFakirwyl3PLIJE2pHMfo00odJzEAqGaqQ3pCaDqka3L0dsLVZz
   8MRnzZu2cohkRNIgO+Whm9gOh+Hn1D35PCHwPtJKjJpXJ67ckNP3E7a5R
   3b8O01z7rz+nMfcv0xT4MXFE1E038uxgG0gmsG+Jwr9YJTs4cB3lvhSyd
   ruMRu8yb8Ipe8tFQr6fPfe9gZiof1VFBlQMOVfBnsCiG6IQ1bJXnq70NV
   bcUr7JVC1t9LsIETOCCdGyrqM48X5DYPhWoMYahnPd3/vjbAIod1It/Vz
   A==;
X-CSE-ConnectionGUID: QGQI4gPfTNCfAJuOcHmxPw==
X-CSE-MsgGUID: tKOuz7N6QJmSMOtEdpHl/A==
X-IronPort-AV: E=McAfee;i="6700,10204,11392"; a="44865046"
X-IronPort-AV: E=Sophos;i="6.15,182,1739865600";
   d="scan'208";a="44865046"
Received: from orviesa002.jf.intel.com ([10.64.159.142])
  by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 02 Apr 2025 05:23:07 -0700
X-CSE-ConnectionGUID: NpNW/DtrQOKquOEGygrJuQ==
X-CSE-MsgGUID: 2YCFpDCtRdeTBRarn2hWXQ==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.15,182,1739865600";
   d="scan'208";a="157635539"
Received: from black.fi.intel.com ([10.237.72.28])
  by orviesa002.jf.intel.com with ESMTP; 02 Apr 2025 05:23:05 -0700
Received: by black.fi.intel.com (Postfix, from userid 1003)
	id 68EB32B9; Wed, 02 Apr 2025 15:23:03 +0300 (EEST)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
	linux-gpio@vger.kernel.org,
	linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Mika Westerberg <westeri@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>
Subject: [PATCH v1 3/5] gpiolib: acpi: Reduce memory footprint for struct
 acpi_gpio_params
Date: Wed,  2 Apr 2025 15:21:18 +0300
Message-ID: <20250402122301.1517463-4-andriy.shevchenko@linux.intel.com>
X-Mailer: git-send-email 2.47.2
In-Reply-To: <20250402122301.1517463-1-andriy.shevchenko@linux.intel.com>
References: <20250402122301.1517463-1-andriy.shevchenko@linux.intel.com>
Precedence: bulk
X-Mailing-List: linux-kernel@vger.kernel.org
List-Id: <linux-kernel.vger.kernel.org>
List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8"

The line_index member in the struct acpi_gpio_params replicates
what is covered in the ACPI GpioIo() or GpioInt() resource.
The value there is limited to 16-bit one, so we don't really need
to have a full 32-bit storage for it. Together with followed
boolean the structure will be smaller.

`pahole` difference before and after:

-	/* size: 12, cachelines: 1, members: 3 */
-	/* padding: 3 */

+	/* size: 8, cachelines: 1, members: 3 */
+	/* padding: 1 */

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/gpio/consumer.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index 45b651c05b9c..899179972bec 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -587,7 +587,7 @@ struct gpio_desc *devm_fwnode_gpiod_get(struct device *=
dev,
=20
 struct acpi_gpio_params {
 	unsigned int crs_entry_index;
-	unsigned int line_index;
+	unsigned short line_index;
 	bool active_low;
 };
=20
--=20
2.47.2
From nobody Wed May  7 09:33:15 2025
Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC3712356AB;
	Wed,  2 Apr 2025 12:23:06 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
 arc=none smtp.client-ip=192.198.163.19
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1743596588; cv=none;
 b=Sry3xQqkipCVJCtHOAjkrZ+BA1mPU4XHFTRz/Ua6XYR5RKqwJyWzUmHDssDoa0uUhAcQ9u7fKrWKsImq4RHAabbKOwm0xd2TxN9sBEbvrLst359p41Izp06JYjCyqeYokMEDfLRv68dnHczHE0+R16EzaG7M7ajn+IMeAajugGU=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1743596588; c=relaxed/simple;
	bh=jrQuqRPZTLRY/Nv4wjP8wiHYwDHsodAh6RSZDaxljOA=;
	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version;
 b=LKU+T32mSafDmM14YybpaKnFq39tLVAMm60tZbycxLP7lW6Dh45TElHXbffPztoUAYVUaonogRRQoWZfvSH5i236cLy0pkuexj2TULBgRpHrEjsnnTrh70h9FD5VEoRfihlqUzsvkXm2fjlmZT5Dldek6oav5zz6KLKDby3U5UM=
ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
 dmarc=pass (p=none dis=none) header.from=linux.intel.com;
 spf=none smtp.mailfrom=linux.intel.com;
 dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com
 header.b=TjhJ0zT0; arc=none smtp.client-ip=192.198.163.19
Authentication-Results: smtp.subspace.kernel.org;
 dmarc=pass (p=none dis=none) header.from=linux.intel.com
Authentication-Results: smtp.subspace.kernel.org;
 spf=none smtp.mailfrom=linux.intel.com
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com
 header.b="TjhJ0zT0"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
  t=1743596587; x=1775132587;
  h=from:to:cc:subject:date:message-id:in-reply-to:
   references:mime-version:content-transfer-encoding;
  bh=jrQuqRPZTLRY/Nv4wjP8wiHYwDHsodAh6RSZDaxljOA=;
  b=TjhJ0zT0Km3lLyIPt5zqZ0N8KOBWO8ybNLcL1G9H8Xx85rvay0FaWGLR
   3ouy4aJk98jGVPbwHdz7AQx1bjsbus6XwJPggZ6C032HgWebjijg8+n9i
   sVPPbfNHAtoLcq5BRZ/2peTNsgfBfJBytTXGOaJYaTMLvOeNjxxwkX4zG
   VHwtZRCu1W7e15/hVpOL8neNWdpLJGoPdVoPgQTaa+FEdDDQMOlN/HqBB
   OYdm+V8yDjqgoVQTOL8MJzxGhW+vp6g2UvNRhOhOJxOhsQDws6bMDBWUT
   ZAjmOD7YYd26LirEPeGgqbOs+28tTpBWxMafAmvWtWKL453rsl+pc/GMV
   w==;
X-CSE-ConnectionGUID: YEahfclmTBysQWaARrbT/w==
X-CSE-MsgGUID: FLDrPTH9RAqmilNwInep1Q==
X-IronPort-AV: E=McAfee;i="6700,10204,11392"; a="44104530"
X-IronPort-AV: E=Sophos;i="6.15,182,1739865600";
   d="scan'208";a="44104530"
Received: from fmviesa002.fm.intel.com ([10.60.135.142])
  by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 02 Apr 2025 05:23:06 -0700
X-CSE-ConnectionGUID: ss7ZNeBlRhKHvpd1/tEbwA==
X-CSE-MsgGUID: JBaTt+7QRqWAk6a/fiZEVA==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.15,182,1739865600";
   d="scan'208";a="149872337"
Received: from black.fi.intel.com ([10.237.72.28])
  by fmviesa002.fm.intel.com with ESMTP; 02 Apr 2025 05:23:04 -0700
Received: by black.fi.intel.com (Postfix, from userid 1003)
	id 745794B0; Wed, 02 Apr 2025 15:23:03 +0300 (EEST)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
	linux-gpio@vger.kernel.org,
	linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Mika Westerberg <westeri@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>
Subject: [PATCH v1 4/5] gpiolib: acpi: Reuse struct acpi_gpio_params in struct
 acpi_gpio_lookup
Date: Wed,  2 Apr 2025 15:21:19 +0300
Message-ID: <20250402122301.1517463-5-andriy.shevchenko@linux.intel.com>
X-Mailer: git-send-email 2.47.2
In-Reply-To: <20250402122301.1517463-1-andriy.shevchenko@linux.intel.com>
References: <20250402122301.1517463-1-andriy.shevchenko@linux.intel.com>
Precedence: bulk
X-Mailing-List: linux-kernel@vger.kernel.org
List-Id: <linux-kernel.vger.kernel.org>
List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8"

Some of the contents of struct acpi_gpio_lookup repeats what we have
in the struct acpi_gpio_params. Reuse the latter in the former.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpiolib-acpi.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index afeb8d1c7102..750724601106 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -744,9 +744,7 @@ static int acpi_gpio_update_gpiod_lookup_flags(unsigned=
 long *lookupflags,
=20
 struct acpi_gpio_lookup {
 	struct acpi_gpio_info info;
-	int index;
-	u16 pin_index;
-	bool active_low;
+	struct acpi_gpio_params par;
 	struct gpio_desc *desc;
 	int n;
 };
@@ -754,6 +752,7 @@ struct acpi_gpio_lookup {
 static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *dat=
a)
 {
 	struct acpi_gpio_lookup *lookup =3D data;
+	struct acpi_gpio_params *par =3D &lookup->par;
=20
 	if (ares->type !=3D ACPI_RESOURCE_TYPE_GPIO)
 		return 1;
@@ -765,12 +764,12 @@ static int acpi_populate_gpio_lookup(struct acpi_reso=
urce *ares, void *data)
 		u16 pin_index;
=20
 		if (lookup->info.quirks & ACPI_GPIO_QUIRK_ONLY_GPIOIO && gpioint)
-			lookup->index++;
+			par->crs_entry_index++;
=20
-		if (lookup->n++ !=3D lookup->index)
+		if (lookup->n++ !=3D par->crs_entry_index)
 			return 1;
=20
-		pin_index =3D lookup->pin_index;
+		pin_index =3D par->line_index;
 		if (pin_index >=3D agpio->pin_table_length)
 			return 1;
=20
@@ -796,7 +795,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resour=
ce *ares, void *data)
 			lookup->info.polarity =3D agpio->polarity;
 			lookup->info.triggering =3D agpio->triggering;
 		} else {
-			lookup->info.polarity =3D lookup->active_low;
+			lookup->info.polarity =3D par->active_low;
 		}
=20
 		lookup->info.flags =3D acpi_gpio_to_gpiod_flags(agpio, lookup->info.pola=
rity);
@@ -834,7 +833,8 @@ static int acpi_gpio_property_lookup(struct fwnode_hand=
le *fwnode, const char *p
 				     struct acpi_gpio_lookup *lookup)
 {
 	struct fwnode_reference_args args;
-	unsigned int index =3D lookup->index;
+	struct acpi_gpio_params *par =3D &lookup->par;
+	unsigned int index =3D par->crs_entry_index;
 	unsigned int quirks =3D 0;
 	int ret;
=20
@@ -857,9 +857,9 @@ static int acpi_gpio_property_lookup(struct fwnode_hand=
le *fwnode, const char *p
 	if (args.nargs !=3D 3)
 		return -EPROTO;
=20
-	lookup->index =3D args.args[0];
-	lookup->pin_index =3D args.args[1];
-	lookup->active_low =3D !!args.args[2];
+	par->crs_entry_index =3D args.args[0];
+	par->line_index =3D args.args[1];
+	par->active_low =3D !!args.args[2];
=20
 	lookup->info.adev =3D to_acpi_device_node(args.fwnode);
 	lookup->info.quirks =3D quirks;
@@ -897,10 +897,11 @@ static struct gpio_desc *acpi_get_gpiod_by_index(stru=
ct acpi_device *adev,
 						 struct acpi_gpio_info *info)
 {
 	struct acpi_gpio_lookup lookup;
+	struct acpi_gpio_params *par =3D &lookup.par;
 	int ret;
=20
 	memset(&lookup, 0, sizeof(lookup));
-	lookup.index =3D index;
+	par->crs_entry_index =3D index;
=20
 	if (propname) {
 		dev_dbg(&adev->dev, "GPIO: looking up %s\n", propname);
@@ -909,9 +910,9 @@ static struct gpio_desc *acpi_get_gpiod_by_index(struct=
 acpi_device *adev,
 		if (ret)
 			return ERR_PTR(ret);
=20
-		dev_dbg(&adev->dev, "GPIO: _DSD returned %s %d %u %u\n",
-			dev_name(&lookup.info.adev->dev), lookup.index,
-			lookup.pin_index, lookup.active_low);
+		dev_dbg(&adev->dev, "GPIO: _DSD returned %s %u %u %u\n",
+			dev_name(&lookup.info.adev->dev),
+			par->crs_entry_index, par->line_index, par->active_low);
 	} else {
 		dev_dbg(&adev->dev, "GPIO: looking up %d in _CRS\n", index);
 		lookup.info.adev =3D adev;
@@ -943,6 +944,7 @@ static struct gpio_desc *acpi_get_gpiod_from_data(struc=
t fwnode_handle *fwnode,
 						  struct acpi_gpio_info *info)
 {
 	struct acpi_gpio_lookup lookup;
+	struct acpi_gpio_params *par =3D &lookup.par;
 	int ret;
=20
 	if (!is_acpi_data_node(fwnode))
@@ -952,7 +954,7 @@ static struct gpio_desc *acpi_get_gpiod_from_data(struc=
t fwnode_handle *fwnode,
 		return ERR_PTR(-EINVAL);
=20
 	memset(&lookup, 0, sizeof(lookup));
-	lookup.index =3D index;
+	par->crs_entry_index =3D index;
=20
 	ret =3D acpi_gpio_property_lookup(fwnode, propname, &lookup);
 	if (ret)
--=20
2.47.2
From nobody Wed May  7 09:33:15 2025
Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7ED4423A98F;
	Wed,  2 Apr 2025 12:23:11 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
 arc=none smtp.client-ip=198.175.65.21
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1743596593; cv=none;
 b=ldpS1n1IRGC3Qks8Y5oIXW0p2Z0Xs66TBuPx5K937dvYmCOWDODoZY36jVjLfhGjfy6vCtHiClUPUtLv9Ov1Me4P0TvhriSovm3gWiSQivvKe7kJnWk1ltMshimym4zwIlBGc1SEJQX5/co7Let/z2bj4rR2SVeX41QmBRcuTeE=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1743596593; c=relaxed/simple;
	bh=ipW7SukMx+y4OYBPi1rirqi+iPYrDFo8757SlZ1abVc=;
	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version;
 b=foKKQ0KH1a1tmhWtFZvWMeRAK/T+O0WL2vloPAYFch0sZ3LQST+gkjzhSo1VW8p51NXuX5YnPxLctz7H+HBphlPo/OzhcxfZ82wC6Z8ltmVZRcWAQc/YGjzdymGNWKN47UKrQaXv1LTNjcVz1cFrYPv+8XUtmLcfKZM4+mQvSJo=
ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
 dmarc=pass (p=none dis=none) header.from=linux.intel.com;
 spf=none smtp.mailfrom=linux.intel.com;
 dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com
 header.b=PvRjJ+/L; arc=none smtp.client-ip=198.175.65.21
Authentication-Results: smtp.subspace.kernel.org;
 dmarc=pass (p=none dis=none) header.from=linux.intel.com
Authentication-Results: smtp.subspace.kernel.org;
 spf=none smtp.mailfrom=linux.intel.com
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com
 header.b="PvRjJ+/L"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
  t=1743596592; x=1775132592;
  h=from:to:cc:subject:date:message-id:in-reply-to:
   references:mime-version:content-transfer-encoding;
  bh=ipW7SukMx+y4OYBPi1rirqi+iPYrDFo8757SlZ1abVc=;
  b=PvRjJ+/Len21IgzbPBU9jMWsaCE/TduAPe32MNAhjJfWveWGgmy2gQoU
   n6CDkXzvgtt2tfxblZsmKu9QH5kCRsFyfomXzMNJa/1bcTNcUN15UP5oq
   nxf+m/CX3gHOPIBIg4skF8RoxS3K/7ooneV9l16uIWxlEhY0xSSZESTxd
   2d64kuCciqk/cMcR7qUUYumoEeSfrNWM+pwNsEoswkNzXqFX55R3ZqI4+
   H2SBSLdJQXPTiaSlpAJXG1bX6KQQdrtr9Dcg4jrlJekImq0+TIz7FMk2y
   Qin6IeZfYm5VZ5OvnM7ECWWzNDJc0qCYNe6rmFLs2lg6UuyuQdKMk0Lg2
   Q==;
X-CSE-ConnectionGUID: 3iLmoYUuS4qBxuosFrARFA==
X-CSE-MsgGUID: vrbLpepmS9Cx6BNS2V763w==
X-IronPort-AV: E=McAfee;i="6700,10204,11392"; a="44865054"
X-IronPort-AV: E=Sophos;i="6.15,182,1739865600";
   d="scan'208";a="44865054"
Received: from orviesa002.jf.intel.com ([10.64.159.142])
  by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 02 Apr 2025 05:23:10 -0700
X-CSE-ConnectionGUID: wM3iTc2ITBevt+9P9ReMjQ==
X-CSE-MsgGUID: Y+IjvnIMTXCANZURAb0Jtw==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.15,182,1739865600";
   d="scan'208";a="157635548"
Received: from black.fi.intel.com ([10.237.72.28])
  by orviesa002.jf.intel.com with ESMTP; 02 Apr 2025 05:23:08 -0700
Received: by black.fi.intel.com (Postfix, from userid 1003)
	id 804CB597; Wed, 02 Apr 2025 15:23:03 +0300 (EEST)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
	linux-gpio@vger.kernel.org,
	linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Mika Westerberg <westeri@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>
Subject: [PATCH v1 5/5] gpiolib: acpi: Deduplicate some code in
 __acpi_find_gpio()
Date: Wed,  2 Apr 2025 15:21:20 +0300
Message-ID: <20250402122301.1517463-6-andriy.shevchenko@linux.intel.com>
X-Mailer: git-send-email 2.47.2
In-Reply-To: <20250402122301.1517463-1-andriy.shevchenko@linux.intel.com>
References: <20250402122301.1517463-1-andriy.shevchenko@linux.intel.com>
Precedence: bulk
X-Mailing-List: linux-kernel@vger.kernel.org
List-Id: <linux-kernel.vger.kernel.org>
List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8"

__acpi_find_gpio() calls two functions depending on the supplied con_id
and possibility to fallback to _CRS lookup. Those functions have the same
pieces of code that can be done only in one place. Do it so.

This gives an impressive shrink of the generated code for x86_64:

add/remove: 0/2 grow/shrink: 0/4 up/down: 0/-1204 (-1204)
Function                                     old     new   delta
acpi_find_gpio.__UNIQUE_ID_ddebug478          56       -     -56
acpi_dev_gpio_irq_wake_get_by.__UNIQUE_ID_ddebug480      56       -     -56
acpi_find_gpio                               354     216    -138
acpi_get_gpiod_by_index                      456     307    -149
__acpi_find_gpio                             877     638    -239
acpi_dev_gpio_irq_wake_get_by                695     129    -566
Total: Before=3D15358, After=3D14154, chg -7.84%

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpiolib-acpi.c | 103 +++++++++++++++++-------------------
 1 file changed, 49 insertions(+), 54 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 750724601106..5c6ef419f875 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -804,8 +804,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resour=
ce *ares, void *data)
 	return 1;
 }
=20
-static int acpi_gpio_resource_lookup(struct acpi_gpio_lookup *lookup,
-				     struct acpi_gpio_info *info)
+static int acpi_gpio_resource_lookup(struct acpi_gpio_lookup *lookup)
 {
 	struct acpi_device *adev =3D lookup->info.adev;
 	struct list_head res_list;
@@ -824,8 +823,6 @@ static int acpi_gpio_resource_lookup(struct acpi_gpio_l=
ookup *lookup,
 	if (!lookup->desc)
 		return -ENOENT;
=20
-	if (info)
-		*info =3D lookup->info;
 	return 0;
 }
=20
@@ -871,97 +868,83 @@ static int acpi_gpio_property_lookup(struct fwnode_ha=
ndle *fwnode, const char *p
  * acpi_get_gpiod_by_index() - get a GPIO descriptor from device resources
  * @adev: pointer to a ACPI device to get GPIO from
  * @propname: Property name of the GPIO (optional)
- * @index: index of GpioIo/GpioInt resource (starting from %0)
- * @info: info pointer to fill in (optional)
+ * @lookup: pointer to struct acpi_gpio_lookup to fill in
  *
- * Function goes through ACPI resources for @adev and based on @index looks
+ * Function goes through ACPI resources for @adev and based on @lookup.ind=
ex looks
  * up a GpioIo/GpioInt resource, translates it to the Linux GPIO descripto=
r,
- * and returns it. @index matches GpioIo/GpioInt resources only so if there
- * are total %3 GPIO resources, the index goes from %0 to %2.
+ * and returns it. @lookup.index matches GpioIo/GpioInt resources only so =
if there
+ * are total 3 GPIO resources, the index goes from 0 to 2.
  *
  * If @propname is specified the GPIO is looked using device property. In
  * that case @index is used to select the GPIO entry in the property value
  * (in case of multiple).
  *
  * Returns:
- * GPIO descriptor to use with Linux generic GPIO API.
- * If the GPIO cannot be translated or there is an error an ERR_PTR is
- * returned.
+ * 0 on success, negative errno on failure.
+ *
+ * The @lookup is filled with GPIO descriptor to use with Linux generic GP=
IO API.
+ * If the GPIO cannot be translated an error will be returned.
  *
  * Note: if the GPIO resource has multiple entries in the pin list, this
  * function only returns the first.
  */
-static struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev,
-						 const char *propname,
-						 int index,
-						 struct acpi_gpio_info *info)
+static int acpi_get_gpiod_by_index(struct acpi_device *adev, const char *p=
ropname,
+				   struct acpi_gpio_lookup *lookup)
 {
-	struct acpi_gpio_lookup lookup;
-	struct acpi_gpio_params *par =3D &lookup.par;
+	struct acpi_gpio_info *info =3D &lookup->info;
+	struct acpi_gpio_params *par =3D &lookup->par;
 	int ret;
=20
-	memset(&lookup, 0, sizeof(lookup));
-	par->crs_entry_index =3D index;
-
 	if (propname) {
 		dev_dbg(&adev->dev, "GPIO: looking up %s\n", propname);
=20
-		ret =3D acpi_gpio_property_lookup(acpi_fwnode_handle(adev), propname, &l=
ookup);
+		ret =3D acpi_gpio_property_lookup(acpi_fwnode_handle(adev), propname, lo=
okup);
 		if (ret)
-			return ERR_PTR(ret);
+			return ret;
=20
 		dev_dbg(&adev->dev, "GPIO: _DSD returned %s %u %u %u\n",
-			dev_name(&lookup.info.adev->dev),
+			dev_name(&info->adev->dev),
 			par->crs_entry_index, par->line_index, par->active_low);
 	} else {
-		dev_dbg(&adev->dev, "GPIO: looking up %d in _CRS\n", index);
-		lookup.info.adev =3D adev;
+		dev_dbg(&adev->dev, "GPIO: looking up %u in _CRS\n", par->crs_entry_inde=
x);
+		info->adev =3D adev;
 	}
=20
-	ret =3D acpi_gpio_resource_lookup(&lookup, info);
-	return ret ? ERR_PTR(ret) : lookup.desc;
+	return acpi_gpio_resource_lookup(lookup);
 }
=20
 /**
  * acpi_get_gpiod_from_data() - get a GPIO descriptor from ACPI data node
  * @fwnode: pointer to an ACPI firmware node to get the GPIO information f=
rom
  * @propname: Property name of the GPIO
- * @index: index of GpioIo/GpioInt resource (starting from %0)
- * @info: info pointer to fill in (optional)
+ * @lookup: pointer to struct acpi_gpio_lookup to fill in
  *
  * This function uses the property-based GPIO lookup to get to the GPIO
  * resource with the relevant information from a data-only ACPI firmware n=
ode
  * and uses that to obtain the GPIO descriptor to return.
  *
  * Returns:
- * GPIO descriptor to use with Linux generic GPIO API.
- * If the GPIO cannot be translated or there is an error an ERR_PTR is
- * returned.
+ * 0 on success, negative errno on failure.
+ *
+ * The @lookup is filled with GPIO descriptor to use with Linux generic GP=
IO API.
+ * If the GPIO cannot be translated an error will be returned.
  */
-static struct gpio_desc *acpi_get_gpiod_from_data(struct fwnode_handle *fw=
node,
-						  const char *propname,
-						  int index,
-						  struct acpi_gpio_info *info)
+static int acpi_get_gpiod_from_data(struct fwnode_handle *fwnode, const ch=
ar *propname,
+				    struct acpi_gpio_lookup *lookup)
 {
-	struct acpi_gpio_lookup lookup;
-	struct acpi_gpio_params *par =3D &lookup.par;
 	int ret;
=20
 	if (!is_acpi_data_node(fwnode))
-		return ERR_PTR(-ENODEV);
+		return -ENODEV;
=20
 	if (!propname)
-		return ERR_PTR(-EINVAL);
+		return -EINVAL;
=20
-	memset(&lookup, 0, sizeof(lookup));
-	par->crs_entry_index =3D index;
-
-	ret =3D acpi_gpio_property_lookup(fwnode, propname, &lookup);
+	ret =3D acpi_gpio_property_lookup(fwnode, propname, lookup);
 	if (ret)
-		return ERR_PTR(ret);
+		return ret;
=20
-	ret =3D acpi_gpio_resource_lookup(&lookup, info);
-	return ret ? ERR_PTR(ret) : lookup.desc;
+	return acpi_gpio_resource_lookup(lookup);
 }
=20
 static bool acpi_can_fallback_to_crs(struct acpi_device *adev,
@@ -983,17 +966,24 @@ __acpi_find_gpio(struct fwnode_handle *fwnode, const =
char *con_id, unsigned int
 		 bool can_fallback, struct acpi_gpio_info *info)
 {
 	struct acpi_device *adev =3D to_acpi_device_node(fwnode);
+	struct acpi_gpio_lookup lookup;
 	struct gpio_desc *desc;
 	char propname[32];
+	int ret;
+
+	memset(&lookup, 0, sizeof(lookup));
+	lookup.par.crs_entry_index =3D idx;
=20
 	/* Try first from _DSD */
 	for_each_gpio_property_name(propname, con_id) {
 		if (adev)
-			desc =3D acpi_get_gpiod_by_index(adev,
-						       propname, idx, info);
+			ret =3D acpi_get_gpiod_by_index(adev, propname, &lookup);
 		else
-			desc =3D acpi_get_gpiod_from_data(fwnode,
-							propname, idx, info);
+			ret =3D acpi_get_gpiod_from_data(fwnode, propname, &lookup);
+		if (ret)
+			continue;
+
+		desc =3D lookup.desc;
 		if (PTR_ERR(desc) =3D=3D -EPROBE_DEFER)
 			return desc;
=20
@@ -1002,8 +992,13 @@ __acpi_find_gpio(struct fwnode_handle *fwnode, const =
char *con_id, unsigned int
 	}
=20
 	/* Then from plain _CRS GPIOs */
-	if (can_fallback)
-		return acpi_get_gpiod_by_index(adev, NULL, idx, info);
+	if (can_fallback) {
+		ret =3D acpi_get_gpiod_by_index(adev, NULL, &lookup);
+		if (ret)
+			return ERR_PTR(ret);
+
+		return lookup.desc;
+	}
=20
 	return ERR_PTR(-ENOENT);
 }
--=20
2.47.2