aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2015-02-10 20:47:04 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2015-02-15 19:06:04 -0500
commit7694f44d63c61883fefba6e8ad12075f17d3ebd3 (patch)
tree80a38c05a787047337557a85b3a6e7aad602062a
parentbfa76d49576599a4b9f9b7a71f23d73d6dcff735 (diff)
Input: bfin_rotary - fix potential oops in interrupt handler
The interrupt handler in the driver tries to fetch driver data from platform device, unfortunately it is only set up after interrupt handler is registered. Since interrupt handler does not really need to access the platform device itself let's change it to get the driver data instance instead. Acked-by: Sonic Zhang <sonic.zhang@analog.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/misc/bfin_rotary.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/input/misc/bfin_rotary.c b/drivers/input/misc/bfin_rotary.c
index 3f4351579372..2bf93df9403f 100644
--- a/drivers/input/misc/bfin_rotary.c
+++ b/drivers/input/misc/bfin_rotary.c
@@ -59,8 +59,7 @@ static void report_rotary_event(struct bfin_rot *rotary, int delta)
59 59
60static irqreturn_t bfin_rotary_isr(int irq, void *dev_id) 60static irqreturn_t bfin_rotary_isr(int irq, void *dev_id)
61{ 61{
62 struct platform_device *pdev = dev_id; 62 struct bfin_rot *rotary = dev_id;
63 struct bfin_rot *rotary = platform_get_drvdata(pdev);
64 int delta; 63 int delta;
65 64
66 switch (bfin_read_CNT_STATUS()) { 65 switch (bfin_read_CNT_STATUS()) {
@@ -152,7 +151,7 @@ static int bfin_rotary_probe(struct platform_device *pdev)
152 } 151 }
153 152
154 error = request_irq(rotary->irq, bfin_rotary_isr, 153 error = request_irq(rotary->irq, bfin_rotary_isr,
155 0, dev_name(&pdev->dev), pdev); 154 0, dev_name(&pdev->dev), rotary);
156 if (error) { 155 if (error) {
157 dev_err(&pdev->dev, 156 dev_err(&pdev->dev,
158 "unable to claim irq %d; error %d\n", 157 "unable to claim irq %d; error %d\n",
@@ -186,7 +185,7 @@ static int bfin_rotary_probe(struct platform_device *pdev)
186 return 0; 185 return 0;
187 186
188out2: 187out2:
189 free_irq(rotary->irq, pdev); 188 free_irq(rotary->irq, rotary);
190out1: 189out1:
191 input_free_device(input); 190 input_free_device(input);
192 kfree(rotary); 191 kfree(rotary);
@@ -202,7 +201,7 @@ static int bfin_rotary_remove(struct platform_device *pdev)
202 bfin_write_CNT_CONFIG(0); 201 bfin_write_CNT_CONFIG(0);
203 bfin_write_CNT_IMASK(0); 202 bfin_write_CNT_IMASK(0);
204 203
205 free_irq(rotary->irq, pdev); 204 free_irq(rotary->irq, rotary);
206 input_unregister_device(rotary->input); 205 input_unregister_device(rotary->input);
207 peripheral_free_list(per_cnt); 206 peripheral_free_list(per_cnt);
208 207