From nobody Tue May  6 16:17:20 2025
Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18])
	(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 7B6FC2512FD;
	Thu,  3 Apr 2025 16:00:53 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
 arc=none smtp.client-ip=192.198.163.18
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1743696055; cv=none;
 b=MKkrvoZFFSVJwWvLbHeQXV8wqNUB2qa3CNS0xSvn3pl7IIhXpsPzQLeDP7rD5Wk3Z1U3ec9iu0rJFAY8EGoQtSDWa49lkYPnb6TvFO03ONAYw4rgUlgJX4Q5wRra9p9kRz/Y8cHy4XSJLDYglFQ6/oBlhTz4WLmkLIWas5WMU0A=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1743696055; c=relaxed/simple;
	bh=JzZ2zxRH5WzmArsIBFNmyYfJ/ZT+m/rFHFyi90jX0UY=;
	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version;
 b=kVF4ObVpKcl54N29Qur2PCVH6qqelESuyhCwaLjsna+XBLgDiisvbhyxnBA7YDxX+SuYRcS1BfuM66NKR0+pcoKnPz7otp77lYhjUSmKwPid7QETCVIHNDgJaiIe7/J8JtbXbVY9naA6jLiwrmFbdRKKXvXj0JTJ8Z9TPAzxGQE=
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=KYgbQVjD; arc=none smtp.client-ip=192.198.163.18
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="KYgbQVjD"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
  t=1743696053; x=1775232053;
  h=from:to:cc:subject:date:message-id:in-reply-to:
   references:mime-version:content-transfer-encoding;
  bh=JzZ2zxRH5WzmArsIBFNmyYfJ/ZT+m/rFHFyi90jX0UY=;
  b=KYgbQVjD1Y6KWDpptMkmIiidYQUSWitayuZMeaS96tpUOMmrQj1XrrW1
   RamewHRGqIOqjIhnhGPSgXhrFK54c1Fwj+xX/craEUWfjbh4mM1IsuAdQ
   PnxmOHisheBiNMfIfg8WhBJGx1YW10vW29IADBmqxfppvE0Re1Vp0y07v
   DahOXNT4lXV5jcTfPHvz2rwD6RcL99jZyflm0CGcSFQPWfluT20uIitRt
   s3PtVFfq7lqn2LEMZVahnSA1NFJPzZTl7LO8PBU/K0FCU/w32n9H0LT19
   k7nUcTmE58756NHheiWTKWjmHb5ZLCMEuYLZZELwjyJH5Z75bzfqSHCS0
   g==;
X-CSE-ConnectionGUID: asObfcIITIasvzgwXMfddg==
X-CSE-MsgGUID: qTv+nBwlQSWcrJ2e0wZSxw==
X-IronPort-AV: E=McAfee;i="6700,10204,11393"; a="44369239"
X-IronPort-AV: E=Sophos;i="6.15,184,1739865600";
   d="scan'208";a="44369239"
Received: from fmviesa001.fm.intel.com ([10.60.135.141])
  by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 03 Apr 2025 09:00:52 -0700
X-CSE-ConnectionGUID: zFe+AvXiTRakGhxQ/xGz/A==
X-CSE-MsgGUID: SDTrjG1PQKuvsXn2QKQBFQ==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.15,184,1739865600";
   d="scan'208";a="158036302"
Received: from black.fi.intel.com ([10.237.72.28])
  by fmviesa001.fm.intel.com with ESMTP; 03 Apr 2025 09:00:37 -0700
Received: by black.fi.intel.com (Postfix, from userid 1003)
	id 2B8F2E0; Thu, 03 Apr 2025 19:00:36 +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 v2 1/6] gpiolib: acpi: Improve struct acpi_gpio_info memory
 footprint
