diff options
author | Mark Brown <broonie@linaro.org> | 2013-09-01 08:50:06 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-09-01 08:50:06 -0400 |
commit | 1ad13028e55847185646b2be7d8b86b311c33249 (patch) | |
tree | 59e30b76948b0031777886ca1e3425205ae08de5 | |
parent | 5288be36cd40d2b830c4165cf1a9c15631eae250 (diff) | |
parent | 84fcf447a99c8cc9cc906b42e590d1a3a7ed56ab (diff) |
Merge remote-tracking branch 'regulator/topic/core' into regulator-next
-rw-r--r-- | drivers/regulator/core.c | 44 | ||||
-rw-r--r-- | include/linux/regulator/consumer.h | 7 |
2 files changed, 31 insertions, 20 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 42ae134797e0..e8dd361cba28 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -323,13 +323,14 @@ static ssize_t regulator_uA_show(struct device *dev, | |||
323 | } | 323 | } |
324 | static DEVICE_ATTR(microamps, 0444, regulator_uA_show, NULL); | 324 | static DEVICE_ATTR(microamps, 0444, regulator_uA_show, NULL); |
325 | 325 | ||
326 | static ssize_t regulator_name_show(struct device *dev, | 326 | static ssize_t name_show(struct device *dev, struct device_attribute *attr, |
327 | struct device_attribute *attr, char *buf) | 327 | char *buf) |
328 | { | 328 | { |
329 | struct regulator_dev *rdev = dev_get_drvdata(dev); | 329 | struct regulator_dev *rdev = dev_get_drvdata(dev); |
330 | 330 | ||
331 | return sprintf(buf, "%s\n", rdev_get_name(rdev)); | 331 | return sprintf(buf, "%s\n", rdev_get_name(rdev)); |
332 | } | 332 | } |
333 | static DEVICE_ATTR_RO(name); | ||
333 | 334 | ||
334 | static ssize_t regulator_print_opmode(char *buf, int mode) | 335 | static ssize_t regulator_print_opmode(char *buf, int mode) |
335 | { | 336 | { |
@@ -489,15 +490,16 @@ static ssize_t regulator_total_uA_show(struct device *dev, | |||
489 | } | 490 | } |
490 | static DEVICE_ATTR(requested_microamps, 0444, regulator_total_uA_show, NULL); | 491 | static DEVICE_ATTR(requested_microamps, 0444, regulator_total_uA_show, NULL); |
491 | 492 | ||
492 | static ssize_t regulator_num_users_show(struct device *dev, | 493 | static ssize_t num_users_show(struct device *dev, struct device_attribute *attr, |
493 | struct device_attribute *attr, char *buf) | 494 | char *buf) |
494 | { | 495 | { |
495 | struct regulator_dev *rdev = dev_get_drvdata(dev); | 496 | struct regulator_dev *rdev = dev_get_drvdata(dev); |
496 | return sprintf(buf, "%d\n", rdev->use_count); | 497 | return sprintf(buf, "%d\n", rdev->use_count); |
497 | } | 498 | } |
499 | static DEVICE_ATTR_RO(num_users); | ||
498 | 500 | ||
499 | static ssize_t regulator_type_show(struct device *dev, | 501 | static ssize_t type_show(struct device *dev, struct device_attribute *attr, |
500 | struct device_attribute *attr, char *buf) | 502 | char *buf) |
501 | { | 503 | { |
502 | struct regulator_dev *rdev = dev_get_drvdata(dev); | 504 | struct regulator_dev *rdev = dev_get_drvdata(dev); |
503 | 505 | ||
@@ -509,6 +511,7 @@ static ssize_t regulator_type_show(struct device *dev, | |||
509 | } | 511 | } |
510 | return sprintf(buf, "unknown\n"); | 512 | return sprintf(buf, "unknown\n"); |
511 | } | 513 | } |
514 | static DEVICE_ATTR_RO(type); | ||
512 | 515 | ||
513 | static ssize_t regulator_suspend_mem_uV_show(struct device *dev, | 516 | static ssize_t regulator_suspend_mem_uV_show(struct device *dev, |
514 | struct device_attribute *attr, char *buf) | 517 | struct device_attribute *attr, char *buf) |
@@ -632,12 +635,13 @@ static DEVICE_ATTR(bypass, 0444, | |||
632 | * These are the only attributes are present for all regulators. | 635 | * These are the only attributes are present for all regulators. |
633 | * Other attributes are a function of regulator functionality. | 636 | * Other attributes are a function of regulator functionality. |
634 | */ | 637 | */ |
635 | static struct device_attribute regulator_dev_attrs[] = { | 638 | static struct attribute *regulator_dev_attrs[] = { |
636 | __ATTR(name, 0444, regulator_name_show, NULL), | 639 | &dev_attr_name.attr, |
637 | __ATTR(num_users, 0444, regulator_num_users_show, NULL), | 640 | &dev_attr_num_users.attr, |
638 | __ATTR(type, 0444, regulator_type_show, NULL), | 641 | &dev_attr_type.attr, |
639 | __ATTR_NULL, | 642 | NULL, |
640 | }; | 643 | }; |
644 | ATTRIBUTE_GROUPS(regulator_dev); | ||
641 | 645 | ||
642 | static void regulator_dev_release(struct device *dev) | 646 | static void regulator_dev_release(struct device *dev) |
643 | { | 647 | { |
@@ -648,7 +652,7 @@ static void regulator_dev_release(struct device *dev) | |||
648 | static struct class regulator_class = { | 652 | static struct class regulator_class = { |
649 | .name = "regulator", | 653 | .name = "regulator", |
650 | .dev_release = regulator_dev_release, | 654 | .dev_release = regulator_dev_release, |
651 | .dev_attrs = regulator_dev_attrs, | 655 | .dev_groups = regulator_dev_groups, |
652 | }; | 656 | }; |
653 | 657 | ||
654 | /* Calculate the new optimum regulator operating mode based on the new total | 658 | /* Calculate the new optimum regulator operating mode based on the new total |
@@ -1238,7 +1242,7 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev, | |||
1238 | 1242 | ||
1239 | /* Internal regulator request function */ | 1243 | /* Internal regulator request function */ |
1240 | static struct regulator *_regulator_get(struct device *dev, const char *id, | 1244 | static struct regulator *_regulator_get(struct device *dev, const char *id, |
1241 | int exclusive) | 1245 | bool exclusive) |
1242 | { | 1246 | { |
1243 | struct regulator_dev *rdev; | 1247 | struct regulator_dev *rdev; |
1244 | struct regulator *regulator = ERR_PTR(-EPROBE_DEFER); | 1248 | struct regulator *regulator = ERR_PTR(-EPROBE_DEFER); |
@@ -1344,7 +1348,7 @@ out: | |||
1344 | */ | 1348 | */ |
1345 | struct regulator *regulator_get(struct device *dev, const char *id) | 1349 | struct regulator *regulator_get(struct device *dev, const char *id) |
1346 | { | 1350 | { |
1347 | return _regulator_get(dev, id, 0); | 1351 | return _regulator_get(dev, id, false); |
1348 | } | 1352 | } |
1349 | EXPORT_SYMBOL_GPL(regulator_get); | 1353 | EXPORT_SYMBOL_GPL(regulator_get); |
1350 | 1354 | ||
@@ -1405,7 +1409,7 @@ EXPORT_SYMBOL_GPL(devm_regulator_get); | |||
1405 | */ | 1409 | */ |
1406 | struct regulator *regulator_get_exclusive(struct device *dev, const char *id) | 1410 | struct regulator *regulator_get_exclusive(struct device *dev, const char *id) |
1407 | { | 1411 | { |
1408 | return _regulator_get(dev, id, 1); | 1412 | return _regulator_get(dev, id, true); |
1409 | } | 1413 | } |
1410 | EXPORT_SYMBOL_GPL(regulator_get_exclusive); | 1414 | EXPORT_SYMBOL_GPL(regulator_get_exclusive); |
1411 | 1415 | ||
@@ -1890,8 +1894,9 @@ int regulator_disable_deferred(struct regulator *regulator, int ms) | |||
1890 | rdev->deferred_disables++; | 1894 | rdev->deferred_disables++; |
1891 | mutex_unlock(&rdev->mutex); | 1895 | mutex_unlock(&rdev->mutex); |
1892 | 1896 | ||
1893 | ret = schedule_delayed_work(&rdev->disable_work, | 1897 | ret = queue_delayed_work(system_power_efficient_wq, |
1894 | msecs_to_jiffies(ms)); | 1898 | &rdev->disable_work, |
1899 | msecs_to_jiffies(ms)); | ||
1895 | if (ret < 0) | 1900 | if (ret < 0) |
1896 | return ret; | 1901 | return ret; |
1897 | else | 1902 | else |
@@ -3835,8 +3840,11 @@ void regulator_unregister(struct regulator_dev *rdev) | |||
3835 | if (rdev == NULL) | 3840 | if (rdev == NULL) |
3836 | return; | 3841 | return; |
3837 | 3842 | ||
3838 | if (rdev->supply) | 3843 | if (rdev->supply) { |
3844 | while (rdev->use_count--) | ||
3845 | regulator_disable(rdev->supply); | ||
3839 | regulator_put(rdev->supply); | 3846 | regulator_put(rdev->supply); |
3847 | } | ||
3840 | mutex_lock(®ulator_list_mutex); | 3848 | mutex_lock(®ulator_list_mutex); |
3841 | debugfs_remove_recursive(rdev->debugfs); | 3849 | debugfs_remove_recursive(rdev->debugfs); |
3842 | flush_work(&rdev->disable_work.work); | 3850 | flush_work(&rdev->disable_work.work); |
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index 3a76389c6aaa..3610df8dd229 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h | |||
@@ -369,8 +369,11 @@ static inline int regulator_count_voltages(struct regulator *regulator) | |||
369 | static inline int regulator_set_voltage_tol(struct regulator *regulator, | 369 | static inline int regulator_set_voltage_tol(struct regulator *regulator, |
370 | int new_uV, int tol_uV) | 370 | int new_uV, int tol_uV) |
371 | { | 371 | { |
372 | return regulator_set_voltage(regulator, | 372 | if (regulator_set_voltage(regulator, new_uV, new_uV + tol_uV) == 0) |
373 | new_uV - tol_uV, new_uV + tol_uV); | 373 | return 0; |
374 | else | ||
375 | return regulator_set_voltage(regulator, | ||
376 | new_uV - tol_uV, new_uV + tol_uV); | ||
374 | } | 377 | } |
375 | 378 | ||
376 | static inline int regulator_is_supported_voltage_tol(struct regulator *regulator, | 379 | static inline int regulator_is_supported_voltage_tol(struct regulator *regulator, |