Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH 1/3] Input: soc_button_array - use resources to set up IRQ info for gpio-keys
@ 2026-10-21  1:49 Dmitry Torokhov
  2026-10-21  1:50 ` [PATCH 2/3] Input: soc_button_array - use __free() cleanup facilities to free memory Dmitry Torokhov
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Dmitry Torokhov @ 2026-10-21  1:49 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Bartosz Golaszewski, Arnd Bergmann, Andy Shevchenko,
	Linus Walleij, linux-input, linux-gpio, linux-kernel

In preparation for transitioning the driver to use static device
properties instead of platform data to configure gpio-keys driver,
switch to using IRQ resources attached to the gpio-keys platform device
to communicate the IRQ selection.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/misc/soc_button_array.c | 33 +++++++++++++++++++++------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
index dbf86ea778e6..d4dc4e7116a7 100644
--- a/drivers/input/misc/soc_button_array.c
+++ b/drivers/input/misc/soc_button_array.c
@@ -17,6 +17,7 @@
 #include <linux/gpio_keys.h>
 #include <linux/platform_data/x86/soc.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 static bool use_low_level_irq;
 module_param(use_low_level_irq, bool, 0444);
@@ -154,6 +155,11 @@ soc_button_device_create(struct platform_device *pdev,
 			 const struct soc_button_info *button_info,
 			 bool autorepeat)
 {
+	struct platform_device_info pdevinfo = {
+		.parent = &pdev->dev,
+		.name = "gpio-keys",
+		.id = PLATFORM_DEVID_AUTO,
+	};
 	const struct soc_button_info *info;
 	struct platform_device *pd;
 	struct gpio_keys_button *gpio_keys;
@@ -167,6 +173,15 @@ soc_button_device_create(struct platform_device *pdev,
 		if (info->autorepeat == autorepeat)
 			n_buttons++;
 
+	struct resource *irq_resources __free(kfree) = NULL;
+	/* See dmi_use_low_level_irq[] comment */
+	if (!autorepeat && (use_low_level_irq ||
+			    dmi_check_system(dmi_use_low_level_irq))) {
+		irq_resources = kzalloc_objs(*irq_resources, n_buttons);
+		if (!irq_resources)
+			return ERR_PTR(-ENOMEM);
+	}
+
 	gpio_keys_pdata = devm_kzalloc(&pdev->dev,
 				       sizeof(*gpio_keys_pdata) +
 					sizeof(*gpio_keys) * n_buttons,
@@ -174,6 +189,9 @@ soc_button_device_create(struct platform_device *pdev,
 	if (!gpio_keys_pdata)
 		return ERR_PTR(-ENOMEM);
 
+	pdevinfo.data = gpio_keys_pdata;
+	pdevinfo.size_data = sizeof(*gpio_keys_pdata);
+
 	gpio_keys = (void *)(gpio_keys_pdata + 1);
 	n_buttons = 0;
 
@@ -212,10 +230,9 @@ soc_button_device_create(struct platform_device *pdev,
 		}
 
 		/* See dmi_use_low_level_irq[] comment */
-		if (!autorepeat && (use_low_level_irq ||
-				    dmi_check_system(dmi_use_low_level_irq))) {
+		if (irq_resources) {
 			irq_set_irq_type(irq, IRQ_TYPE_LEVEL_LOW);
-			gpio_keys[n_buttons].irq = irq;
+			irq_resources[n_buttons] = DEFINE_RES_IRQ(irq);
 			gpio_keys[n_buttons].gpio = -ENOENT;
 		} else {
 			gpio_keys[n_buttons].gpio = gpio;
@@ -240,10 +257,12 @@ soc_button_device_create(struct platform_device *pdev,
 	gpio_keys_pdata->nbuttons = n_buttons;
 	gpio_keys_pdata->rep = autorepeat;
 
-	pd = platform_device_register_resndata(&pdev->dev, "gpio-keys",
-					       PLATFORM_DEVID_AUTO, NULL, 0,
-					       gpio_keys_pdata,
-					       sizeof(*gpio_keys_pdata));
+	if (irq_resources) {
+		pdevinfo.res = irq_resources;
+		pdevinfo.num_res = n_buttons;
+	}
+
+	pd = platform_device_register_full(&pdevinfo);
 	error = PTR_ERR_OR_ZERO(pd);
 	if (error) {
 		dev_err(&pdev->dev,
-- 
2.56.0.212.g129ede20d9-goog


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-10-21 18:21 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-21  1:49 [PATCH 1/3] Input: soc_button_array - use resources to set up IRQ info for gpio-keys Dmitry Torokhov
2026-10-21  1:50 ` [PATCH 2/3] Input: soc_button_array - use __free() cleanup facilities to free memory Dmitry Torokhov
2026-10-21 10:06   ` Bartosz Golaszewski
2026-10-21 17:05   ` Andy Shevchenko
2026-10-21 17:15     ` Dmitry Torokhov
2026-10-21 17:43       ` Andy Shevchenko
2026-10-21 17:53         ` Dmitry Torokhov
2026-10-21 18:21           ` Andy Shevchenko
2026-10-21  1:50 ` [PATCH 3/3] Input: soc_button_array - convert to software nodes Dmitry Torokhov
2026-10-21 10:11   ` Bartosz Golaszewski
2026-10-21 16:56     ` Dmitry Torokhov
2026-10-21 17:02       ` Arnd Bergmann
2026-10-21 17:16         ` Dmitry Torokhov
2026-10-21 17:13   ` Andy Shevchenko
2026-10-21 17:23     ` Dmitry Torokhov
2026-10-21  1:59 ` [PATCH 1/3] Input: soc_button_array - use resources to set up IRQ info for gpio-keys sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox