From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Yinbo Zhu <zhuyinbo@loongson.cn>,
Hoan Tran <hoan@os.amperecomputing.com>,
Manivannan Sadhasivam <mani@kernel.org>,
Yang Shen <shenyang39@huawei.com>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-unisoc@lists.infradead.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: [PATCH RESEND 11/14] gpio: rda: use new generic GPIO chip API
Date: Tue, 12 Aug 2025 14:12:53 +0200 [thread overview]
Message-ID: <20250812-gpio-mmio-gpio-conv-v1-11-aac41d656979@linaro.org> (raw)
In-Reply-To: <20250812-gpio-mmio-gpio-conv-v1-0-aac41d656979@linaro.org>
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Convert the driver to using the new generic GPIO chip interfaces from
linux/gpio/generic.h.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/gpio/gpio-rda.c | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/drivers/gpio/gpio-rda.c b/drivers/gpio/gpio-rda.c
index cb2f63eee2aa10a2708ec91dfd610ed1ea76917d..bcd85a2237a532b875df9470d972ac88b95a91cc 100644
--- a/drivers/gpio/gpio-rda.c
+++ b/drivers/gpio/gpio-rda.c
@@ -8,6 +8,7 @@
#include <linux/bitops.h>
#include <linux/gpio/driver.h>
+#include <linux/gpio/generic.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
@@ -35,7 +36,7 @@
#define RDA_GPIO_BANK_NR 32
struct rda_gpio {
- struct gpio_chip chip;
+ struct gpio_generic_chip chip;
void __iomem *base;
spinlock_t lock;
int irq;
@@ -208,6 +209,7 @@ static const struct irq_chip rda_gpio_irq_chip = {
static int rda_gpio_probe(struct platform_device *pdev)
{
+ struct gpio_generic_chip_config config;
struct device *dev = &pdev->dev;
struct gpio_irq_chip *girq;
struct rda_gpio *rda_gpio;
@@ -235,24 +237,29 @@ static int rda_gpio_probe(struct platform_device *pdev)
spin_lock_init(&rda_gpio->lock);
- ret = bgpio_init(&rda_gpio->chip, dev, 4,
- rda_gpio->base + RDA_GPIO_VAL,
- rda_gpio->base + RDA_GPIO_SET,
- rda_gpio->base + RDA_GPIO_CLR,
- rda_gpio->base + RDA_GPIO_OEN_SET_OUT,
- rda_gpio->base + RDA_GPIO_OEN_SET_IN,
- BGPIOF_READ_OUTPUT_REG_SET);
+ config = (typeof(config)){
+ .dev = dev,
+ .sz = 4,
+ .dat = rda_gpio->base + RDA_GPIO_VAL,
+ .set = rda_gpio->base + RDA_GPIO_SET,
+ .clr = rda_gpio->base + RDA_GPIO_CLR,
+ .dirout = rda_gpio->base + RDA_GPIO_OEN_SET_OUT,
+ .dirin = rda_gpio->base + RDA_GPIO_OEN_SET_IN,
+ .flags = BGPIOF_READ_OUTPUT_REG_SET,
+ };
+
+ ret = gpio_generic_chip_init(&rda_gpio->chip, &config);
if (ret) {
- dev_err(dev, "bgpio_init failed\n");
+ dev_err(dev, "failed to initialize the generic GPIO chip\n");
return ret;
}
- rda_gpio->chip.label = dev_name(dev);
- rda_gpio->chip.ngpio = ngpios;
- rda_gpio->chip.base = -1;
+ rda_gpio->chip.gc.label = dev_name(dev);
+ rda_gpio->chip.gc.ngpio = ngpios;
+ rda_gpio->chip.gc.base = -1;
if (rda_gpio->irq >= 0) {
- girq = &rda_gpio->chip.irq;
+ girq = &rda_gpio->chip.gc.irq;
gpio_irq_chip_set_chip(girq, &rda_gpio_irq_chip);
girq->handler = handle_bad_irq;
girq->default_type = IRQ_TYPE_NONE;
@@ -269,7 +276,7 @@ static int rda_gpio_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, rda_gpio);
- return devm_gpiochip_add_data(dev, &rda_gpio->chip, rda_gpio);
+ return devm_gpiochip_add_data(dev, &rda_gpio->chip.gc, rda_gpio);
}
static const struct of_device_id rda_gpio_of_match[] = {
--
2.48.1
next prev parent reply other threads:[~2025-08-12 12:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-12 12:12 [PATCH RESEND 00/14] gpio: replace legacy bgpio_init() with its modernized alternative Bartosz Golaszewski
2025-08-12 12:12 ` [PATCH RESEND 01/14] gpio: generic: provide to_gpio_generic_chip() Bartosz Golaszewski
2025-08-12 12:12 ` [PATCH RESEND 02/14] gpio: generic: provide helpers for reading and writing registers Bartosz Golaszewski
2025-08-12 12:12 ` [PATCH RESEND 03/14] gpio: hisi: use the BGPIOF_UNREADABLE_REG_DIR flag Bartosz Golaszewski
2025-08-12 12:12 ` [PATCH RESEND 04/14] gpio: ts4800: remove the unnecessary call to platform_set_drvdata() Bartosz Golaszewski
2025-08-12 12:12 ` [PATCH RESEND 05/14] gpio: ts4800: use generic device properties Bartosz Golaszewski
2025-08-12 12:12 ` [PATCH RESEND 06/14] gpio: ts4800: use dev_err_probe() Bartosz Golaszewski
2025-08-12 12:12 ` [PATCH RESEND 07/14] gpio: ts4800: use new generic GPIO chip API Bartosz Golaszewski
2025-08-12 12:12 ` [PATCH RESEND 08/14] gpio: loongson-64bit: " Bartosz Golaszewski
2025-08-12 12:12 ` [PATCH RESEND 09/14] gpio: dwapb: " Bartosz Golaszewski
2025-08-12 12:12 ` [PATCH RESEND 10/14] gpio: amdpt: " Bartosz Golaszewski
2025-08-12 12:12 ` Bartosz Golaszewski [this message]
2025-08-12 12:12 ` [PATCH RESEND 12/14] gpio: grgpio: " Bartosz Golaszewski
2025-08-12 12:12 ` [PATCH RESEND 13/14] gpio: mpc8xxx: " Bartosz Golaszewski
2025-08-12 12:12 ` [PATCH RESEND 14/14] gpio: ge: " Bartosz Golaszewski
2025-08-12 12:14 ` [PATCH RESEND 00/14] gpio: replace legacy bgpio_init() with its modernized alternative Bartosz Golaszewski
2025-08-19 11:18 ` Linus Walleij
-- strict thread matches above, loose matches on Subject: below --
2025-08-25 9:48 Bartosz Golaszewski
2025-08-25 9:48 ` [PATCH RESEND 11/14] gpio: rda: use new generic GPIO chip API Bartosz Golaszewski
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=20250812-gpio-mmio-gpio-conv-v1-11-aac41d656979@linaro.org \
--to=brgl@bgdev.pl \
--cc=bartosz.golaszewski@linaro.org \
--cc=hoan@os.amperecomputing.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-unisoc@lists.infradead.org \
--cc=mani@kernel.org \
--cc=shenyang39@huawei.com \
--cc=zhuyinbo@loongson.cn \
/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).