i2c-pxa: prepare clock before use
authorDaniel Drake <dsd@laptop.org>
Mon, 17 Jun 2013 15:30:36 +0000 (11:30 -0400)
committerWolfram Sang <wsa@the-dreams.de>
Tue, 18 Jun 2013 16:11:32 +0000 (18:11 +0200)
On OLPC XO-1.75 (MMP2), a WARN_ON() was occurring during boot
since the clock being enabled by i2c-pxa had not been prepared.

Use clk_prepare_enable() to ensure that the prepare operation
has taken place, and use clk_disable_unprepare() in the matching
shutdown paths.

Signed-off-by: Daniel Drake <dsd@laptop.org>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-pxa.c

index ea6d45d1dcd60f6fb58006b61b3397a6e1da452b..fbafed29fb8153ba404c27c8ec5183a4e82520ff 100644 (file)
@@ -1160,7 +1160,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
                i2c->adap.class = plat->class;
        }
 
-       clk_enable(i2c->clk);
+       clk_prepare_enable(i2c->clk);
 
        if (i2c->use_pio) {
                i2c->adap.algo = &i2c_pxa_pio_algorithm;
@@ -1202,7 +1202,7 @@ eadapt:
        if (!i2c->use_pio)
                free_irq(irq, i2c);
 ereqirq:
-       clk_disable(i2c->clk);
+       clk_disable_unprepare(i2c->clk);
        iounmap(i2c->reg_base);
 eremap:
        clk_put(i2c->clk);
@@ -1221,7 +1221,7 @@ static int i2c_pxa_remove(struct platform_device *dev)
        if (!i2c->use_pio)
                free_irq(i2c->irq, i2c);
 
-       clk_disable(i2c->clk);
+       clk_disable_unprepare(i2c->clk);
        clk_put(i2c->clk);
 
        iounmap(i2c->reg_base);