Date: Thu,  3 Apr 2025 18:59:12 +0300
Message-ID: <20250403160034.2680485-2-andriy.shevchenko@linux.intel.com>
X-Mailer: git-send-email 2.47.2
In-Reply-To: <20250403160034.2680485-1-andriy.shevchenko@linux.intel.com>
References: <20250403160034.2680485-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>
Acked-by: Mika Westerberg <westeri@kernel.org>
---
 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 Tue May  6 16:17:20 2025
Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16])
	(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 A335D250C19;
	Thu,  3 Apr 2025 16:00:49 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
 arc=none smtp.client-ip=192.198.163.16
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1743696051; cv=none;
 b=ckkftzseACObZNqvMjqgrK6Kh1qtARMemUR6Aue4aL9C+noMNZ4lh8/gYlH2Bm2vGSdaUlqpZp+OH6+lbWpCQBAuzX4gwytZH8FGZ39SKULGmIQxn0ImHW2mUu2agaLyQYS5bYsMO5bCPrF/dLgIqXbgI4td/ENf+EC9w3pdcoQ=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1743696051; c=relaxed/simple;
	bh=iZYIMc6tqqQjamxndLTziI4yLhoLETWBDIAWhz1dFLQ=;
	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version;
 b=NJlJn20lTYuRcpmmLNyG7NfftY76uoQQpX8ZCKMxcCd+Nq7Yca0t2+nWyWAPMZpH/QxUkTZtBL8Ztm0hKhKCn+5gos5E6DgGKdloAkt+Br/EzTNKqgxcqpEV061pObqybGrEGf9QxSuOifaEN0vVRqAr45V6+d64bxRdirW+hAU=
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=be4NgbCF; arc=none smtp.client-ip=192.198.163.16
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="be4NgbCF"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
  t=1743696050; x=1775232050;
  h=from:to:cc:subject:date:message-id:in-reply-to:
   references:mime-version:content-transfer-encoding;
  bh=iZYIMc6tqqQjamxndLTziI4yLhoLETWBDIAWhz1dFLQ=;
  b=be4NgbCFpFh3rxXVe22YZ6K8E65bK0IGwvdaly+5evAoKsC1Y7Lsafna
   trfhN3W/bYptaTi0xCVoTt/6grixTjR3orhFj/oxnD6io1ttyX+bBA+P3
   nQgSeUD4R1Rh2dYROzOYNjlArOVf9XeF/Nrg3qEiDt4a+90e0U351wKBr
   f/ZjBXJKQLiq4VEgvr33HcwcU7E84G09caEsEGU31XrNqT1oZEDNimuO3
   hzMVcxbagtk4qaDFn70Rb9kpdVhJoXMcWoR7BE0WqWgn8LpoMphl+exjY
   4bVbV7q4Is1Y8XdKXZQkiTHmoY9Alyn/Q6hEyKu3hApuXo4w9RPVJzhxY
   g==;
X-CSE-ConnectionGUID: N+KKVia3RbqQgfp7DGsdKA==
X-CSE-MsgGUID: dBTrUlERS/a8NCnnThvXBw==
X-IronPort-AV: E=McAfee;i="6700,10204,11393"; a="32716811"
X-IronPort-AV: E=Sophos;i="6.15,184,1739865600";
   d="scan'208";a="32716811"
Received: from fmviesa007.fm.intel.com ([10.60.135.147])
  by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 03 Apr 2025 09:00:39 -0700
X-CSE-ConnectionGUID: 8xJgQ5D5QYKulp3uRIvluA==
X-CSE-MsgGUID: FFgZtgaaQV2RusdiN9NVUg==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.15,184,1739865600";
   d="scan'208";a="127036146"
Received: from black.fi.intel.com ([10.237.72.28])
  by fmviesa007.fm.intel.com with ESMTP; 03 Apr 2025 09:00:37 -0700
Received: by black.fi.intel.com (Postfix, from userid 1003)
	id 3CA981BC; Thu, 03 Apr 2025 19:00:36 +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 v2 2/6] gpiolib: acpi: Remove index parameter from
 acpi_gpio_property_lookup()
Date: Thu,  3 Apr 2025 18:59:13 +0300
Message-ID: <20250403160034.2680485-3-andriy.shevchenko@linux.intel.com>
X-Mailer: git-send-email 2.47.2
In-Reply-To: <20250403160034.2680485-1-andriy.shevchenko@linux.intel.com>
References: <20250403160034.2680485-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.

add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-14 (-14)
Function                                     old     new   delta
acpi_get_gpiod_by_index                      462     456      -6
acpi_gpio_property_lookup                    425     417      -8
Total: Before=3D15375, After=3D15361, chg -0.09%

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mika Westerberg <westeri@kernel.org>
---
 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 Tue May  6 16:17:20 2025
Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18])
	(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 3581D251786;
	Thu,  3 Apr 2025 16:00:55 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
 arc=none smtp.client-ip=192.198.163.18
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1743696056; cv=none;
 b=bJ9HA8Mk7AAInpReSXyhbni2r4cjebNwhAIGKUhRlQPq3qz6HCTUs62WyDtg5LB09O7a+HjHEo9izsWb4ZmMgU5xmsnGWrD5Z90kPT6PexgH48NvFcW8q9wycG/rMq7/2MUOknQiswUow2rNvL2D9w9K9Pab9gCGm6irCtXP6YY=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1743696056; c=relaxed/simple;
	bh=vjI5klfXDk5T17g4Xw3ZZiIo7UPS2209JJJrsDjn1iI=;
	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version;
 b=QyX3V+P+AOHHurNA4CuGlEvAmWdA20XAuDE1uMGQdQp++aeusnBLSWJepBzQprxQ2pBeAp5HoK3CedZUi2ptJNlOP8cwr1Qn6bAsCQeXcz7+Ac5rLsxGitfu/ZwmNtJMxc2QGXiy5Vswa7jgHWZH5rcnHLK1S3sWGABvAPkQcPg=
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=OfUtCzvv; arc=none smtp.client-ip=192.198.163.18
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="OfUtCzvv"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
  t=1743696055; x=1775232055;
  h=from:to:cc:subject:date:message-id:in-reply-to:
   references:mime-version:content-transfer-encoding;
  bh=vjI5klfXDk5T17g4Xw3ZZiIo7UPS2209JJJrsDjn1iI=;
  b=OfUtCzvvzZLQnk7pHtMhZLNGUpKOVes6sxFTb4jQ08/+JE7jjCxQCVlJ
   kMZA/9Xdfj7a5enWjOwvyZfMC8fLvw9O3WkzSXI1IgJZI1ipNQI2RoJqQ
   2pzInQp550ek3wrsmAP55RmuaLnIydolIxbZ7lRr2wBX9HIWk1kmB6yot
   sdtjV4UH+EDq3XxBPulyu/I1K4UEn5fNc0+gE2KrmEFcv4t6XKml/58VA
   8ONfSMzlVBtawPGR5Fzo5Ozb2yaLKNTff7fgxOocPXnQX7dATE/IN0Y8y
   Bi6T0adsNCNQ5pcOrysHJOLOGxOvOlLdL2uDozgmr7FHuv4Pnt2+etfE9
   g==;
X-CSE-ConnectionGUID: WjTBo1VMQ1uwVelVC/fDKA==
X-CSE-MsgGUID: INwv4u2OQreTJ92X5glQ2g==
X-IronPort-AV: E=McAfee;i="6700,10204,11393"; a="44369243"
X-IronPort-AV: E=Sophos;i="6.15,184,1739865600";
   d="scan'208";a="44369243"
Received: from fmviesa001.fm.intel.com ([10.60.135.141])
  by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 03 Apr 2025 09:00:52 -0700
X-CSE-ConnectionGUID: dbHragxiS2C12LDSG0jNPg==
X-CSE-MsgGUID: L9hMbCSHTeKpUxJfCa8FqQ==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.15,184,1739865600";
   d="scan'208";a="158036301"
Received: from black.fi.intel.com ([10.237.72.28])
  by fmviesa001.fm.intel.com with ESMTP; 03 Apr 2025 09:00:37 -0700
Received: by black.fi.intel.com (Postfix, from userid 1003)
	id 47F2F22A; Thu, 03 Apr 2025 19:00:36 +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 v2 3/6] gpiolib: acpi: Reduce memory footprint for struct
 acpi_gpio_params
