Skip to contentSkip to conversation

gpiolib: acpi: Split quirks to its own file

PATCH In review Andy Shevchenko 4 participants 16 messages May 13, 2025 – May 15, 2025

Subsystems (3)
lore
Share & tools
lore

Andy Shevchenko

author maintainer
#0 lore raw

cover gpiolib: acpi: Split quirks to its own file

The GPIO ACPI helpers use a few quirks which consumes approximately 20% of the file. Besides that the necessary bits are sparse and being directly referred. Split them to a separate file. There is no functional change.

For the new file I used the Hans' authorship of Hans as he the author of all those bits (expect very tiny changes made by this series).

Hans, please check if it's okay and confirm, or suggest better alternative.

Andy Shevchenko (4):
gpiolib: acpi: Switch to use enum in acpi_gpio_in_ignore_list()
gpiolib: acpi: Handle deferred list via new API
gpiolib: acpi: Add acpi_gpio_need_run_edge_events_on_boot() getter
gpiolib: acpi: Move quirks to a separate file

 drivers/gpio/Makefile                         |   1 +
 .../{gpiolib-acpi.c => gpiolib-acpi-core.c}   | 344 +----------------
 drivers/gpio/gpiolib-acpi-quirks.c            | 363 ++++++++++++++++++
 drivers/gpio/gpiolib-acpi.h                   |  15 +
 4 files changed, 392 insertions(+), 331 deletions(-)
 rename drivers/gpio/{gpiolib-acpi.c => gpiolib-acpi-core.c} (79%)
 create mode 100644 drivers/gpio/gpiolib-acpi-quirks.c
Signature · 1 line
2.47.2
author maintainer
#1 lore raw

PATCH 1/4 gpiolib: acpi: Switch to use enum in acpi_gpio_in_ignore_list()

Switch to use enum instead of pointers in acpi_gpio_in_ignore_list() which moves towards isolating the GPIO ACPI and quirk APIs. It will helps splitting them completely in the next changes.

No functional changes.

---
 drivers/gpio/gpiolib-acpi.c | 21 ++++++++++++++++-----
 drivers/gpio/gpiolib-acpi.h |  8 ++++++++
 2 files changed, 24 insertions(+), 5 deletions(-)
drivers/gpio/gpiolib-acpi.c +16 -5
index 3c9535d767e7..fb573b5f0ba1 100644
@@ -350,14 +350,25 @@ static struct gpio_desc *acpi_request_own_gpiod(struct gpio_chip *chip,
 	return desc;
 }
 
