* [PATCH] gpio: 104-dio-48e: Use irqchip template
@ 2020-07-22 10:39 Linus Walleij
2020-07-22 17:22 ` William Breathitt Gray
0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2020-07-22 10:39 UTC (permalink / raw)
To: linux-gpio; +Cc: Bartosz Golaszewski, Linus Walleij, William Breathitt Gray
This makes the driver use the irqchip template to assign
properties to the gpio_irq_chip instead of using the
explicit call to gpiochip_irqchip_add().
The irqchip is instead added while adding the gpiochip.
Also move the IRQ initialization to the special .init_hw()
callback.
Cc: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/gpio/gpio-104-dio-48e.c | 35 ++++++++++++++++++++++-----------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c
index 1f7d9bbec0fc..7a9021c4fa48 100644
--- a/drivers/gpio/gpio-104-dio-48e.c
+++ b/drivers/gpio/gpio-104-dio-48e.c
@@ -368,10 +368,21 @@ static const char *dio48e_names[DIO48E_NGPIO] = {
"PPI Group 1 Port C 5", "PPI Group 1 Port C 6", "PPI Group 1 Port C 7"
};
+static int dio48e_irq_init_hw(struct gpio_chip *gc)
+{
+ struct dio48e_gpio *const dio48egpio = gpiochip_get_data(gc);
+
+ /* Disable IRQ by default */
+ inb(dio48egpio->base + 0xB);
+
+ return 0;
+}
+
static int dio48e_probe(struct device *dev, unsigned int id)
{
struct dio48e_gpio *dio48egpio;
const char *const name = dev_name(dev);
+ struct gpio_irq_chip *girq;
int err;
dio48egpio = devm_kzalloc(dev, sizeof(*dio48egpio), GFP_KERNEL);
@@ -399,13 +410,17 @@ static int dio48e_probe(struct device *dev, unsigned int id)
dio48egpio->chip.set_multiple = dio48e_gpio_set_multiple;
dio48egpio->base = base[id];
- raw_spin_lock_init(&dio48egpio->lock);
+ girq = &dio48egpio->chip.irq;
+ girq->chip = &dio48e_irqchip;
+ /* This will let us handle the parent IRQ in the driver */
+ girq->parent_handler = NULL;
+ girq->num_parents = 0;
+ girq->parents = NULL;
+ girq->default_type = IRQ_TYPE_NONE;
+ girq->handler = handle_edge_irq;
+ girq->init_hw = dio48e_irq_init_hw;
- err = devm_gpiochip_add_data(dev, &dio48egpio->chip, dio48egpio);
- if (err) {
- dev_err(dev, "GPIO registering failed (%d)\n", err);
- return err;
- }
+ raw_spin_lock_init(&dio48egpio->lock);
/* initialize all GPIO as output */
outb(0x80, base[id] + 3);
@@ -419,13 +434,9 @@ static int dio48e_probe(struct device *dev, unsigned int id)
outb(0x00, base[id] + 6);
outb(0x00, base[id] + 7);
- /* disable IRQ by default */
- inb(base[id] + 0xB);
-
- err = gpiochip_irqchip_add(&dio48egpio->chip, &dio48e_irqchip, 0,
- handle_edge_irq, IRQ_TYPE_NONE);
+ err = devm_gpiochip_add_data(dev, &dio48egpio->chip, dio48egpio);
if (err) {
- dev_err(dev, "Could not add irqchip (%d)\n", err);
+ dev_err(dev, "GPIO registering failed (%d)\n", err);
return err;
}
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] gpio: 104-dio-48e: Use irqchip template
2020-07-22 10:39 [PATCH] gpio: 104-dio-48e: Use irqchip template Linus Walleij
@ 2020-07-22 17:22 ` William Breathitt Gray
0 siblings, 0 replies; 2+ messages in thread
From: William Breathitt Gray @ 2020-07-22 17:22 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-gpio, Bartosz Golaszewski
[-- Attachment #1: Type: text/plain, Size: 3014 bytes --]
On Wed, Jul 22, 2020 at 12:39:15PM +0200, Linus Walleij wrote:
> This makes the driver use the irqchip template to assign
> properties to the gpio_irq_chip instead of using the
> explicit call to gpiochip_irqchip_add().
>
> The irqchip is instead added while adding the gpiochip.
> Also move the IRQ initialization to the special .init_hw()
> callback.
>
> Cc: William Breathitt Gray <vilhelm.gray@gmail.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>
> ---
> drivers/gpio/gpio-104-dio-48e.c | 35 ++++++++++++++++++++++-----------
> 1 file changed, 23 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c
> index 1f7d9bbec0fc..7a9021c4fa48 100644
> --- a/drivers/gpio/gpio-104-dio-48e.c
> +++ b/drivers/gpio/gpio-104-dio-48e.c
> @@ -368,10 +368,21 @@ static const char *dio48e_names[DIO48E_NGPIO] = {
> "PPI Group 1 Port C 5", "PPI Group 1 Port C 6", "PPI Group 1 Port C 7"
> };
>
> +static int dio48e_irq_init_hw(struct gpio_chip *gc)
> +{
> + struct dio48e_gpio *const dio48egpio = gpiochip_get_data(gc);
> +
> + /* Disable IRQ by default */
> + inb(dio48egpio->base + 0xB);
> +
> + return 0;
> +}
> +
> static int dio48e_probe(struct device *dev, unsigned int id)
> {
> struct dio48e_gpio *dio48egpio;
> const char *const name = dev_name(dev);
> + struct gpio_irq_chip *girq;
> int err;
>
> dio48egpio = devm_kzalloc(dev, sizeof(*dio48egpio), GFP_KERNEL);
> @@ -399,13 +410,17 @@ static int dio48e_probe(struct device *dev, unsigned int id)
> dio48egpio->chip.set_multiple = dio48e_gpio_set_multiple;
> dio48egpio->base = base[id];
>
> - raw_spin_lock_init(&dio48egpio->lock);
> + girq = &dio48egpio->chip.irq;
> + girq->chip = &dio48e_irqchip;
> + /* This will let us handle the parent IRQ in the driver */
> + girq->parent_handler = NULL;
> + girq->num_parents = 0;
> + girq->parents = NULL;
> + girq->default_type = IRQ_TYPE_NONE;
> + girq->handler = handle_edge_irq;
> + girq->init_hw = dio48e_irq_init_hw;
>
> - err = devm_gpiochip_add_data(dev, &dio48egpio->chip, dio48egpio);
> - if (err) {
> - dev_err(dev, "GPIO registering failed (%d)\n", err);
> - return err;
> - }
> + raw_spin_lock_init(&dio48egpio->lock);
>
> /* initialize all GPIO as output */
> outb(0x80, base[id] + 3);
> @@ -419,13 +434,9 @@ static int dio48e_probe(struct device *dev, unsigned int id)
> outb(0x00, base[id] + 6);
> outb(0x00, base[id] + 7);
>
> - /* disable IRQ by default */
> - inb(base[id] + 0xB);
> -
> - err = gpiochip_irqchip_add(&dio48egpio->chip, &dio48e_irqchip, 0,
> - handle_edge_irq, IRQ_TYPE_NONE);
> + err = devm_gpiochip_add_data(dev, &dio48egpio->chip, dio48egpio);
> if (err) {
> - dev_err(dev, "Could not add irqchip (%d)\n", err);
> + dev_err(dev, "GPIO registering failed (%d)\n", err);
> return err;
> }
>
> --
> 2.26.2
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-22 17:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 10:39 [PATCH] gpio: 104-dio-48e: Use irqchip template Linus Walleij
2020-07-22 17:22 ` William Breathitt Gray
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).