* [PATCH] gpio: 104-idi-48: Use irqchip template
@ 2020-07-22 10:48 Linus Walleij
2020-07-22 17:23 ` William Breathitt Gray
0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2020-07-22 10:48 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-idi-48.c | 33 ++++++++++++++++++++++-----------
1 file changed, 22 insertions(+), 11 deletions(-)
diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c
index d350ac0de06b..94c3a9bc4e75 100644
--- a/drivers/gpio/gpio-104-idi-48.c
+++ b/drivers/gpio/gpio-104-idi-48.c
@@ -247,10 +247,22 @@ static const char *idi48_names[IDI48_NGPIO] = {
"Bit 18 B", "Bit 19 B", "Bit 20 B", "Bit 21 B", "Bit 22 B", "Bit 23 B"
};
+static int idi_48_irq_init_hw(struct gpio_chip *gc)
+{
+ struct idi_48_gpio *const idi48gpio = gpiochip_get_data(gc);
+
+ /* Disable IRQ by default */
+ outb(0, idi48gpio->base + 7);
+ inb(idi48gpio->base + 7);
+
+ return 0;
+}
+
static int idi_48_probe(struct device *dev, unsigned int id)
{
struct idi_48_gpio *idi48gpio;
const char *const name = dev_name(dev);
+ struct gpio_irq_chip *girq;
int err;
idi48gpio = devm_kzalloc(dev, sizeof(*idi48gpio), GFP_KERNEL);
@@ -275,6 +287,16 @@ static int idi_48_probe(struct device *dev, unsigned int id)
idi48gpio->chip.get_multiple = idi_48_gpio_get_multiple;
idi48gpio->base = base[id];
+ girq = &idi48gpio->chip.irq;
+ girq->chip = &idi_48_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 = idi_48_irq_init_hw;
+
raw_spin_lock_init(&idi48gpio->lock);
spin_lock_init(&idi48gpio->ack_lock);
@@ -284,17 +306,6 @@ static int idi_48_probe(struct device *dev, unsigned int id)
return err;
}
- /* Disable IRQ by default */
- outb(0, base[id] + 7);
- inb(base[id] + 7);
-
- err = gpiochip_irqchip_add(&idi48gpio->chip, &idi_48_irqchip, 0,
- handle_edge_irq, IRQ_TYPE_NONE);
- if (err) {
- dev_err(dev, "Could not add irqchip (%d)\n", err);
- return err;
- }
-
err = devm_request_irq(dev, irq[id], idi_48_irq_handler, IRQF_SHARED,
name, idi48gpio);
if (err) {
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] gpio: 104-idi-48: Use irqchip template
2020-07-22 10:48 [PATCH] gpio: 104-idi-48: Use irqchip template Linus Walleij
@ 2020-07-22 17:23 ` William Breathitt Gray
0 siblings, 0 replies; 2+ messages in thread
From: William Breathitt Gray @ 2020-07-22 17:23 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-gpio, Bartosz Golaszewski
[-- Attachment #1: Type: text/plain, Size: 2759 bytes --]
On Wed, Jul 22, 2020 at 12:48:20PM +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-idi-48.c | 33 ++++++++++++++++++++++-----------
> 1 file changed, 22 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c
> index d350ac0de06b..94c3a9bc4e75 100644
> --- a/drivers/gpio/gpio-104-idi-48.c
> +++ b/drivers/gpio/gpio-104-idi-48.c
> @@ -247,10 +247,22 @@ static const char *idi48_names[IDI48_NGPIO] = {
> "Bit 18 B", "Bit 19 B", "Bit 20 B", "Bit 21 B", "Bit 22 B", "Bit 23 B"
> };
>
> +static int idi_48_irq_init_hw(struct gpio_chip *gc)
> +{
> + struct idi_48_gpio *const idi48gpio = gpiochip_get_data(gc);
> +
> + /* Disable IRQ by default */
> + outb(0, idi48gpio->base + 7);
> + inb(idi48gpio->base + 7);
> +
> + return 0;
> +}
> +
> static int idi_48_probe(struct device *dev, unsigned int id)
> {
> struct idi_48_gpio *idi48gpio;
> const char *const name = dev_name(dev);
> + struct gpio_irq_chip *girq;
> int err;
>
> idi48gpio = devm_kzalloc(dev, sizeof(*idi48gpio), GFP_KERNEL);
> @@ -275,6 +287,16 @@ static int idi_48_probe(struct device *dev, unsigned int id)
> idi48gpio->chip.get_multiple = idi_48_gpio_get_multiple;
> idi48gpio->base = base[id];
>
> + girq = &idi48gpio->chip.irq;
> + girq->chip = &idi_48_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 = idi_48_irq_init_hw;
> +
> raw_spin_lock_init(&idi48gpio->lock);
> spin_lock_init(&idi48gpio->ack_lock);
>
> @@ -284,17 +306,6 @@ static int idi_48_probe(struct device *dev, unsigned int id)
> return err;
> }
>
> - /* Disable IRQ by default */
> - outb(0, base[id] + 7);
> - inb(base[id] + 7);
> -
> - err = gpiochip_irqchip_add(&idi48gpio->chip, &idi_48_irqchip, 0,
> - handle_edge_irq, IRQ_TYPE_NONE);
> - if (err) {
> - dev_err(dev, "Could not add irqchip (%d)\n", err);
> - return err;
> - }
> -
> err = devm_request_irq(dev, irq[id], idi_48_irq_handler, IRQF_SHARED,
> name, idi48gpio);
> if (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:23 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:48 [PATCH] gpio: 104-idi-48: Use irqchip template Linus Walleij
2020-07-22 17:23 ` 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).