hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/input/misc/ixp4xx-beeper.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Generic IXP4xx beeper driver
34 *
....@@ -8,11 +9,6 @@
89 *
910 * Author: Alessandro Zummo <a.zummo@towertech.it>
1011 * 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
- *
1612 */
1713
1814 #include <linux/module.h>
....@@ -29,6 +25,8 @@
2925 MODULE_ALIAS("platform:ixp4xx-beeper");
3026
3127 static DEFINE_SPINLOCK(beep_lock);
28
+
29
+static int ixp4xx_timer2_irq;
3230
3331 static void ixp4xx_spkr_control(unsigned int pin, unsigned int count)
3432 {
....@@ -90,6 +88,7 @@
9088 static int ixp4xx_spkr_probe(struct platform_device *dev)
9189 {
9290 struct input_dev *input_dev;
91
+ int irq;
9392 int err;
9493
9594 input_dev = input_allocate_device();
....@@ -110,15 +109,22 @@
110109 input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
111110 input_dev->event = ixp4xx_spkr_event;
112111
112
+ irq = platform_get_irq(dev, 0);
113
+ if (irq < 0) {
114
+ err = irq;
115
+ goto err_free_device;
116
+ }
117
+
113118 err = gpio_request(dev->id, "ixp4-beeper");
114119 if (err)
115120 goto err_free_device;
116121
117
- err = request_irq(IRQ_IXP4XX_TIMER2, &ixp4xx_spkr_interrupt,
122
+ err = request_irq(irq, &ixp4xx_spkr_interrupt,
118123 IRQF_NO_SUSPEND, "ixp4xx-beeper",
119124 (void *) dev->id);
120125 if (err)
121126 goto err_free_gpio;
127
+ ixp4xx_timer2_irq = irq;
122128
123129 err = input_register_device(input_dev);
124130 if (err)
....@@ -129,7 +135,7 @@
129135 return 0;
130136
131137 err_free_irq:
132
- free_irq(IRQ_IXP4XX_TIMER2, (void *)dev->id);
138
+ free_irq(irq, (void *)dev->id);
133139 err_free_gpio:
134140 gpio_free(dev->id);
135141 err_free_device:
....@@ -146,10 +152,10 @@
146152 input_unregister_device(input_dev);
147153
148154 /* turn the speaker off */
149
- disable_irq(IRQ_IXP4XX_TIMER2);
155
+ disable_irq(ixp4xx_timer2_irq);
150156 ixp4xx_spkr_control(pin, 0);
151157
152
- free_irq(IRQ_IXP4XX_TIMER2, (void *)dev->id);
158
+ free_irq(ixp4xx_timer2_irq, (void *)dev->id);
153159 gpio_free(dev->id);
154160
155161 return 0;
....@@ -161,7 +167,7 @@
161167 unsigned int pin = (unsigned int) input_get_drvdata(input_dev);
162168
163169 /* turn off the speaker */
164
- disable_irq(IRQ_IXP4XX_TIMER2);
170
+ disable_irq(ixp4xx_timer2_irq);
165171 ixp4xx_spkr_control(pin, 0);
166172 }
167173