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 7A2003B4EAA; Fri, 10 Jul 2026 21:19:11 +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=1783718352; cv=none; b=th3y5KvPa+d6rJyCGZ5QG0fkOmIIjFHu3awcbzgSbKnBGVzpZ2m0eIDSzLvR+kfBf7ISuYBTVjCdKz8p1g7N+NvFdzOj3bWsqjeMfAGgNv3s4UdhNzQ0WSnQuoNvwIazmLspHkdSL0uQaS2yV0gww4TxwYqHk5HSWQ1QIz9GEIQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783718352; c=relaxed/simple; bh=9t2rX193IBbII/SkD1sZ6b1S6Kg5U6adn3TSbDt1o7o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=S5vtrW372scmJl2Ih8qMXksPXVFCicKpL7YyHV3JDDIL6Ppf6odKRXT9/iZYBbwqeWqhzadnlJ1XuC+mtjXACUz0JMSbsXWt/JeJf4otPwQxbMO8a9V6wfcKPzFX5F2NNtwrgz6GzY1QgW1cScFlWIQKu+6H4wah71dZ5RUrr/s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ObhtfZcz; 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="ObhtfZcz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 985741F000E9; Fri, 10 Jul 2026 21:19:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783718351; bh=m5zCJ35nUw+Ql++3UWFF1hzVFzNhspySX+1bZiFa+dY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ObhtfZczMIqCiXI1u6WScaZcB7ywyXfILXUucikWo1uU0jIvHpbgDEfWUiE9YSK4u hGrMxq5NYybGhaUet239t7i+Es3h1bIHOTzyUu9WDdQFzVxuNcmUH7ve6LbWMkE2FP ZMwYyLud22CSnD+Bfg93ZtuVE65MJ/6z+0wG+l80Bpa44jGBYUeANUel3Ac0XjvGAw +iLdLbTwkuut1DYAp9qCLjTbYntAomrhHXHO4syecua4jhSHE1CSZOowHubJzAHhBD 3aHmBG+oAba4QOVRFIlGuQO9iSGHc7hq8oUQvCuLxqn8lZEJxV+Z6BRrtnk3yOOEl8 anxIZsmEY6qBw== From: Arnd Bergmann To: linux-gpio@vger.kernel.org, Linus Walleij , Bartosz Golaszewski Cc: Arnd Bergmann , John Paul Adrian Glaubitz , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , 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, Bartosz Golaszewski Subject: [PATCH 2/6] [v6] Input: gpio-keys: make legacy gpiolib optional Date: Fri, 10 Jul 2026 23:18:50 +0200 Message-Id: <20260710211854.1371746-3-arnd@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260710211854.1371746-1-arnd@kernel.org> References: <20260710211854.1371746-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-sh@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/ Acked-by: Bartosz Golaszewski Acked-by: Dmitry Torokhov # for input 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