]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
ARM: ixp4xx: Pass IRQ resource to beeper
authorLinus Walleij <linus.walleij@linaro.org>
Sat, 29 Dec 2018 14:49:08 +0000 (15:49 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Fri, 19 Apr 2019 18:37:40 +0000 (20:37 +0200)
All IXP4xx devices except the beeper passes the IRQ as a
resource, augment the NSLU2 beeper to do the same.

This is a prerequisite for SPARSE_IRQ.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
arch/arm/mach-ixp4xx/nslu2-setup.c
drivers/input/misc/ixp4xx-beeper.c

index 341b263482ef98a7045d4ea31a1a9ddc2ab890d6..7c2b6604187e398612c76ac9ae8a51d3556bdb16 100644 (file)
@@ -125,10 +125,18 @@ static struct platform_device nslu2_i2c_gpio = {
        },
 };
 
+static struct resource nslu2_beeper_resources[] = {
+       {
+               .start  = IRQ_IXP4XX_TIMER2,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
 static struct platform_device nslu2_beeper = {
        .name                   = "ixp4xx-beeper",
        .id                     = NSLU2_GPIO_BUZZ,
-       .num_resources          = 0,
+       .resource               = nslu2_beeper_resources,
+       .num_resources          = ARRAY_SIZE(nslu2_beeper_resources),
 };
 
 static struct resource nslu2_uart_resources[] = {
index 1fe149f3def24b62484c1e02b2ea895758bb67c4..4776273fa10b3590ad4606f2c4d45df7b7d564af 100644 (file)
@@ -30,6 +30,8 @@ MODULE_ALIAS("platform:ixp4xx-beeper");
 
 static DEFINE_SPINLOCK(beep_lock);
 
+static int ixp4xx_timer2_irq;
+
 static void ixp4xx_spkr_control(unsigned int pin, unsigned int count)
 {
        unsigned long flags;
@@ -90,6 +92,7 @@ static irqreturn_t ixp4xx_spkr_interrupt(int irq, void *dev_id)
 static int ixp4xx_spkr_probe(struct platform_device *dev)
 {
        struct input_dev *input_dev;
+       int irq;
        int err;
 
        input_dev = input_allocate_device();
@@ -110,15 +113,22 @@ static int ixp4xx_spkr_probe(struct platform_device *dev)
        input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
        input_dev->event = ixp4xx_spkr_event;
 
+       irq = platform_get_irq(dev, 0);
+       if (irq < 0) {
+               err = irq;
+               goto err_free_device;
+       }
+
        err = gpio_request(dev->id, "ixp4-beeper");
        if (err)
                goto err_free_device;
 
-       err = request_irq(IRQ_IXP4XX_TIMER2, &ixp4xx_spkr_interrupt,
+       err = request_irq(irq, &ixp4xx_spkr_interrupt,
                          IRQF_NO_SUSPEND, "ixp4xx-beeper",
                          (void *) dev->id);
        if (err)
                goto err_free_gpio;
+       ixp4xx_timer2_irq = irq;
 
        err = input_register_device(input_dev);
        if (err)
@@ -129,7 +139,7 @@ static int ixp4xx_spkr_probe(struct platform_device *dev)
        return 0;
 
  err_free_irq:
-       free_irq(IRQ_IXP4XX_TIMER2, (void *)dev->id);
+       free_irq(irq, (void *)dev->id);
  err_free_gpio:
        gpio_free(dev->id);
  err_free_device:
@@ -146,10 +156,10 @@ static int ixp4xx_spkr_remove(struct platform_device *dev)
        input_unregister_device(input_dev);
 
        /* turn the speaker off */
-       disable_irq(IRQ_IXP4XX_TIMER2);
+       disable_irq(ixp4xx_timer2_irq);
        ixp4xx_spkr_control(pin, 0);
 
-       free_irq(IRQ_IXP4XX_TIMER2, (void *)dev->id);
+       free_irq(ixp4xx_timer2_irq, (void *)dev->id);
        gpio_free(dev->id);
 
        return 0;
@@ -161,7 +171,7 @@ static void ixp4xx_spkr_shutdown(struct platform_device *dev)
        unsigned int pin = (unsigned int) input_get_drvdata(input_dev);
 
        /* turn off the speaker */
-       disable_irq(IRQ_IXP4XX_TIMER2);
+       disable_irq(ixp4xx_timer2_irq);
        ixp4xx_spkr_control(pin, 0);
 }