diff options
| author | Mark Brown <broonie@linaro.org> | 2013-09-01 08:50:17 -0400 |
|---|---|---|
| committer | Mark Brown <broonie@linaro.org> | 2013-09-01 08:50:17 -0400 |
| commit | f27a5fb424d4897edd3c7735ecf054ee57a5dbd0 (patch) | |
| tree | a6bc4d322341ee1211657302f41614b52572b207 /drivers/regulator | |
| parent | 6979380d85fd9e1ff701021206b315fcd66b510e (diff) | |
| parent | 9efdd27678ef5e22c27c230a08a211b702768f3a (diff) | |
Merge remote-tracking branch 'regulator/topic/optional' into regulator-next
Diffstat (limited to 'drivers/regulator')
| -rw-r--r-- | drivers/regulator/core.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a560da3a633e..9f4ccf2b3340 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
| @@ -1413,6 +1413,65 @@ struct regulator *regulator_get_exclusive(struct device *dev, const char *id) | |||
| 1413 | } | 1413 | } |
| 1414 | EXPORT_SYMBOL_GPL(regulator_get_exclusive); | 1414 | EXPORT_SYMBOL_GPL(regulator_get_exclusive); |
| 1415 | 1415 | ||
| 1416 | /** | ||
| 1417 | * regulator_get_optional - obtain optional access to a regulator. | ||
| 1418 | * @dev: device for regulator "consumer" | ||
| 1419 | * @id: Supply name or regulator ID. | ||
| 1420 | * | ||
| 1421 | * Returns a struct regulator corresponding to the regulator producer, | ||
| 1422 | * or IS_ERR() condition containing errno. Other consumers will be | ||
| 1423 | * unable to obtain this reference is held and the use count for the | ||
| 1424 | * regulator will be initialised to reflect the current state of the | ||
| 1425 | * regulator. | ||
| 1426 | * | ||
| 1427 | * This is intended for use by consumers for devices which can have | ||
| 1428 | * some supplies unconnected in normal use, such as some MMC devices. | ||
| 1429 | * It can allow the regulator core to provide stub supplies for other | ||
| 1430 | * supplies requested using normal regulator_get() calls without | ||
| 1431 | * disrupting the operation of drivers that can handle absent | ||
| 1432 | * supplies. | ||
| 1433 | * | ||
| 1434 | * Use of supply names configured via regulator_set_device_supply() is | ||
| 1435 | * strongly encouraged. It is recommended that the supply name used | ||
| 1436 | * should match the name used for the supply and/or the relevant | ||
| 1437 | * device pins in the datasheet. | ||
| 1438 | */ | ||
| 1439 | struct regulator *regulator_get_optional(struct device *dev, const char *id) | ||
| 1440 | { | ||
| 1441 | return _regulator_get(dev, id, 0); | ||
| 1442 | } | ||
| 1443 | EXPORT_SYMBOL_GPL(regulator_get_optional); | ||
| 1444 | |||
| 1445 | /** | ||
| 1446 | * devm_regulator_get_optional - Resource managed regulator_get_optional() | ||
| 1447 | * @dev: device for regulator "consumer" | ||
| 1448 | * @id: Supply name or regulator ID. | ||
| 1449 | * | ||
| 1450 | * Managed regulator_get_optional(). Regulators returned from this | ||
| 1451 | * function are automatically regulator_put() on driver detach. See | ||
| 1452 | * regulator_get_optional() for more information. | ||
| 1453 | */ | ||
| 1454 | struct regulator *devm_regulator_get_optional(struct device *dev, | ||
| 1455 | const char *id) | ||
| 1456 | { | ||
| 1457 | struct regulator **ptr, *regulator; | ||
| 1458 | |||
| 1459 | ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); | ||
| 1460 | if (!ptr) | ||
| 1461 | return ERR_PTR(-ENOMEM); | ||
| 1462 | |||
| 1463 | regulator = regulator_get_optional(dev, id); | ||
| 1464 | if (!IS_ERR(regulator)) { | ||
| 1465 | *ptr = regulator; | ||
| 1466 | devres_add(dev, ptr); | ||
| 1467 | } else { | ||
| 1468 | devres_free(ptr); | ||
| 1469 | } | ||
| 1470 | |||
| 1471 | return regulator; | ||
| 1472 | } | ||
| 1473 | EXPORT_SYMBOL_GPL(devm_regulator_get_optional); | ||
| 1474 | |||
| 1416 | /* Locks held by regulator_put() */ | 1475 | /* Locks held by regulator_put() */ |
| 1417 | static void _regulator_put(struct regulator *regulator) | 1476 | static void _regulator_put(struct regulator *regulator) |
| 1418 | { | 1477 | { |
| @@ -1439,6 +1498,36 @@ static void _regulator_put(struct regulator *regulator) | |||
| 1439 | } | 1498 | } |
| 1440 | 1499 | ||
| 1441 | /** | 1500 | /** |
| 1501 | * devm_regulator_get_exclusive - Resource managed regulator_get_exclusive() | ||
| 1502 | * @dev: device for regulator "consumer" | ||
| 1503 | * @id: Supply name or regulator ID. | ||
| 1504 | * | ||
| 1505 | * Managed regulator_get_exclusive(). Regulators returned from this function | ||
| 1506 | * are automatically regulator_put() on driver detach. See regulator_get() for | ||
| 1507 | * more information. | ||
| 1508 | */ | ||
| 1509 | struct regulator *devm_regulator_get_exclusive(struct device *dev, | ||
| 1510 | const char *id) | ||
| 1511 | { | ||
| 1512 | struct regulator **ptr, *regulator; | ||
| 1513 | |||
| 1514 | ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); | ||
| 1515 | if (!ptr) | ||
| 1516 | return ERR_PTR(-ENOMEM); | ||
| 1517 | |||
| 1518 | regulator = _regulator_get(dev, id, 1); | ||
| 1519 | if (!IS_ERR(regulator)) { | ||
| 1520 | *ptr = regulator; | ||
| 1521 | devres_add(dev, ptr); | ||
| 1522 | } else { | ||
| 1523 | devres_free(ptr); | ||
| 1524 | } | ||
| 1525 | |||
| 1526 | return regulator; | ||
| 1527 | } | ||
| 1528 | EXPORT_SYMBOL_GPL(devm_regulator_get_exclusive); | ||
| 1529 | |||
| 1530 | /** | ||
| 1442 | * regulator_put - "free" the regulator source | 1531 | * regulator_put - "free" the regulator source |
| 1443 | * @regulator: regulator source | 1532 | * @regulator: regulator source |
| 1444 | * | 1533 | * |
