]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/5.0.1/gnss-sirf-fix-premature-wakeup-interrupt-enable.patch
5.0-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 5.0.1 / gnss-sirf-fix-premature-wakeup-interrupt-enable.patch
1 From 82f844c22588bf47132c82faeda50b6db473162c Mon Sep 17 00:00:00 2001
2 From: Johan Hovold <johan@kernel.org>
3 Date: Tue, 22 Jan 2019 18:22:53 +0100
4 Subject: gnss: sirf: fix premature wakeup interrupt enable
5
6 From: Johan Hovold <johan@kernel.org>
7
8 commit 82f844c22588bf47132c82faeda50b6db473162c upstream.
9
10 Make sure the receiver is powered (and booted) before enabling the
11 wakeup interrupt to avoid spurious interrupts due to a floating input.
12
13 Similarly, disable the interrupt before powering off on probe errors and
14 on unbind.
15
16 Fixes: d2efbbd18b1e ("gnss: add driver for sirfstar-based receivers")
17 Cc: stable <stable@vger.kernel.org> # 4.19
18 Signed-off-by: Johan Hovold <johan@kernel.org>
19 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20
21 ---
22 drivers/gnss/sirf.c | 32 +++++++++++++++++---------------
23 1 file changed, 17 insertions(+), 15 deletions(-)
24
25 --- a/drivers/gnss/sirf.c
26 +++ b/drivers/gnss/sirf.c
27 @@ -310,30 +310,26 @@ static int sirf_probe(struct serdev_devi
28 ret = -ENODEV;
29 goto err_put_device;
30 }
31 +
32 + ret = regulator_enable(data->vcc);
33 + if (ret)
34 + goto err_put_device;
35 +
36 + /* Wait for chip to boot into hibernate mode. */
37 + msleep(SIRF_BOOT_DELAY);
38 }
39
40 if (data->wakeup) {
41 ret = gpiod_to_irq(data->wakeup);
42 if (ret < 0)
43 - goto err_put_device;
44 -
45 + goto err_disable_vcc;
46 data->irq = ret;
47
48 - ret = devm_request_threaded_irq(dev, data->irq, NULL,
49 - sirf_wakeup_handler,
50 + ret = request_threaded_irq(data->irq, NULL, sirf_wakeup_handler,
51 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
52 "wakeup", data);
53 if (ret)
54 - goto err_put_device;
55 - }
56 -
57 - if (data->on_off) {
58 - ret = regulator_enable(data->vcc);
59 - if (ret)
60 - goto err_put_device;
61 -
62 - /* Wait for chip to boot into hibernate mode */
63 - msleep(SIRF_BOOT_DELAY);
64 + goto err_disable_vcc;
65 }
66
67 if (IS_ENABLED(CONFIG_PM)) {
68 @@ -342,7 +338,7 @@ static int sirf_probe(struct serdev_devi
69 } else {
70 ret = sirf_runtime_resume(dev);
71 if (ret < 0)
72 - goto err_disable_vcc;
73 + goto err_free_irq;
74 }
75
76 ret = gnss_register_device(gdev);
77 @@ -356,6 +352,9 @@ err_disable_rpm:
78 pm_runtime_disable(dev);
79 else
80 sirf_runtime_suspend(dev);
81 +err_free_irq:
82 + if (data->wakeup)
83 + free_irq(data->irq, data);
84 err_disable_vcc:
85 if (data->on_off)
86 regulator_disable(data->vcc);
87 @@ -376,6 +375,9 @@ static void sirf_remove(struct serdev_de
88 else
89 sirf_runtime_suspend(&serdev->dev);
90
91 + if (data->wakeup)
92 + free_irq(data->irq, data);
93 +
94 if (data->on_off)
95 regulator_disable(data->vcc);
96