637dc9c8eac7fbf990bf6ce3dc74d2d7aaf0e83d
[openwrt/staging/thess.git] /
1 From d0fde01a8476390b77a0320897b267313a851312 Mon Sep 17 00:00:00 2001
2 From: Annaliese McDermond <nh6z@nh6z.net>
3 Date: Fri, 21 Jun 2019 03:52:49 -0700
4 Subject: [PATCH 695/782] i2c: bcm2835: Move IRQ request after clock code in
5 probe
6
7 Commit 4a5cfa39465cad25dd736d7ceba8a5d32eea4ecc upstream.
8
9 If any of the clock code in the probe fails and returns, the IRQ
10 will not be freed. Moving the IRQ request to last allows it to
11 be freed on any errors further up in the probe function. devm_
12 calls can apparently not be used because there are some potential
13 race conditions that will arise.
14
15 Fixes: bebff81fb8b9 ("i2c: bcm2835: Model Divider in CCF")
16 Signed-off-by: Annaliese McDermond <nh6z@nh6z.net>
17 Acked-by: Stefan Wahren <wahrenst@gmx.net>
18 Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
19 ---
20 drivers/i2c/busses/i2c-bcm2835.c | 28 ++++++++++++++--------------
21 1 file changed, 14 insertions(+), 14 deletions(-)
22
23 --- a/drivers/i2c/busses/i2c-bcm2835.c
24 +++ b/drivers/i2c/busses/i2c-bcm2835.c
25 @@ -521,20 +521,6 @@ static int bcm2835_i2c_probe(struct plat
26 if (IS_ERR(i2c_dev->regs))
27 return PTR_ERR(i2c_dev->regs);
28
29 - irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
30 - if (!irq) {
31 - dev_err(&pdev->dev, "No IRQ resource\n");
32 - return -ENODEV;
33 - }
34 - i2c_dev->irq = irq->start;
35 -
36 - ret = request_irq(i2c_dev->irq, bcm2835_i2c_isr, IRQF_SHARED,
37 - dev_name(&pdev->dev), i2c_dev);
38 - if (ret) {
39 - dev_err(&pdev->dev, "Could not request IRQ\n");
40 - return -ENODEV;
41 - }
42 -
43 mclk_name = of_clk_get_parent_name(pdev->dev.of_node, 0);
44
45 bus_clk = bcm2835_i2c_register_div(&pdev->dev, mclk_name, i2c_dev);
46 @@ -564,6 +550,20 @@ static int bcm2835_i2c_probe(struct plat
47 return ret;
48 }
49
50 + irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
51 + if (!irq) {
52 + dev_err(&pdev->dev, "No IRQ resource\n");
53 + return -ENODEV;
54 + }
55 + i2c_dev->irq = irq->start;
56 +
57 + ret = request_irq(i2c_dev->irq, bcm2835_i2c_isr, IRQF_SHARED,
58 + dev_name(&pdev->dev), i2c_dev);
59 + if (ret) {
60 + dev_err(&pdev->dev, "Could not request IRQ\n");
61 + return -ENODEV;
62 + }
63 +
64 adap = &i2c_dev->adapter;
65 i2c_set_adapdata(adap, i2c_dev);
66 adap->owner = THIS_MODULE;