-static bool acpi_gpio_in_ignore_list(const char *ignore_list, const char *controller_in,
-				     unsigned int pin_in)
+bool acpi_gpio_in_ignore_list(enum acpi_gpio_ignore_list list, const char *controller_in,
+			      unsigned int pin_in)
 {
-	const char *controller, *pin_str;
+	const char *ignore_list, *controller, *pin_str;
 	unsigned int pin;
 	char *endp;
 	int len;
 
+	switch (list) {
+	case ACPI_GPIO_IGNORE_WAKE:
+		ignore_list = ignore_wake;
+		break;
+	case ACPI_GPIO_IGNORE_INTERRUPT:
+		ignore_list = ignore_interrupt;
+		break;
+	default:
+		return false;
+	}
+
 	controller = ignore_list;
 	while (controller) {
 		pin_str = strchr(controller, '@');
@@ -394,7 +405,7 @@ static bool acpi_gpio_irq_is_wake(struct device *parent,
 	if (agpio->wake_capable != ACPI_WAKE_CAPABLE)
 		return false;
 
-	if (acpi_gpio_in_ignore_list(ignore_wake, dev_name(parent), pin)) {
+	if (acpi_gpio_in_ignore_list(ACPI_GPIO_IGNORE_WAKE, dev_name(parent), pin)) {
 		dev_info(parent, "Ignoring wakeup on pin %u\n", pin);
 		return false;
 	}
@@ -437,7 +448,7 @@ static acpi_status acpi_gpiochip_alloc_event(struct acpi_resource *ares,
 	if (!handler)
 		return AE_OK;
 
-	if (acpi_gpio_in_ignore_list(ignore_interrupt, dev_name(chip->parent), pin)) {
+	if (acpi_gpio_in_ignore_list(ACPI_GPIO_IGNORE_INTERRUPT, dev_name(chip->parent), pin)) {
 		dev_info(chip->parent, "Ignoring interrupt on pin %u\n", pin);
 		return AE_OK;
 	}
drivers/gpio/gpiolib-acpi.h +8 -0
index 7e1c51d04040..ef0b1a3c85d7 100644
@@ -58,4 +58,12 @@ static inline int acpi_gpio_count(const struct fwnode_handle *fwnode,
 }
 #endif
 
+enum acpi_gpio_ignore_list {
+	ACPI_GPIO_IGNORE_WAKE,
+	ACPI_GPIO_IGNORE_INTERRUPT,
+};
+
+bool acpi_gpio_in_ignore_list(enum acpi_gpio_ignore_list list,
+			      const char *controller_in, unsigned int pin_in);
+
 #endif /* GPIOLIB_ACPI_H */
Signature · 1 line
2.47.2
author maintainer
#2 lore raw

PATCH 2/4 gpiolib: acpi: Handle deferred list via new API

In reply to Andy Shevchenko

Introduce a new API and handle deferred list via it which moves towards isolating the GPIO ACPI and quirk APIs. It will helps splitting them completely in the next changes.

No functional changes.

---
 drivers/gpio/gpiolib-acpi.c | 52 +++++++++++++++++++++++--------------
 drivers/gpio/gpiolib-acpi.h |  5 ++++
 2 files changed, 37 insertions(+), 20 deletions(-)
drivers/gpio/gpiolib-acpi.c +32 -20
index fb573b5f0ba1..ac5f8ec6e72b 100644
@@ -350,6 +350,27 @@ static struct gpio_desc *acpi_request_own_gpiod(struct gpio_chip *chip,
 	return desc;
 }
 
+bool acpi_gpio_add_to_deferred_list(struct list_head *list)
+{
+	bool defer;
+
+	mutex_lock(&acpi_gpio_deferred_req_irqs_lock);
+	defer = !acpi_gpio_deferred_req_irqs_done;
+	if (defer)
+		list_add(list, &acpi_gpio_deferred_req_irqs_list);
+	mutex_unlock(&acpi_gpio_deferred_req_irqs_lock);
+
+	return defer;
+}
+
+void acpi_gpio_remove_from_deferred_list(struct list_head *list)
+{
+	mutex_lock(&acpi_gpio_deferred_req_irqs_lock);
+	if (!list_empty(list))
+		list_del_init(list);
+	mutex_unlock(&acpi_gpio_deferred_req_irqs_lock);
+}
+
 bool acpi_gpio_in_ignore_list(enum acpi_gpio_ignore_list list, const char *controller_in,
 			      unsigned int pin_in)
 {
@@ -536,7 +557,6 @@ void acpi_gpiochip_request_interrupts(struct gpio_chip *chip)
 	struct acpi_gpio_chip *acpi_gpio;
 	acpi_handle handle;
 	acpi_status status;
-	bool defer;
 
 	if (!chip->parent || !chip->to_irq)
 		return;
@@ -555,14 +575,7 @@ void acpi_gpiochip_request_interrupts(struct gpio_chip *chip)
 	acpi_walk_resources(handle, METHOD_NAME__AEI,
 			    acpi_gpiochip_alloc_event, acpi_gpio);
 
-	mutex_lock(&acpi_gpio_deferred_req_irqs_lock);
-	defer = !acpi_gpio_deferred_req_irqs_done;
-	if (defer)
-		list_add(&acpi_gpio->deferred_req_irqs_list_entry,
-			 &acpi_gpio_deferred_req_irqs_list);
-	mutex_unlock(&acpi_gpio_deferred_req_irqs_lock);
-
-	if (defer)
+	if (acpi_gpio_add_to_deferred_list(&acpi_gpio->deferred_req_irqs_list_entry))
 		return;
 
 	acpi_gpiochip_request_irqs(acpi_gpio);
@@ -594,10 +607,7 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip)
 	if (ACPI_FAILURE(status))
 		return;
 
-	mutex_lock(&acpi_gpio_deferred_req_irqs_lock);
-	if (!list_empty(&acpi_gpio->deferred_req_irqs_list_entry))
-		list_del_init(&acpi_gpio->deferred_req_irqs_list_entry);
-	mutex_unlock(&acpi_gpio_deferred_req_irqs_lock);
+	acpi_gpio_remove_from_deferred_list(&acpi_gpio->deferred_req_irqs_list_entry);
 
 	list_for_each_entry_safe_reverse(event, ep, &acpi_gpio->events, node) {
 		if (event->irq_requested) {
@@ -615,6 +625,14 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip)
 }
 EXPORT_SYMBOL_GPL(acpi_gpiochip_free_interrupts);
 
+void __init acpi_gpio_process_deferred_list(struct list_head *list)
+{
+	struct acpi_gpio_chip *acpi_gpio, *tmp;
+
+	list_for_each_entry_safe(acpi_gpio, tmp, list, deferred_req_irqs_list_entry)
+		acpi_gpiochip_request_irqs(acpi_gpio);
+}
+
 int acpi_dev_add_driver_gpios(struct acpi_device *adev,
 			      const struct acpi_gpio_mapping *gpios)
 {
@@ -1503,14 +1521,8 @@ int acpi_gpio_count(const struct fwnode_handle *fwnode, const char *con_id)
 /* Run deferred acpi_gpiochip_request_irqs() */
 static int __init acpi_gpio_handle_deferred_request_irqs(void)
 {
-	struct acpi_gpio_chip *acpi_gpio, *tmp;
-
 	mutex_lock(&acpi_gpio_deferred_req_irqs_lock);
-	list_for_each_entry_safe(acpi_gpio, tmp,
-				 &acpi_gpio_deferred_req_irqs_list,
-				 deferred_req_irqs_list_entry)
-		acpi_gpiochip_request_irqs(acpi_gpio);
-
+	acpi_gpio_process_deferred_list(&acpi_gpio_deferred_req_irqs_list);
 	acpi_gpio_deferred_req_irqs_done = true;
 	mutex_unlock(&acpi_gpio_deferred_req_irqs_lock);
 
drivers/gpio/gpiolib-acpi.h +5 -0
index ef0b1a3c85d7..8249977e6140 100644
@@ -58,6 +58,11 @@ static inline int acpi_gpio_count(const struct fwnode_handle *fwnode,
 }
 #endif
 
+void acpi_gpio_process_deferred_list(struct list_head *list);
+
+bool acpi_gpio_add_to_deferred_list(struct list_head *list);
+void acpi_gpio_remove_from_deferred_list(struct list_head *list);
+
 enum acpi_gpio_ignore_list {
 	ACPI_GPIO_IGNORE_WAKE,
 	ACPI_GPIO_IGNORE_INTERRUPT,
Signature · 1 line
2.47.2
author maintainer
#3 lore raw

PATCH 3/4 gpiolib: acpi: Add acpi_gpio_need_run_edge_events_on_boot() getter

In reply to Andy Shevchenko

Add acpi_gpio_need_run_edge_events_on_boot() getter which moves towards isolating the GPIO ACPI and quirk APIs. It will helps splitting them completely in the next changes.

No functional changes.

---
 drivers/gpio/gpiolib-acpi.c | 7 ++++++-
 drivers/gpio/gpiolib-acpi.h | 2 ++
 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/gpio/gpiolib-acpi.c +6 -1
index ac5f8ec6e72b..609e3a7f9636 100644
@@ -268,7 +268,7 @@ static void acpi_gpiochip_request_irq(struct acpi_gpio_chip *acpi_gpio,
 	event->irq_requested = true;
 
 	/* Make sure we trigger the initial state of edge-triggered IRQs */
-	if (run_edge_events_on_boot &&
+	if (acpi_gpio_need_run_edge_events_on_boot() &&
 	    (event->irqflags & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING))) {
 		value = gpiod_get_raw_value_cansleep(event->desc);
 		if (((event->irqflags & IRQF_TRIGGER_RISING) && value == 1) ||
@@ -371,6 +371,11 @@ void acpi_gpio_remove_from_deferred_list(struct list_head *list)
 	mutex_unlock(&acpi_gpio_deferred_req_irqs_lock);
 }
 
+int acpi_gpio_need_run_edge_events_on_boot(void)
+{
+	return run_edge_events_on_boot;
+}
+
 bool acpi_gpio_in_ignore_list(enum acpi_gpio_ignore_list list, const char *controller_in,
 			      unsigned int pin_in)
 {
drivers/gpio/gpiolib-acpi.h +2 -0
index 8249977e6140..a90267470a4e 100644
@@ -63,6 +63,8 @@ void acpi_gpio_process_deferred_list(struct list_head *list);
 bool acpi_gpio_add_to_deferred_list(struct list_head *list);
 void acpi_gpio_remove_from_deferred_list(struct list_head *list);
 
+int acpi_gpio_need_run_edge_events_on_boot(void);
+
 enum acpi_gpio_ignore_list {
 	ACPI_GPIO_IGNORE_WAKE,
 	ACPI_GPIO_IGNORE_INTERRUPT,
Signature · 1 line
2.47.2
author maintainer
#4 lore raw

PATCH 4/4 gpiolib: acpi: Move quirks to a separate file

In reply to Andy Shevchenko

The gpiolib-acpi.c is huge enough even without DMI quirks. Move them to a separate file for a better maintenance.

No functional change intended.

---
 drivers/gpio/Makefile                         |   1 +
 .../{gpiolib-acpi.c => gpiolib-acpi-core.c}   | 346 -----------------
 drivers/gpio/gpiolib-acpi-quirks.c            | 363 ++++++++++++++++++
 3 files changed, 364 insertions(+), 346 deletions(-)
 rename drivers/gpio/{gpiolib-acpi.c => gpiolib-acpi-core.c} (79%)
 create mode 100644 drivers/gpio/gpiolib-acpi-quirks.c
drivers/gpio/Makefile +1 -0
index 9aabbb9cb4c6..7b4ba3475f0b 100644
@@ -10,6 +10,7 @@ obj-$(CONFIG_OF_GPIO)		+= gpiolib-of.o
 obj-$(CONFIG_GPIO_CDEV)		+= gpiolib-cdev.o
 obj-$(CONFIG_GPIO_SYSFS)	+= gpiolib-sysfs.o
 obj-$(CONFIG_GPIO_ACPI)		+= gpiolib-acpi.o
+gpiolib-acpi-y			:= gpiolib-acpi-core.o gpiolib-acpi-quirks.o
 obj-$(CONFIG_GPIOLIB)		+= gpiolib-swnode.o
 
 # Device drivers. Generally keep list sorted alphabetically
drivers/gpio/gpiolib-acpi-core.c renamed from drivers/gpio/gpiolib-acpi.c +0 -346

367 lines not on this page · raw message

drivers/gpio/gpiolib-acpi-quirks.c new file +363 -0

363 lines not on this page · raw message

Signature · 1 line
2.47.2
Reviewed-by on the v1 series
#5 lore raw
In reply to Andy Shevchenko

Hi,

Quoted 8 lines · Andy Shevchenko

The GPIO ACPI helpers use a few quirks which consumes approximately 20% of the file. Besides that the necessary bits are sparse and being directly referred. Split them to a separate file. There is no functional change.

For the new file I used the Hans' authorship of Hans as he the author of all those bits (expect very tiny changes made by this series).

Hans, please check if it's okay and confirm, or suggest better alternative.

Thanks, the entire series looks good to me:

Regards,

Hans

Quoted 14 lines

Andy Shevchenko (4):
gpiolib: acpi: Switch to use enum in acpi_gpio_in_ignore_list()
gpiolib: acpi: Handle deferred list via new API
gpiolib: acpi: Add acpi_gpio_need_run_edge_events_on_boot() getter
gpiolib: acpi: Move quirks to a separate file

 drivers/gpio/Makefile                         |   1 +
 .../{gpiolib-acpi.c => gpiolib-acpi-core.c}   | 344 +----------------
 drivers/gpio/gpiolib-acpi-quirks.c            | 363 ++++++++++++++++++
 drivers/gpio/gpiolib-acpi.h                   |  15 +
 4 files changed, 392 insertions(+), 331 deletions(-)
 rename drivers/gpio/{gpiolib-acpi.c => gpiolib-acpi-core.c} (79%)
 create mode 100644 drivers/gpio/gpiolib-acpi-quirks.c
#6 lore raw
In reply to Andy Shevchenko
Quoted 15 lines · Andy Shevchenko

The GPIO ACPI helpers use a few quirks which consumes approximately 20% of the file. Besides that the necessary bits are sparse and being directly referred. Split them to a separate file. There is no functional change.

For the new file I used the Hans' authorship of Hans as he the author of all those bits (expect very tiny changes made by this series).

Hans, please check if it's okay and confirm, or suggest better alternative.

Andy Shevchenko (4):
gpiolib: acpi: Switch to use enum in acpi_gpio_in_ignore_list()
gpiolib: acpi: Handle deferred list via new API
gpiolib: acpi: Add acpi_gpio_need_run_edge_events_on_boot() getter
gpiolib: acpi: Move quirks to a separate file

Quoted 4 lines
 drivers/gpio/Makefile                         |   1 +
 .../{gpiolib-acpi.c => gpiolib-acpi-core.c}   | 344 +----------------
 drivers/gpio/gpiolib-acpi-quirks.c            | 363 ++++++++++++++++++
 drivers/gpio/gpiolib-acpi.h                   |  15 +

All this -foo-core things look redundant to me. Why not just split it out and call it gpiolib-quirks.c and put there all the quirks not just ACPI? I Don't think we want to have gpiolib-of-quirks.c and gpiolog-swnode-quirks.c and so on.

Quoted 6 lines
 4 files changed, 392 insertions(+), 331 deletions(-)
 rename drivers/gpio/{gpiolib-acpi.c => gpiolib-acpi-core.c} (79%)
 create mode 100644 drivers/gpio/gpiolib-acpi-quirks.c
Signature · 1 line
2.47.2
#7 lore raw
Quoted 9 lines · Mika Westerberg
Quoted 4 lines
 drivers/gpio/Makefile                         |   1 +
 .../{gpiolib-acpi.c => gpiolib-acpi-core.c}   | 344 +----------------
 drivers/gpio/gpiolib-acpi-quirks.c            | 363 ++++++++++++++++++
 drivers/gpio/gpiolib-acpi.h                   |  15 +

All this -foo-core things look redundant to me. Why not just split it out and call it gpiolib-quirks.c and put there all the quirks not just ACPI? I Don't think we want to have gpiolib-of-quirks.c and gpiolog-swnode-quirks.c and so on.

For OF/device tree the quirks are in gpiolib-of.c and we probably do not want to put these into a shared file with ACPI (and swnode?) quirks as systems with OF compile objects (Makefile entries) and ACPI compile objects are not always included in the same build, so having them per-hw-config-principle cuts down compiletime overhead. Also it's pretty clear separation of concerns I think.

Yours,
Linus Walleij

author maintainer
#8 lore raw
Quoted 13 lines · Linus Walleij
Quoted 9 lines · Mika Westerberg
Quoted 4 lines
 drivers/gpio/Makefile                         |   1 +
 .../{gpiolib-acpi.c => gpiolib-acpi-core.c}   | 344 +----------------
 drivers/gpio/gpiolib-acpi-quirks.c            | 363 ++++++++++++++++++
 drivers/gpio/gpiolib-acpi.h                   |  15 +

All this -foo-core things look redundant to me. Why not just split it out and call it gpiolib-quirks.c and put there all the quirks not just ACPI? I Don't think we want to have gpiolib-of-quirks.c and gpiolog-swnode-quirks.c and so on.

Quoted 6 lines

For OF/device tree the quirks are in gpiolib-of.c and we probably do not want to put these into a shared file with ACPI (and swnode?) quirks as systems with OF compile objects (Makefile entries) and ACPI compile objects are not always included in the same build, so having them per-hw-config-principle cuts down compiletime overhead. Also it's pretty clear separation of concerns I think.

Yes, gpiolib-quirks.c would make sense for the shared code, but I don't expect we will have any reasonable amount of those that are shared between ACPI, DT, swnode cases.

But main problem here is the module parameters that are already exist, there is no clean way in Linux kernel to provide an aliases table when renaming files (AFAIK, otherwise tell me how to achieve that).

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#9 lore raw
In reply to Mika Westerberg
Quoted 21 lines · Mika Westerberg
Quoted 15 lines · Andy Shevchenko

The GPIO ACPI helpers use a few quirks which consumes approximately 20% of the file. Besides that the necessary bits are sparse and being directly referred. Split them to a separate file. There is no functional change.

For the new file I used the Hans' authorship of Hans as he the author of all those bits (expect very tiny changes made by this series).

Hans, please check if it's okay and confirm, or suggest better alternative.

Andy Shevchenko (4):
gpiolib: acpi: Switch to use enum in acpi_gpio_in_ignore_list()
gpiolib: acpi: Handle deferred list via new API
gpiolib: acpi: Add acpi_gpio_need_run_edge_events_on_boot() getter
gpiolib: acpi: Move quirks to a separate file

Quoted 4 lines
 drivers/gpio/Makefile                         |   1 +
 .../{gpiolib-acpi.c => gpiolib-acpi-core.c}   | 344 +----------------
 drivers/gpio/gpiolib-acpi-quirks.c            | 363 ++++++++++++++++++
 drivers/gpio/gpiolib-acpi.h                   |  15 +
Quoted 4 lines

All this -foo-core things look redundant to me. Why not just split it out and call it gpiolib-quirks.c and put there all the quirks not just ACPI? I Don't think we want to have gpiolib-of-quirks.c and gpiolog-swnode-quirks.c and so on.

That's might be the next step to have for all of them, but these are ACPI specific. In any case they can't be put to gpiolib-quirks.c due to module parameters. If we do that we will need a dirty hack to support old module parameters (see 8250 how it's done there, and even author of that didn't like the approach).

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#10 lore raw
Quoted 27 lines · Andy Shevchenko
Quoted 21 lines · Mika Westerberg
Quoted 15 lines · Andy Shevchenko

The GPIO ACPI helpers use a few quirks which consumes approximately 20% of the file. Besides that the necessary bits are sparse and being directly referred. Split them to a separate file. There is no functional change.

For the new file I used the Hans' authorship of Hans as he the author of all those bits (expect very tiny changes made by this series).

Hans, please check if it's okay and confirm, or suggest better alternative.

Andy Shevchenko (4):
gpiolib: acpi: Switch to use enum in acpi_gpio_in_ignore_list()
gpiolib: acpi: Handle deferred list via new API
gpiolib: acpi: Add acpi_gpio_need_run_edge_events_on_boot() getter
gpiolib: acpi: Move quirks to a separate file

Quoted 4 lines
 drivers/gpio/Makefile                         |   1 +
 .../{gpiolib-acpi.c => gpiolib-acpi-core.c}   | 344 +----------------
 drivers/gpio/gpiolib-acpi-quirks.c            | 363 ++++++++++++++++++
 drivers/gpio/gpiolib-acpi.h                   |  15 +
Quoted 4 lines

All this -foo-core things look redundant to me. Why not just split it out and call it gpiolib-quirks.c and put there all the quirks not just ACPI? I Don't think we want to have gpiolib-of-quirks.c and gpiolog-swnode-quirks.c and so on.

Quoted 5 lines

That's might be the next step to have for all of them, but these are ACPI specific. In any case they can't be put to gpiolib-quirks.c due to module parameters. If we do that we will need a dirty hack to support old module parameters (see 8250 how it's done there, and even author of that didn't like the approach).

Hmm, how does it affect module paremeters? I thought they are gpiolib.something as all these object files are linked to it?

At least can we drop the gpiolib-acpi-core.c rename?

author maintainer
#11 lore raw
Quoted 28 lines · Mika Westerberg
Quoted 27 lines · Andy Shevchenko
Quoted 25 lines · Mika Westerberg
Quoted 15 lines · Andy Shevchenko

The GPIO ACPI helpers use a few quirks which consumes approximately 20% of the file. Besides that the necessary bits are sparse and being directly referred. Split them to a separate file. There is no functional change.

For the new file I used the Hans' authorship of Hans as he the author of all those bits (expect very tiny changes made by this series).

Hans, please check if it's okay and confirm, or suggest better alternative.

Andy Shevchenko (4):
gpiolib: acpi: Switch to use enum in acpi_gpio_in_ignore_list()
gpiolib: acpi: Handle deferred list via new API
gpiolib: acpi: Add acpi_gpio_need_run_edge_events_on_boot() getter
gpiolib: acpi: Move quirks to a separate file

Quoted 4 lines
 drivers/gpio/Makefile                         |   1 +
 .../{gpiolib-acpi.c => gpiolib-acpi-core.c}   | 344 +----------------
 drivers/gpio/gpiolib-acpi-quirks.c            | 363 ++++++++++++++++++
 drivers/gpio/gpiolib-acpi.h                   |  15 +

All this -foo-core things look redundant to me. Why not just split it out and call it gpiolib-quirks.c and put there all the quirks not just ACPI? I Don't think we want to have gpiolib-of-quirks.c and gpiolog-swnode-quirks.c and so on.

Quoted 8 lines
Quoted 5 lines

That's might be the next step to have for all of them, but these are ACPI specific. In any case they can't be put to gpiolib-quirks.c due to module parameters. If we do that we will need a dirty hack to support old module parameters (see 8250 how it's done there, and even author of that didn't like the approach).

Hmm, how does it affect module paremeters? I thought they are gpiolib.something as all these object files are linked to it?

gpiolib_acpi.FOO because the object file is gpiolib-acpi.o.

Quoted 1 line

At least can we drop the gpiolib-acpi-core.c rename?

Unfortunately no due to the above.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#12 lore raw
Quoted 35 lines · Andy Shevchenko
Quoted 34 lines · Mika Westerberg
Quoted 32 lines · Andy Shevchenko
Quoted 21 lines · Mika Westerberg
Quoted 15 lines · Andy Shevchenko

The GPIO ACPI helpers use a few quirks which consumes approximately 20% of the file. Besides that the necessary bits are sparse and being directly referred. Split them to a separate file. There is no functional change.

For the new file I used the Hans' authorship of Hans as he the author of all those bits (expect very tiny changes made by this series).

Hans, please check if it's okay and confirm, or suggest better alternative.

Andy Shevchenko (4):
gpiolib: acpi: Switch to use enum in acpi_gpio_in_ignore_list()
gpiolib: acpi: Handle deferred list via new API
gpiolib: acpi: Add acpi_gpio_need_run_edge_events_on_boot() getter
gpiolib: acpi: Move quirks to a separate file

Quoted 4 lines
 drivers/gpio/Makefile                         |   1 +
 .../{gpiolib-acpi.c => gpiolib-acpi-core.c}   | 344 +----------------
 drivers/gpio/gpiolib-acpi-quirks.c            | 363 ++++++++++++++++++
 drivers/gpio/gpiolib-acpi.h                   |  15 +
Quoted 4 lines

All this -foo-core things look redundant to me. Why not just split it out and call it gpiolib-quirks.c and put there all the quirks not just ACPI? I Don't think we want to have gpiolib-of-quirks.c and gpiolog-swnode-quirks.c and so on.

That's might be the next step to have for all of them, but these are ACPI specific. In any case they can't be put to gpiolib-quirks.c due to module parameters. If we do that we will need a dirty hack to support old module parameters (see 8250 how it's done there, and even author of that didn't like the approach).

Quoted 4 lines
Quoted 2 lines

Hmm, how does it affect module paremeters? I thought they are gpiolib.something as all these object files are linked to it?

gpiolib_acpi.FOO because the object file is gpiolib-acpi.o.

Ah okay.

Quoted 3 lines
Quoted 1 line

At least can we drop the gpiolib-acpi-core.c rename?

Unfortunately no due to the above.

This does not work?

gpiolib-acpi-y := gpiolib-acpi.o gpiolib-acpi-quirks.o

author maintainer
#13 lore raw
Quoted 4 lines · Mika Westerberg
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Mika Westerberg
Quoted 1 line · Andy Shevchenko

On Wed, May 14, 2025 at 06:59:55PM +0300, Mika Westerberg wrote:

...

Quoted 13 lines
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines

That's might be the next step to have for all of them, but these are ACPI specific. In any case they can't be put to gpiolib-quirks.c due to module parameters. If we do that we will need a dirty hack to support old module parameters (see 8250 how it's done there, and even author of that didn't like the approach).

Hmm, how does it affect module paremeters? I thought they are gpiolib.something as all these object files are linked to it?

gpiolib_acpi.FOO because the object file is gpiolib-acpi.o.

Ah okay.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

At least can we drop the gpiolib-acpi-core.c rename?

Unfortunately no due to the above.

This does not work?

gpiolib-acpi-y := gpiolib-acpi.o gpiolib-acpi-quirks.o

No. You can't use the same name on left and right parts.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#14 lore raw
Quoted 23 lines · Andy Shevchenko
Quoted 4 lines · Mika Westerberg
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Mika Westerberg
Quoted 1 line · Andy Shevchenko

On Wed, May 14, 2025 at 06:59:55PM +0300, Mika Westerberg wrote:

...

Quoted 15 lines
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines

That's might be the next step to have for all of them, but these are ACPI specific. In any case they can't be put to gpiolib-quirks.c due to module parameters. If we do that we will need a dirty hack to support old module parameters (see 8250 how it's done there, and even author of that didn't like the approach).

Hmm, how does it affect module paremeters? I thought they are gpiolib.something as all these object files are linked to it?

gpiolib_acpi.FOO because the object file is gpiolib-acpi.o.

Ah okay.

Quoted 2 lines
Quoted 1 line

At least can we drop the gpiolib-acpi-core.c rename?

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Unfortunately no due to the above.

This does not work?

gpiolib-acpi-y := gpiolib-acpi.o gpiolib-acpi-quirks.o

No. You can't use the same name on left and right parts.

I see :( Okay then I guess there are no other options than name it like this.

[ Ideally we would drop the while gpiolib- prefix from all these so you have acpi.c, sysfs.c and so on without the redundancy but that's outside of scope of this work anyways ;-) ]

author maintainer
#15 lore raw
Quoted 30 lines · Mika Westerberg
Quoted 29 lines · Andy Shevchenko
Quoted 4 lines · Mika Westerberg
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Mika Westerberg
Quoted 1 line · Andy Shevchenko

On Wed, May 14, 2025 at 06:59:55PM +0300, Mika Westerberg wrote:

...

Quoted 20 lines
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines

That's might be the next step to have for all of them, but these are ACPI specific. In any case they can't be put to gpiolib-quirks.c due to module parameters. If we do that we will need a dirty hack to support old module parameters (see 8250 how it's done there, and even author of that didn't like the approach).

Hmm, how does it affect module paremeters? I thought they are gpiolib.something as all these object files are linked to it?

gpiolib_acpi.FOO because the object file is gpiolib-acpi.o.

Ah okay.

Quoted 3 lines
Quoted 1 line

At least can we drop the gpiolib-acpi-core.c rename?

Unfortunately no due to the above.

This does not work?

gpiolib-acpi-y := gpiolib-acpi.o gpiolib-acpi-quirks.o

Quoted 8 lines
Quoted 1 line

No. You can't use the same name on left and right parts.

I see :( Okay then I guess there are no other options than name it like this.

[ Ideally we would drop the while gpiolib- prefix from all these so you have acpi.c, sysfs.c and so on without the redundancy but that's outside of scope of this work anyways ;-) ]

I also would like to have prefix to be dropped for the files, but the modules (and it's can be achieved, but it's indeed out of scope here).

Quoted 1 line

Thank you!
I am going to push to my review and testing queue soon.

Signature · 2 lines
With Best Regards,
Andy Shevchenko