| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Generic IXP4xx beeper driver |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 8 | 9 | * |
|---|
| 9 | 10 | * Author: Alessandro Zummo <a.zummo@towertech.it> |
|---|
| 10 | 11 | * Maintainers: http://www.nslu2-linux.org/ |
|---|
| 11 | | - * |
|---|
| 12 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 13 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 14 | | - * published by the Free Software Foundation. |
|---|
| 15 | | - * |
|---|
| 16 | 12 | */ |
|---|
| 17 | 13 | |
|---|
| 18 | 14 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 29 | 25 | MODULE_ALIAS("platform:ixp4xx-beeper"); |
|---|
| 30 | 26 | |
|---|
| 31 | 27 | static DEFINE_SPINLOCK(beep_lock); |
|---|
| 28 | + |
|---|
| 29 | +static int ixp4xx_timer2_irq; |
|---|
| 32 | 30 | |
|---|
| 33 | 31 | static void ixp4xx_spkr_control(unsigned int pin, unsigned int count) |
|---|
| 34 | 32 | { |
|---|
| .. | .. |
|---|
| 90 | 88 | static int ixp4xx_spkr_probe(struct platform_device *dev) |
|---|
| 91 | 89 | { |
|---|
| 92 | 90 | struct input_dev *input_dev; |
|---|
| 91 | + int irq; |
|---|
| 93 | 92 | int err; |
|---|
| 94 | 93 | |
|---|
| 95 | 94 | input_dev = input_allocate_device(); |
|---|
| .. | .. |
|---|
| 110 | 109 | input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE); |
|---|
| 111 | 110 | input_dev->event = ixp4xx_spkr_event; |
|---|
| 112 | 111 | |
|---|
| 112 | + irq = platform_get_irq(dev, 0); |
|---|
| 113 | + if (irq < 0) { |
|---|
| 114 | + err = irq; |
|---|
| 115 | + goto err_free_device; |
|---|
| 116 | + } |
|---|
| 117 | + |
|---|
| 113 | 118 | err = gpio_request(dev->id, "ixp4-beeper"); |
|---|
| 114 | 119 | if (err) |
|---|
| 115 | 120 | goto err_free_device; |
|---|
| 116 | 121 | |
|---|
| 117 | | - err = request_irq(IRQ_IXP4XX_TIMER2, &ixp4xx_spkr_interrupt, |
|---|
| 122 | + err = request_irq(irq, &ixp4xx_spkr_interrupt, |
|---|
| 118 | 123 | IRQF_NO_SUSPEND, "ixp4xx-beeper", |
|---|
| 119 | 124 | (void *) dev->id); |
|---|
| 120 | 125 | if (err) |
|---|
| 121 | 126 | goto err_free_gpio; |
|---|
| 127 | + ixp4xx_timer2_irq = irq; |
|---|
| 122 | 128 | |
|---|
| 123 | 129 | err = input_register_device(input_dev); |
|---|
| 124 | 130 | if (err) |
|---|
| .. | .. |
|---|
| 129 | 135 | return 0; |
|---|
| 130 | 136 | |
|---|
| 131 | 137 | err_free_irq: |
|---|
| 132 | | - free_irq(IRQ_IXP4XX_TIMER2, (void *)dev->id); |
|---|
| 138 | + free_irq(irq, (void *)dev->id); |
|---|
| 133 | 139 | err_free_gpio: |
|---|
| 134 | 140 | gpio_free(dev->id); |
|---|
| 135 | 141 | err_free_device: |
|---|
| .. | .. |
|---|
| 146 | 152 | input_unregister_device(input_dev); |
|---|
| 147 | 153 | |
|---|
| 148 | 154 | /* turn the speaker off */ |
|---|
| 149 | | - disable_irq(IRQ_IXP4XX_TIMER2); |
|---|
| 155 | + disable_irq(ixp4xx_timer2_irq); |
|---|
| 150 | 156 | ixp4xx_spkr_control(pin, 0); |
|---|
| 151 | 157 | |
|---|
| 152 | | - free_irq(IRQ_IXP4XX_TIMER2, (void *)dev->id); |
|---|
| 158 | + free_irq(ixp4xx_timer2_irq, (void *)dev->id); |
|---|
| 153 | 159 | gpio_free(dev->id); |
|---|
| 154 | 160 | |
|---|
| 155 | 161 | return 0; |
|---|
| .. | .. |
|---|
| 161 | 167 | unsigned int pin = (unsigned int) input_get_drvdata(input_dev); |
|---|
| 162 | 168 | |
|---|
| 163 | 169 | /* turn off the speaker */ |
|---|
| 164 | | - disable_irq(IRQ_IXP4XX_TIMER2); |
|---|
| 170 | + disable_irq(ixp4xx_timer2_irq); |
|---|
| 165 | 171 | ixp4xx_spkr_control(pin, 0); |
|---|
| 166 | 172 | } |
|---|
| 167 | 173 | |
|---|