From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.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 0244840911B; Mon, 29 Jun 2026 13:04:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782738243; cv=none; b=brCZRlcZK33xefIV2q5rmlCZyZgGbqigLjiXSgYOdtCXqlqckAMd4NIBGQ83oL5GvbIoWHnfYzb+/ePwd8OdwEW2CJmQC2ZCaGJF4lJmPkcw+89idRgwIUbtSVXozW1UYugXQRjT83R8CB26rb5P136ybVeawM9U/OAnqybPWPE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782738243; c=relaxed/simple; bh=mtbb7EJ1r/8nG05E7GOe3F9JwLWlylCGbJbcuXBJpK8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DMBEUrcK2n7qJVaKWvRu7Ui7KEmRK4ei3I0If9YLT3WR9pIQ+V6qG5f3sd9BnVAVlKQkH4b+8euG4FTc8RvejbohPy9/1x6//opUou8iMz7pMZrAi/Y02yqWJCApb+aj6sSJPijNTm3xsGTU8OGeyeJ+UOTBqxEAPcEActJfLdU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i7rtPnfc; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="i7rtPnfc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22ADA1F00A3A; Mon, 29 Jun 2026 13:03:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1782738241; bh=7gUgA0N+1ESGHfe4tRJHUwAOZY/chqJL+SD2zqa2tDc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=i7rtPnfcYfHF4vJtdh4EX3c3iIRtn14PQQP60tVn23nAcRNlze9oovIC+8lnnO1PA NlOzKE1wqWgstJsYvfQglifeavG/zO+6+eZ3fe+jen64+sXuoxtnvBLJrqY53jOiGn jOIjLSDYk9xPMEju08LQSJxye7+0M+7AWxAAbUUeJ58eS7DN5VXWPBLnZpQDp4Ay2g QJKhNmaa+zhFQD9jhkvHL7NwnE1IKdOVHrhvHQzL6KBVq/RHPh8WrmwWnH8+WVGEWi fVHrgpNS5cnxXGYHCC4wJPMSoL9rtvp11lJXjb3AZj9IllqazeI3m+MPIAG2xlHJ1k WTeCNVQPU4rWA== From: Arnd Bergmann To: linux-gpio@vger.kernel.org Cc: Arnd Bergmann , John Paul Adrian Glaubitz , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Linus Walleij , Bartosz Golaszewski , Dmitry Torokhov , Lee Jones , Pavel Machek , linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org Subject: [PATCH 4/6] [v5] Input: gpio-keys: make legacy gpiolib optional Date: Mon, 29 Jun 2026 15:03:27 +0200 Message-Id: <20260629130329.1291953-5-arnd@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260629130329.1291953-1-arnd@kernel.org> References: <20260629130329.1291953-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnd Bergmann Most users of gpio-keys and gpio-keys-polled use modern gpiolib interfaces, but there are still number of ancient sh, arm32 and x86 machines that have never been converted. Add an #ifdef block for the parts of the driver that are only used on those legacy machines. The two Rohm PMIC drivers use a gpio-keys device without an actual GPIO, passing an IRQ number instead. In order to keep this working both with and with CONFIG_GPIOLIB_LEGACY, change the gpio-keys driver to ignore the gpio number if an IRQ is passed. Link: https://lore.kernel.org/all/b3c94552-c104-42e3-be15-7e8362e8039e@gmail.com/ Link: https://lore.kernel.org/all/afJXG4_rtaj3l2Dk@google.com/ Link: https://lore.kernel.org/all/ajQ-CtU131FAJ9ES@google.com/ Signed-off-by: Arnd Bergmann --- v3..v5: resend v2: skip the fake GPIO number passing from mfd This patch now has a small conflict with the rework of the rohm drivers to use software nodes. That patch is the one we want, and then the drivers/mfd changes here can get dropped, but the two need to get merged in the correct order. --- drivers/input/keyboard/gpio_keys.c | 9 +++++---- drivers/input/keyboard/gpio_keys_polled.c | 4 +++- drivers/mfd/rohm-bd71828.c | 1 - drivers/mfd/rohm-bd718x7.c | 1 - include/linux/gpio_keys.h | 2 ++ 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index e19617485679..e988657f97cb 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -23,8 +23,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -528,7 +528,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev, */ bdata->gpiod = NULL; } - } else if (gpio_is_valid(button->gpio)) { +#ifdef CONFIG_GPIOLIB_LEGACY + } else if (!button->irq && gpio_is_valid(button->gpio)) { /* * Legacy GPIO number, so request the GPIO here and * convert it to descriptor. @@ -546,6 +547,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev, if (button->active_low ^ gpiod_is_active_low(bdata->gpiod)) gpiod_toggle_active_low(bdata->gpiod); +#endif } if (bdata->gpiod) { @@ -583,8 +585,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev, if (irq < 0) { error = irq; dev_err_probe(dev, error, - "Unable to get irq number for GPIO %d\n", - button->gpio); + "Unable to get irq number for GPIO\n"); return error; } bdata->irq = irq; diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c index e6707d72210e..4e7a366ff05b 100644 --- a/drivers/input/keyboard/gpio_keys_polled.c +++ b/drivers/input/keyboard/gpio_keys_polled.c @@ -18,8 +18,8 @@ #include #include #include -#include #include +#include #include #include @@ -301,6 +301,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) return dev_err_probe(dev, PTR_ERR(bdata->gpiod), "failed to get gpio\n"); } +#ifdef CONFIG_GPIOLIB_LEGACY } else if (gpio_is_valid(button->gpio)) { /* * Legacy GPIO number so request the GPIO here and @@ -323,6 +324,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) if (button->active_low ^ gpiod_is_active_low(bdata->gpiod)) gpiod_toggle_active_low(bdata->gpiod); +#endif } bdata->last_state = -1; diff --git a/drivers/mfd/rohm-bd71828.c b/drivers/mfd/rohm-bd71828.c index a79f354bf5cb..df6dad762ec9 100644 --- a/drivers/mfd/rohm-bd71828.c +++ b/drivers/mfd/rohm-bd71828.c @@ -39,7 +39,6 @@ static struct gpio_keys_button button = { .code = KEY_POWER, - .gpio = -1, .type = EV_KEY, .wakeup = 1, }; diff --git a/drivers/mfd/rohm-bd718x7.c b/drivers/mfd/rohm-bd718x7.c index ff714fd4f54d..dd774aa8828b 100644 --- a/drivers/mfd/rohm-bd718x7.c +++ b/drivers/mfd/rohm-bd718x7.c @@ -20,7 +20,6 @@ static struct gpio_keys_button button = { .code = KEY_POWER, - .gpio = -1, .type = EV_KEY, }; diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h index 80fa930b04c6..e8d6dc290efb 100644 --- a/include/linux/gpio_keys.h +++ b/include/linux/gpio_keys.h @@ -25,7 +25,9 @@ struct device; */ struct gpio_keys_button { unsigned int code; +#ifdef CONFIG_GPIOLIB_LEGACY int gpio; +#endif int active_low; const char *desc; unsigned int type; -- 2.39.5