Date: Thu,  3 Apr 2025 18:59:14 +0300
Message-ID: <20250403160034.2680485-4-andriy.shevchenko@linux.intel.com>
X-Mailer: git-send-email 2.47.2
In-Reply-To: <20250403160034.2680485-1-andriy.shevchenko@linux.intel.com>
References: <20250403160034.2680485-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.

add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3 (-3)
Function                                     old     new   delta
acpi_gpio_property_lookup                    417     414      -3
Total: Before=3D15361, After=3D15358, chg -0.02%

`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>
Acked-by: Mika Westerberg <westeri@kernel.org>
---
 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 Tue May  6 16:17:20 2025
Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18])
	(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 AF953251796;
	Thu,  3 Apr 2025 16:00:55 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
 arc=none smtp.client-ip=192.198.163.18
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1743696058; cv=none;
 b=t1+1aGT/nYf/yM0ZzKZfgULJMLScFXXFou/qjxQCtbxSMMOwHBZtSWuYai1gIuIVWOwKByVW4tSJi4zaCWuwqGT5BSXU4Yee4RwL+OXvL7lox2MYNT/I7i7SPDQAIX7FjDLr52MrAUyGX+gap6c/+nw406cVtuSQX7U2W9IX7Ok=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1743696058; c=relaxed/simple;
	bh=zi/0itXjLWX25lyreRTOs04H8X0b6Vm47Emh2xv1hAA=;
	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version;
 b=oDDotZW7mhrb483/QV9NN+lB3WAfpeHh/YszG0EYAR6mqbJqJnK149DKyMXT41dTjRK/C/GwgLkRKcYTGbERI01qFOVgLrZmH6et2zNLDB7RI4KVkTuKfsKfzAkj/UNsHIKbzjTxGuFkUX1Z/eYJBk6/YEKMSjhVr+bvpEaV3rY=
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=VFXehhq7; arc=none smtp.client-ip=192.198.163.18
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="VFXehhq7"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
  t=1743696056; x=1775232056;
  h=from:to:cc:subject:date:message-id:in-reply-to:
   references:mime-version:content-transfer-encoding;
  bh=zi/0itXjLWX25lyreRTOs04H8X0b6Vm47Emh2xv1hAA=;
  b=VFXehhq7B2S5nZ+rmas56ne7alcZlntP2jbQRtC1hFm1uMyGV3YYWRP0
   e0Di7k2z1FC347EYBUMveGSLajZBx6RtWR7j15ebzU7Vasa+uVm99fZMg
   7g32vIZGt8ueY1OZpy7e1fIO8jseasbyyvBqWHsph3nPuxClAtpLIxPHn
   SqygVy42NAEQ5P1lQVtSqcCae339Q988HXhPka870PsdniJKu3GUKAEsz
   bNBY0iN/pe+XYOefhxuKrXBla4RpKMMy1zNAnGGhzFl7lCvs65Fx1Klv3
   qShYGDytToKy47Rm5uXAga1JQ+e3ZLnwafP4/FNYYsLBplC3MBHBpLJbi
   A==;
X-CSE-ConnectionGUID: YR120+xpQF2OHWZKxkDnuQ==
X-CSE-MsgGUID: Zvm5LHJlSligPmcKQONJWQ==
X-IronPort-AV: E=McAfee;i="6700,10204,11393"; a="44369234"
X-IronPort-AV: E=Sophos;i="6.15,184,1739865600";
   d="scan'208";a="44369234"
Received: from fmviesa001.fm.intel.com ([10.60.135.141])
  by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 03 Apr 2025 09:00:52 -0700
X-CSE-ConnectionGUID: BLo9hNJPTIe+0GcLGLcoxQ==
X-CSE-MsgGUID: NXJHmboGS52qmYKbTNXC/g==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.15,184,1739865600";
   d="scan'208";a="158036300"
Received: from black.fi.intel.com ([10.237.72.28])
  by fmviesa001.fm.intel.com with ESMTP; 03 Apr 2025 09:00:37 -0700
Received: by black.fi.intel.com (Postfix, from userid 1003)
	id 53AE1245; Thu, 03 Apr 2025 19:00:36 +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 v2 4/6] gpiolib: acpi: Rename par to params for better
 readability
Date: Thu,  3 Apr 2025 18:59:15 +0300
Message-ID: <20250403160034.2680485-5-andriy.shevchenko@linux.intel.com>
X-Mailer: git-send-email 2.47.2
In-Reply-To: <20250403160034.2680485-1-andriy.shevchenko@linux.intel.com>
References: <20250403160034.2680485-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"

Rename par to params for better readability in acpi_get_driver_gpio_data().
No functional changes intended.

Requested-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mika Westerberg <westeri@kernel.org>
---
 drivers/gpio/gpiolib-acpi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index afeb8d1c7102..d6e9563d9364 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -653,12 +653,12 @@ static bool acpi_get_driver_gpio_data(struct acpi_dev=
ice *adev,
=20
 	for (gm =3D adev->driver_gpios; gm->name; gm++)
 		if (!strcmp(name, gm->name) && gm->data && index < gm->size) {
-			const struct acpi_gpio_params *par =3D gm->data + index;
+			const struct acpi_gpio_params *params =3D gm->data + index;
=20
 			args->fwnode =3D acpi_fwnode_handle(adev);
-			args->args[0] =3D par->crs_entry_index;
-			args->args[1] =3D par->line_index;
-			args->args[2] =3D par->active_low;
+			args->args[0] =3D params->crs_entry_index;
+			args->args[1] =3D params->line_index;
+			args->args[2] =3D params->active_low;
 			args->nargs =3D 3;
=20
 			*quirks =3D gm->quirks;
--=20
2.47.2
From nobody Tue May  6 16:17:20 2025
Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8])
	(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 3E673149C4A;
	Thu,  3 Apr 2025 16:00:43 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
 arc=none smtp.client-ip=192.198.163.8
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1743696047; cv=none;
 b=dYD5y0aLqhqaH6WfN5GgIU/q8rEyVrQvMXo+4/a9BJ4wEQb8QpHN8Xm1ZoIo4KqE2KddSYAnxlUxNiaXAbXBiLUonznVTHXMMiGMiVv3TTdzDb04wvn3XWvjoUvMQm77TcrJXycdbmF2mBsY9QIC3hydwQ1TxboFEqBoPZwHTN0=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1743696047; c=relaxed/simple;
	bh=LRKHiTtshFgZNPJAnBtQFUQlju7HJJJmlBxX+E467Rk=;
	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version;
 b=U2+jAqoS7qPLizdSI2b4Zhtng9LJNNg83D5aMEi0KXzbOQ8DmxuT/X4L1pgA+egR1eahsqAQzN2obWGgzDcGVC+Ltbx14XRHuz044KqlBcU0Nxs36UIPkit7660/NF2p95x5qGOLpteDoWpnJhBlLPbJ+PCRsx1hdGhy1MHE1S4=
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=emFq9L13; arc=none smtp.client-ip=192.198.163.8
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="emFq9L13"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
  t=1743696045; x=1775232045;
  h=from:to:cc:subject:date:message-id:in-reply-to:
   references:mime-version:content-transfer-encoding;
  bh=LRKHiTtshFgZNPJAnBtQFUQlju7HJJJmlBxX+E467Rk=;
  b=emFq9L13ouZ/xrrO6iEYGo6OTKimakJaa6zdbxbHp6tl4iHs2tIhusax
   dKYU2V1C8OAqT0kB9Le8hlUoIAN4Aw9+1bidX6KLxBimkE7Xn6SO0N5zm
   deFkRGJdCyppbAMw67O7W4L+go4F+qlTMzB2tGy9eXfZqitUvGh+hnSE0
   q07yUXKosralcTFI8+0a44c5STFoooM3/skLd5rDy0sGuYs2KatVq5UvJ
   2m1aUNIP8MV7AzhjRFyxYma7PlMPEN9NCubbVLjjtJpD2vYGjyesFAQog
   HTWplFQJ/WLm6Y/GzRKzNwxvGnYGu2Y0EqQDR2zUhAMC3U1FQeQB3nVVx
   g==;
X-CSE-ConnectionGUID: wmu0i06mShu3hetYVdT6ng==
X-CSE-MsgGUID: 3pGfKlitQtClay2FLIeydA==
X-IronPort-AV: E=McAfee;i="6700,10204,11393"; a="62651612"
X-IronPort-AV: E=Sophos;i="6.15,184,1739865600";
   d="scan'208";a="62651612"
Received: from orviesa004.jf.intel.com ([10.64.159.144])
  by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 03 Apr 2025 09:00:43 -0700
X-CSE-ConnectionGUID: bxS8qnZDTXmXnLH8gNkq1A==
X-CSE-MsgGUID: x23ln8zdQyqUV+IHsuR3hA==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.15,184,1739865600";
   d="scan'208";a="132029475"
Received: from black.fi.intel.com ([10.237.72.28])
  by orviesa004.jf.intel.com with ESMTP; 03 Apr 2025 09:00:40 -0700
Received: by black.fi.intel.com (Postfix, from userid 1003)
	id 5F9C726F; Thu, 03 Apr 2025 19:00:36 +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 v2 5/6] gpiolib: acpi: Reuse struct acpi_gpio_params in struct
 acpi_gpio_lookup
Date: Thu,  3 Apr 2025 18:59:16 +0300
Message-ID: <20250403160034.2680485-6-andriy.shevchenko@linux.intel.com>
X-Mailer: git-send-email 2.47.2
In-Reply-To: <20250403160034.2680485-1-andriy.shevchenko@linux.intel.com>
References: <20250403160034.2680485-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>
Acked-by: Mika Westerberg <westeri@kernel.org>
---
 drivers/gpio/gpiolib-acpi.c | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index d6e9563d9364..f44d25df15cb 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 params;
 	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 *params =3D &lookup->params;
=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++;
+			params->crs_entry_index++;
=20
-		if (lookup->n++ !=3D lookup->index)
+		if (lookup->n++ !=3D params->crs_entry_index)
 			return 1;
=20
-		pin_index =3D lookup->pin_index;
+		pin_index =3D params->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 params->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 *params =3D &lookup->params;
+	unsigned int index =3D params->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];
+	params->crs_entry_index =3D args.args[0];
+	params->line_index =3D args.args[1];
+	params->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 *params =3D &lookup.params;
 	int ret;
=20
 	memset(&lookup, 0, sizeof(lookup));
-	lookup.index =3D index;
+	params->crs_entry_index =3D index;
=20
 	if (propname) {
 		dev_dbg(&adev->dev, "GPIO: looking up %s\n", propname);
@@ -909,11 +910,11 @@ static struct gpio_desc *acpi_get_gpiod_by_index(stru=
ct 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),
+			params->crs_entry_index, params->line_index, params->active_low);
 	} else {
-		dev_dbg(&adev->dev, "GPIO: looking up %d in _CRS\n", index);
+		dev_dbg(&adev->dev, "GPIO: looking up %u in _CRS\n", params->crs_entry_i=
ndex);
 		lookup.info.adev =3D adev;
 	}
=20
@@ -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 *params =3D &lookup.params;
 	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;
+	params->crs_entry_index =3D index;
=20
 	ret =3D acpi_gpio_property_lookup(fwnode, propname, &lookup);
 	if (ret)
--=20
2.47.2
From nobody Tue May  6 16:17:20 2025
Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18])
	(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 D205F25179E;
	Thu,  3 Apr 2025 16:00:56 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
 arc=none smtp.client-ip=192.198.163.18
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1743696058; cv=none;
 b=I1KDHxZddGkc2scNDD7VeUvNjWNhu0+iZe2ZXCMq7ilhE/O31tXs79kO+kjIK/swZ5LkVx6r1aUVA7rWZZTVy1Q5a7Jq2ATI7dvf4kqUqFlNOId1ODPUeKjHbdIyCx4UA8TtifTPFkWfRtOLS+s9EFRJS7TOqFtFLyOqO9bIR0w=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1743696058; c=relaxed/simple;
	bh=XODY8LfdrBtTcIIHyGQ5a/GmoObL2peM0YKaifcX+Z0=;
	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version;
 b=ZpNN9j184H62MiwCsKbmq59dazXLXL6/wS9PIGwjFjafvwQIULsphIZVjCZ04Cnae7TfQXJg9DdIakMKBrR9NMW/dW2m4TWpd4NL+L6bpUqSxGWPhqoggW79vsiafYSxc6ysgFltoWMUAZGn1rujzD+tQ+Go1ZRFvxsD71yPxDg=
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=efVUOZTZ; arc=none smtp.client-ip=192.198.163.18
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="efVUOZTZ"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
  t=1743696057; x=1775232057;
  h=from:to:cc:subject:date:message-id:in-reply-to:
   references:mime-version:content-transfer-encoding;
  bh=XODY8LfdrBtTcIIHyGQ5a/GmoObL2peM0YKaifcX+Z0=;
  b=efVUOZTZT4qHO5KOP3Bkut7PGhuGPcoCFkipOeIeSCFK3U/MyM0/pdsu
   tRWuiPlUiwAS2Ze3apPAsCAx98F005LMTE9CZwrvoemJ6LbzODoRoHYi4
   eypyB/e1YdzdtV9HZ9epXjd4i6BQJv3ycB3PFt2aeEMLl7EOUXrdFAZmJ
   1S9KbITf7FD8H63fSIOSCBVsxqQv9HzEO2e3pLduKusZ7Ely3F9l5k2yT
   Yrp5kmnnCd70ke48fnbxY0jD9NRNWbi60SOr0vy4CM8U55E6HlisrTpUT
   JLp/9IagQFnso8+9V75zI3Ww6swmuB34wv3g+KoCJMHzf6/J5IvYiEZIn
   A==;
X-CSE-ConnectionGUID: Id1E0ArfSyaZESThz5xHEg==
X-CSE-MsgGUID: nPH7LXQSS3CtYVCVV8Ywsg==
X-IronPort-AV: E=McAfee;i="6700,10204,11393"; a="44369247"
X-IronPort-AV: E=Sophos;i="6.15,184,1739865600";
   d="scan'208";a="44369247"
Received: from fmviesa001.fm.intel.com ([10.60.135.141])
  by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 03 Apr 2025 09:00:52 -0700
X-CSE-ConnectionGUID: 20RZYshrQnuU/FUkhE9Lfg==
X-CSE-MsgGUID: Cvuzk59KQf6orkTLlN2Jqw==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.15,184,1739865600";
   d="scan'208";a="158036305"
Received: from black.fi.intel.com ([10.237.72.28])
  by fmviesa001.fm.intel.com with ESMTP; 03 Apr 2025 09:00:40 -0700
Received: by black.fi.intel.com (Postfix, from userid 1003)
	id 6F7D4283; Thu, 03 Apr 2025 19:00:36 +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 v2 6/6] gpiolib: acpi: Deduplicate some code in
 __acpi_find_gpio()
Date: Thu,  3 Apr 2025 18:59:17 +0300
Message-ID: <20250403160034.2680485-7-andriy.shevchenko@linux.intel.com>
X-Mailer: git-send-email 2.47.2
In-Reply-To: <20250403160034.2680485-1-andriy.shevchenko@linux.intel.com>
References: <20250403160034.2680485-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>
Acked-by: Mika Westerberg <westeri@kernel.org>
---
 drivers/gpio/gpiolib-acpi.c | 101 +++++++++++++++++-------------------
 1 file changed, 48 insertions(+), 53 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index f44d25df15cb..b3fcb9d5a39f 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 *params =3D &lookup.params;
+	struct acpi_gpio_info *info =3D &lookup->info;
+	struct acpi_gpio_params *params =3D &lookup->params;
 	int ret;
=20
-	memset(&lookup, 0, sizeof(lookup));
-	params->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),
 			params->crs_entry_index, params->line_index, params->active_low);
 	} else {
 		dev_dbg(&adev->dev, "GPIO: looking up %u in _CRS\n", params->crs_entry_i=
ndex);
-		lookup.info.adev =3D adev;
+		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 *params =3D &lookup.params;
 	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));
-	params->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.params.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