aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2013-09-10 07:06:57 -0400
committerLinus Walleij <linus.walleij@linaro.org>2013-09-27 08:15:20 -0400
commitb22973d0ecfcf499179870599b0f6e0712ff0a14 (patch)
tree3e3c5bce26ad87c1521c7898d919927bd8b05b9f /drivers
parente9c9fc2315ad7a57af1a5124ad911870b60d9bd0 (diff)
input: misc: ixp4-beeper: use gpiolib strictly
Request and free the GPIO line used for the beeper properly. Then use the gpiolib API to flip the output of the GPIO pin instead of relying on hacks to poke the register bits. Cc: Imre Kaloz <kaloz@openwrt.org> Cc: Alexandre Courbot <acourbot@nvidia.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Krzysztof Halasa <khc@pm.waw.pl> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/misc/ixp4xx-beeper.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/input/misc/ixp4xx-beeper.c b/drivers/input/misc/ixp4xx-beeper.c
index f14afd09e34d..17ccba88d636 100644
--- a/drivers/input/misc/ixp4xx-beeper.c
+++ b/drivers/input/misc/ixp4xx-beeper.c
@@ -76,11 +76,13 @@ static int ixp4xx_spkr_event(struct input_dev *dev, unsigned int type, unsigned
76 76
77static irqreturn_t ixp4xx_spkr_interrupt(int irq, void *dev_id) 77static irqreturn_t ixp4xx_spkr_interrupt(int irq, void *dev_id)
78{ 78{
79 unsigned int pin = (unsigned int) dev_id;
80
79 /* clear interrupt */ 81 /* clear interrupt */
80 *IXP4XX_OSST = IXP4XX_OSST_TIMER_2_PEND; 82 *IXP4XX_OSST = IXP4XX_OSST_TIMER_2_PEND;
81 83
82 /* flip the beeper output */ 84 /* flip the beeper output */
83 *IXP4XX_GPIO_GPOUTR ^= (1 << (unsigned int) dev_id); 85 gpio_set_value(pin, !gpio_get_value(pin));
84 86
85 return IRQ_HANDLED; 87 return IRQ_HANDLED;
86} 88}
@@ -108,11 +110,15 @@ static int ixp4xx_spkr_probe(struct platform_device *dev)
108 input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE); 110 input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
109 input_dev->event = ixp4xx_spkr_event; 111 input_dev->event = ixp4xx_spkr_event;
110 112
113 err = gpio_request(dev->id, "ixp4-beeper");
114 if (err)
115 goto err_free_device;
116
111 err = request_irq(IRQ_IXP4XX_TIMER2, &ixp4xx_spkr_interrupt, 117 err = request_irq(IRQ_IXP4XX_TIMER2, &ixp4xx_spkr_interrupt,
112 IRQF_NO_SUSPEND, "ixp4xx-beeper", 118 IRQF_NO_SUSPEND, "ixp4xx-beeper",
113 (void *) dev->id); 119 (void *) dev->id);
114 if (err) 120 if (err)
115 goto err_free_device; 121 goto err_free_gpio;
116 122
117 err = input_register_device(input_dev); 123 err = input_register_device(input_dev);
118 if (err) 124 if (err)
@@ -124,6 +130,8 @@ static int ixp4xx_spkr_probe(struct platform_device *dev)
124 130
125 err_free_irq: 131 err_free_irq:
126 free_irq(IRQ_IXP4XX_TIMER2, (void *)dev->id); 132 free_irq(IRQ_IXP4XX_TIMER2, (void *)dev->id);
133 err_free_gpio:
134 gpio_free(dev->id);
127 err_free_device: 135 err_free_device:
128 input_free_device(input_dev); 136 input_free_device(input_dev);
129 137
@@ -142,6 +150,7 @@ static int ixp4xx_spkr_remove(struct platform_device *dev)
142 ixp4xx_spkr_control(pin, 0); 150 ixp4xx_spkr_control(pin, 0);
143 151
144 free_irq(IRQ_IXP4XX_TIMER2, (void *)dev->id); 152 free_irq(IRQ_IXP4XX_TIMER2, (void *)dev->id);
153 gpio_free(dev->id);
145 154
146 return 0; 155 return 0;
147} 156}