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 [thread overview]
Message-ID: <20250403160034.2680485-6-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20250403160034.2680485-1-andriy.shevchenko@linux.intel.com>
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 | 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,
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 *data)
{
struct acpi_gpio_lookup *lookup = data;
+ struct acpi_gpio_params *params = &lookup->params;
if (ares->type != ACPI_RESOURCE_TYPE_GPIO)
return 1;
@@ -765,12 +764,12 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
u16 pin_index;
if (lookup->info.quirks & ACPI_GPIO_QUIRK_ONLY_GPIOIO && gpioint)
- lookup->index++;
+ params->crs_entry_index++;
- if (lookup->n++ != lookup->index)
+ if (lookup->n++ != params->crs_entry_index)
return 1;
- pin_index = lookup->pin_index;
+ pin_index = params->line_index;
if (pin_index >= agpio->pin_table_length)
return 1;
@@ -796,7 +795,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
lookup->info.polarity = agpio->polarity;
lookup->info.triggering = agpio->triggering;
} else {
- lookup->info.polarity = lookup->active_low;
+ lookup->info.polarity = params->active_low;
}
lookup->info.flags = acpi_gpio_to_gpiod_flags(agpio, lookup->info.polarity);
@@ -834,7 +833,8 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode, const char *p
struct acpi_gpio_lookup *lookup)
{
struct fwnode_reference_args args;
- unsigned int index = lookup->index;
+ struct acpi_gpio_params *params = &lookup->params;
+ unsigned int index = params->crs_entry_index;
unsigned int quirks = 0;
int ret;
@@ -857,9 +857,9 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode, const char *p
if (args.nargs != 3)
return -EPROTO;
- lookup->index = args.args[0];
- lookup->pin_index = args.args[1];
- lookup->active_low = !!args.args[2];
+ params->crs_entry_index = args.args[0];
+ params->line_index = args.args[1];
+ params->active_low = !!args.args[2];
lookup->info.adev = to_acpi_device_node(args.fwnode);
lookup->info.quirks = quirks;
@@ -897,10 +897,11 @@ static struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev,
struct acpi_gpio_info *info)
{
struct acpi_gpio_lookup lookup;
+ struct acpi_gpio_params *params = &lookup.params;
int ret;
memset(&lookup, 0, sizeof(lookup));
- lookup.index = index;
+ params->crs_entry_index = index;
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(struct acpi_device *adev,
if (ret)
return ERR_PTR(ret);
- 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_index);
lookup.info.adev = adev;
}
@@ -943,6 +944,7 @@ static struct gpio_desc *acpi_get_gpiod_from_data(struct fwnode_handle *fwnode,
struct acpi_gpio_info *info)
{
struct acpi_gpio_lookup lookup;
+ struct acpi_gpio_params *params = &lookup.params;
int ret;
if (!is_acpi_data_node(fwnode))
@@ -952,7 +954,7 @@ static struct gpio_desc *acpi_get_gpiod_from_data(struct fwnode_handle *fwnode,
return ERR_PTR(-EINVAL);
memset(&lookup, 0, sizeof(lookup));
- lookup.index = index;
+ params->crs_entry_index = index;
ret = acpi_gpio_property_lookup(fwnode, propname, &lookup);
if (ret)
--
2.47.2
next prev parent reply other threads:[~2025-04-03 16:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-03 15:59 [PATCH v2 0/6] gpiolib: acpi: Refactor to shrink the code by ~8% Andy Shevchenko
2025-04-03 15:59 ` [PATCH v2 1/6] gpiolib: acpi: Improve struct acpi_gpio_info memory footprint Andy Shevchenko
2025-04-03 15:59 ` [PATCH v2 2/6] gpiolib: acpi: Remove index parameter from acpi_gpio_property_lookup() Andy Shevchenko
2025-04-03 15:59 ` [PATCH v2 3/6] gpiolib: acpi: Reduce memory footprint for struct acpi_gpio_params Andy Shevchenko
2025-04-03 15:59 ` [PATCH v2 4/6] gpiolib: acpi: Rename par to params for better readability Andy Shevchenko
2025-04-03 15:59 ` Andy Shevchenko [this message]
2025-04-03 15:59 ` [PATCH v2 6/6] gpiolib: acpi: Deduplicate some code in __acpi_find_gpio() Andy Shevchenko
2025-04-08 20:09 ` Kees Bakker
2025-04-09 7:31 ` Andy Shevchenko
2025-04-04 4:43 ` [PATCH v2 0/6] gpiolib: acpi: Refactor to shrink the code by ~8% Mika Westerberg
2025-04-07 6:41 ` Andy Shevchenko
2025-04-04 8:38 ` Bartosz Golaszewski
2025-04-04 10:23 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250403160034.2680485-6-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=bartosz.golaszewski@linaro.org \
--cc=brgl@bgdev.pl \
--cc=linus.walleij@linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=westeri@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).