Commit 7694f44d authored by Dmitry Torokhov's avatar Dmitry Torokhov

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: default avatarSonic Zhang <sonic.zhang@analog.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent bfa76d49
...@@ -59,8 +59,7 @@ static void report_rotary_event(struct bfin_rot *rotary, int delta) ...@@ -59,8 +59,7 @@ static void report_rotary_event(struct bfin_rot *rotary, int delta)
static irqreturn_t bfin_rotary_isr(int irq, void *dev_id) static irqreturn_t bfin_rotary_isr(int irq, void *dev_id)
{ {
struct platform_device *pdev = dev_id; struct bfin_rot *rotary = dev_id;
struct bfin_rot *rotary = platform_get_drvdata(pdev);
int delta; int delta;
switch (bfin_read_CNT_STATUS()) { switch (bfin_read_CNT_STATUS()) {
...@@ -152,7 +151,7 @@ static int bfin_rotary_probe(struct platform_device *pdev) ...@@ -152,7 +151,7 @@ static int bfin_rotary_probe(struct platform_device *pdev)
} }
error = request_irq(rotary->irq, bfin_rotary_isr, error = request_irq(rotary->irq, bfin_rotary_isr,
0, dev_name(&pdev->dev), pdev); 0, dev_name(&pdev->dev), rotary);
if (error) { if (error) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"unable to claim irq %d; error %d\n", "unable to claim irq %d; error %d\n",
...@@ -186,7 +185,7 @@ static int bfin_rotary_probe(struct platform_device *pdev) ...@@ -186,7 +185,7 @@ static int bfin_rotary_probe(struct platform_device *pdev)
return 0; return 0;
out2: out2:
free_irq(rotary->irq, pdev); free_irq(rotary->irq, rotary);
out1: out1:
input_free_device(input); input_free_device(input);
kfree(rotary); kfree(rotary);
...@@ -202,7 +201,7 @@ static int bfin_rotary_remove(struct platform_device *pdev) ...@@ -202,7 +201,7 @@ static int bfin_rotary_remove(struct platform_device *pdev)
bfin_write_CNT_CONFIG(0); bfin_write_CNT_CONFIG(0);
bfin_write_CNT_IMASK(0); bfin_write_CNT_IMASK(0);
free_irq(rotary->irq, pdev); free_irq(rotary->irq, rotary);
input_unregister_device(rotary->input); input_unregister_device(rotary->input);
peripheral_free_list(per_cnt); peripheral_free_list(per_cnt);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment