ARM: ixp4xx: Pass IRQ resource to beeper

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>
This commit is contained in:
Linus Walleij 2018-12-29 15:49:08 +01:00
parent 98ac0cc270
commit 075df31aed
2 changed files with 24 additions and 6 deletions

View 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[] = {

View 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);
}