[PATCH v3 5/5] OMAP: I2C: Convert i2c driver to use PM runtime api's
From: Russell King - ARM Linux <hidden>
Date: 2010-09-28 07:48:40
Also in:
linux-i2c, linux-omap
On Tue, Sep 28, 2010 at 12:29:01PM +0530, Nayak, Rajendra wrote:
<snip>...quoted
quoted
quoted
static int omap_i2c_init(struct omap_i2c_dev *dev)@@ -356,6 +333,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) unsigned long fclk_rate = 12000000; unsigned long timeout; unsigned long internal_clk = 0; + struct clk *fclk; if (dev->rev >= OMAP_I2C_REV_2) { /* Disable I2C controller before soft reset */@@ -414,7 +392,8 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) * always returns 12MHz for the functional clock, we can * do this bit unconditionally. */ - fclk_rate = clk_get_rate(dev->fclk); + fclk = clk_get(dev->dev, "fck"); + fclk_rate = clk_get_rate(fclk); /* TRM for 5912 says the I2C clock must be prescaled to be * between 7 - 12 MHz. The XOR input clock is typically@@ -443,7 +422,8 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) internal_clk = 9600; else internal_clk = 4000; - fclk_rate = clk_get_rate(dev->fclk) / 1000; + fclk = clk_get(dev->dev, "fck"); + fclk_rate = clk_get_rate(fclk) / 1000;You don't put the clk after getting it and using it once?clk_get needs an equivalent clk_put and not clk_get_rate. clk_get_rate is used to merely know the existing rate of the clock.Sorry, I guess you did mean the clk_get above the clk_get_rate does not have an equivalent clk_put. I could put a clk_put for readability, but a clk_put on OMAP actually does map to an empty function. See arch/arm/plat-omap/include/plat/clkdev.h clk_get merely returns a pointer to the clk struct and does not do any usecounting, hence a clk_put does not do anything.
That's no reason to avoid using it.