ramips: add support for PandoraBox PBR-M1
[15.05/openwrt.git] / target / linux / brcm2708 / patches-3.18 / 0107-i2c_bcm2708-Fix-clock-reference-counting.patch
1 From cf1b789e1a6873d9680156fac9f675a0f1cdd17b Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Thu, 5 Feb 2015 16:01:44 +0000
4 Subject: [PATCH 107/114] i2c_bcm2708: Fix clock reference counting
5
6 ---
7  drivers/i2c/busses/i2c-bcm2708.c | 12 ++++++++++--
8  1 file changed, 10 insertions(+), 2 deletions(-)
9
10 --- a/drivers/i2c/busses/i2c-bcm2708.c
11 +++ b/drivers/i2c/busses/i2c-bcm2708.c
12 @@ -337,11 +337,17 @@ static int bcm2708_i2c_probe(struct plat
13                 return PTR_ERR(clk);
14         }
15  
16 +       err = clk_prepare_enable(clk);
17 +       if (err) {
18 +               dev_err(&pdev->dev, "could not enable clk: %d\n", err);
19 +               goto out_clk_put;
20 +       }
21 +
22         bcm2708_i2c_init_pinmode(pdev->id);
23  
24         bi = kzalloc(sizeof(*bi), GFP_KERNEL);
25         if (!bi)
26 -               goto out_clk_put;
27 +               goto out_clk_disable;
28  
29         platform_set_drvdata(pdev, bi);
30  
31 @@ -412,6 +418,8 @@ out_iounmap:
32         iounmap(bi->base);
33  out_free_bi:
34         kfree(bi);
35 +out_clk_disable:
36 +       clk_disable_unprepare(clk);
37  out_clk_put:
38         clk_put(clk);
39         return err;
40 @@ -426,7 +434,7 @@ static int bcm2708_i2c_remove(struct pla
41         i2c_del_adapter(&bi->adapter);
42         free_irq(bi->irq, bi);
43         iounmap(bi->base);
44 -       clk_disable(bi->clk);
45 +       clk_disable_unprepare(bi->clk);
46         clk_put(bi->clk);
47         kfree(bi);
48