diff options
author | Rob Herring <r.herring@freescale.com> | 2008-03-13 08:34:30 -0500 |
---|---|---|
committer | Daniel Schaeffer <daniel.schaeffer@timesys.com> | 2008-08-25 15:20:44 -0400 |
commit | a52caebf02ce6fe7876ff4c28a932f91ec6d52f3 (patch) | |
tree | 572b9d7d4da5dc17b720e3aa79a37766f392cb6e | |
parent | 024463f3f812ddff77c0b058adf8a7020a86389d (diff) |
ENGR00068562 Fix WM8350 init and regulator enable counting
Fix WM8350 init flow so WM8350 and regulators are enabled as early as possible.
Prevent regulator enable counting from being < 0.
Signed-off-by: Rob Herring <r.herring@freescale.com>
-rw-r--r-- | drivers/regulator/reg-core.c | 4 | ||||
-rw-r--r-- | drivers/regulator/wm8350/reg-wm8350-bus.c | 14 | ||||
-rw-r--r-- | drivers/regulator/wm8350/reg-wm8350-i2c.c | 11 | ||||
-rw-r--r-- | drivers/regulator/wm8350/reg-wm8350.c | 7 |
4 files changed, 14 insertions, 22 deletions
diff --git a/drivers/regulator/reg-core.c b/drivers/regulator/reg-core.c index ecc94b6fea6a..afaf68457ba7 100644 --- a/drivers/regulator/reg-core.c +++ b/drivers/regulator/reg-core.c @@ -390,8 +390,7 @@ static int __regulator_disable(struct regulator *regulator) { int ret = 0; - if (regulator->use_count == 1) { - + if (regulator->use_count > 0 && !(--regulator->use_count)) { if (regulator->ops->disable) { ret = regulator->ops->disable(regulator); if (ret < 0) @@ -400,7 +399,6 @@ static int __regulator_disable(struct regulator *regulator) if (regulator->parent) __regulator_disable(regulator->parent); } - regulator->use_count--; out: return ret; } diff --git a/drivers/regulator/wm8350/reg-wm8350-bus.c b/drivers/regulator/wm8350/reg-wm8350-bus.c index c6a42fa3078f..edeb5af3da6d 100644 --- a/drivers/regulator/wm8350/reg-wm8350-bus.c +++ b/drivers/regulator/wm8350/reg-wm8350-bus.c @@ -1496,20 +1496,6 @@ struct bus_type wm8350_bus_type = { }; EXPORT_SYMBOL(wm8350_bus_type); -static int __init wm8350_bus_init(void) -{ - printk("WM8350 Bus Manager %s\n", WM8350_BUS_VERSION); - return bus_register(&wm8350_bus_type); -} -subsys_initcall(wm8350_bus_init); - -static void __exit wm8350_bus_exit(void) -{ - bus_unregister(&wm8350_bus_type); -} - -module_exit(wm8350_bus_exit); - MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com"); MODULE_DESCRIPTION("WM8350 PMIC Bus driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/regulator/wm8350/reg-wm8350-i2c.c b/drivers/regulator/wm8350/reg-wm8350-i2c.c index 5c0639ec14c3..d8ca6436442a 100644 --- a/drivers/regulator/wm8350/reg-wm8350-i2c.c +++ b/drivers/regulator/wm8350/reg-wm8350-i2c.c @@ -41,6 +41,9 @@ static unsigned short normal_i2c[] = { WM8350_I2C_ADDR, I2C_CLIENT_END }; /* Magic definition of all other variables and things */ I2C_CLIENT_INSMOD; +extern int wm8350_pmu_init(void); +extern void wm8350_pmu_exit(void); + static int wm8350_pmic_i2c_detect(struct i2c_adapter *adap, int addr, int kind) { struct wm8350* wm8350; @@ -90,6 +93,12 @@ static int wm8350_pmic_i2c_detect(struct i2c_adapter *adap, int addr, int kind) goto err; } + ret = bus_register(&wm8350_bus_type); + if (ret < 0) + goto err; + + wm8350_pmu_init(); + ret = wm8350_init(wm8350); if (ret == 0) return ret; @@ -109,6 +118,8 @@ static int wm8350_i2c_detach(struct i2c_client *client) struct wm8350 *wm8350 = i2c_get_clientdata(client); wm8350_free(wm8350); + wm8350_pmu_exit(); + bus_unregister(&wm8350_bus_type); i2c_detach_client(client); kfree(client); if (wm8350->reg_cache) diff --git a/drivers/regulator/wm8350/reg-wm8350.c b/drivers/regulator/wm8350/reg-wm8350.c index ffbec586610e..d9aa8ec941bd 100644 --- a/drivers/regulator/wm8350/reg-wm8350.c +++ b/drivers/regulator/wm8350/reg-wm8350.c @@ -997,19 +997,16 @@ struct device_driver wm8350_driver = { .remove = wm8350_remove, }; -static int __devinit wm8350_pmu_init(void) +int wm8350_pmu_init(void) { return driver_register(&wm8350_driver); } -static void wm8350_pmu_exit(void) +void wm8350_pmu_exit(void) { driver_unregister(&wm8350_driver); } -module_init(wm8350_pmu_init); -module_exit(wm8350_pmu_exit); - /* Module information */ MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com,\ www.wolfsonmicro.com"); |