aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-09-01 08:50:17 -0400
committerMark Brown <broonie@linaro.org>2013-09-01 08:50:17 -0400
commitf27a5fb424d4897edd3c7735ecf054ee57a5dbd0 (patch)
treea6bc4d322341ee1211657302f41614b52572b207
parent6979380d85fd9e1ff701021206b315fcd66b510e (diff)
parent9efdd27678ef5e22c27c230a08a211b702768f3a (diff)
Merge remote-tracking branch 'regulator/topic/optional' into regulator-next
-rw-r--r--drivers/cpufreq/cpufreq-cpu0.c2
-rw-r--r--drivers/hwmon/sht15.c2
-rw-r--r--drivers/mmc/core/core.c2
-rw-r--r--drivers/mmc/host/dw_mmc.c2
-rw-r--r--drivers/mmc/host/pxamci.c2
-rw-r--r--drivers/mmc/host/sdhci.c4
-rw-r--r--drivers/regulator/core.c89
-rw-r--r--include/linux/regulator/consumer.h25
8 files changed, 121 insertions, 7 deletions
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index ad1fde277661..e9dedb27deca 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -197,7 +197,7 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev)
197 cpu_dev = &pdev->dev; 197 cpu_dev = &pdev->dev;
198 cpu_dev->of_node = np; 198 cpu_dev->of_node = np;
199 199
200 cpu_reg = devm_regulator_get(cpu_dev, "cpu0"); 200 cpu_reg = devm_regulator_get_optional(cpu_dev, "cpu0");
201 if (IS_ERR(cpu_reg)) { 201 if (IS_ERR(cpu_reg)) {
202 /* 202 /*
203 * If cpu0 regulator supply node is present, but regulator is 203 * If cpu0 regulator supply node is present, but regulator is
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
index 2507f902fb7a..ab5dc3af4cfb 100644
--- a/drivers/hwmon/sht15.c
+++ b/drivers/hwmon/sht15.c
@@ -957,7 +957,7 @@ static int sht15_probe(struct platform_device *pdev)
957 * If a regulator is available, 957 * If a regulator is available,
958 * query what the supply voltage actually is! 958 * query what the supply voltage actually is!
959 */ 959 */
960 data->reg = devm_regulator_get(data->dev, "vcc"); 960 data->reg = devm_regulator_get_optional(data->dev, "vcc");
961 if (!IS_ERR(data->reg)) { 961 if (!IS_ERR(data->reg)) {
962 int voltage; 962 int voltage;
963 963
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 49a5bca418bd..5d088551196b 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1313,7 +1313,7 @@ int mmc_regulator_get_supply(struct mmc_host *mmc)
1313 1313
1314 supply = devm_regulator_get(dev, "vmmc"); 1314 supply = devm_regulator_get(dev, "vmmc");
1315 mmc->supply.vmmc = supply; 1315 mmc->supply.vmmc = supply;
1316 mmc->supply.vqmmc = devm_regulator_get(dev, "vqmmc"); 1316 mmc->supply.vqmmc = devm_regulator_get_optional(dev, "vqmmc");
1317 1317
1318 if (IS_ERR(supply)) 1318 if (IS_ERR(supply))
1319 return PTR_ERR(supply); 1319 return PTR_ERR(supply);
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index ee5f1676f14e..542407363dd2 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -2231,7 +2231,7 @@ int dw_mci_probe(struct dw_mci *host)
2231 } 2231 }
2232 } 2232 }
2233 2233
2234 host->vmmc = devm_regulator_get(host->dev, "vmmc"); 2234 host->vmmc = devm_regulator_get_optional(host->dev, "vmmc");
2235 if (IS_ERR(host->vmmc)) { 2235 if (IS_ERR(host->vmmc)) {
2236 ret = PTR_ERR(host->vmmc); 2236 ret = PTR_ERR(host->vmmc);
2237 if (ret == -EPROBE_DEFER) 2237 if (ret == -EPROBE_DEFER)
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
index 2c5a91bb8ec3..1956a3df7cf3 100644
--- a/drivers/mmc/host/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -83,7 +83,7 @@ struct pxamci_host {
83static inline void pxamci_init_ocr(struct pxamci_host *host) 83static inline void pxamci_init_ocr(struct pxamci_host *host)
84{ 84{
85#ifdef CONFIG_REGULATOR 85#ifdef CONFIG_REGULATOR
86 host->vcc = regulator_get(mmc_dev(host->mmc), "vmmc"); 86 host->vcc = regulator_get_optional(mmc_dev(host->mmc), "vmmc");
87 87
88 if (IS_ERR(host->vcc)) 88 if (IS_ERR(host->vcc))
89 host->vcc = NULL; 89 host->vcc = NULL;
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index a78bd4f3aecc..dd2c083c434d 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2966,7 +2966,7 @@ int sdhci_add_host(struct sdhci_host *host)
2966 mmc->caps |= MMC_CAP_NEEDS_POLL; 2966 mmc->caps |= MMC_CAP_NEEDS_POLL;
2967 2967
2968 /* If vqmmc regulator and no 1.8V signalling, then there's no UHS */ 2968 /* If vqmmc regulator and no 1.8V signalling, then there's no UHS */
2969 host->vqmmc = regulator_get(mmc_dev(mmc), "vqmmc"); 2969 host->vqmmc = regulator_get_optional(mmc_dev(mmc), "vqmmc");
2970 if (IS_ERR_OR_NULL(host->vqmmc)) { 2970 if (IS_ERR_OR_NULL(host->vqmmc)) {
2971 if (PTR_ERR(host->vqmmc) < 0) { 2971 if (PTR_ERR(host->vqmmc) < 0) {
2972 pr_info("%s: no vqmmc regulator found\n", 2972 pr_info("%s: no vqmmc regulator found\n",
@@ -3042,7 +3042,7 @@ int sdhci_add_host(struct sdhci_host *host)
3042 3042
3043 ocr_avail = 0; 3043 ocr_avail = 0;
3044 3044
3045 host->vmmc = regulator_get(mmc_dev(mmc), "vmmc"); 3045 host->vmmc = regulator_get_optional(mmc_dev(mmc), "vmmc");
3046 if (IS_ERR_OR_NULL(host->vmmc)) { 3046 if (IS_ERR_OR_NULL(host->vmmc)) {
3047 if (PTR_ERR(host->vmmc) < 0) { 3047 if (PTR_ERR(host->vmmc) < 0) {
3048 pr_info("%s: no vmmc regulator found\n", 3048 pr_info("%s: no vmmc regulator found\n",
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}
1414EXPORT_SYMBOL_GPL(regulator_get_exclusive); 1414EXPORT_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 */
1439struct regulator *regulator_get_optional(struct device *dev, const char *id)
1440{
1441 return _regulator_get(dev, id, 0);
1442}
1443EXPORT_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 */
1454struct 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}
1473EXPORT_SYMBOL_GPL(devm_regulator_get_optional);
1474
1416/* Locks held by regulator_put() */ 1475/* Locks held by regulator_put() */
1417static void _regulator_put(struct regulator *regulator) 1476static 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 */
1509struct 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}
1528EXPORT_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 *
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index 3610df8dd229..27be915caa96 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -137,6 +137,12 @@ struct regulator *__must_check devm_regulator_get(struct device *dev,
137 const char *id); 137 const char *id);
138struct regulator *__must_check regulator_get_exclusive(struct device *dev, 138struct regulator *__must_check regulator_get_exclusive(struct device *dev,
139 const char *id); 139 const char *id);
140struct regulator *__must_check devm_regulator_get_exclusive(struct device *dev,
141 const char *id);
142struct regulator *__must_check regulator_get_optional(struct device *dev,
143 const char *id);
144struct regulator *__must_check devm_regulator_get_optional(struct device *dev,
145 const char *id);
140void regulator_put(struct regulator *regulator); 146void regulator_put(struct regulator *regulator);
141void devm_regulator_put(struct regulator *regulator); 147void devm_regulator_put(struct regulator *regulator);
142 148
@@ -217,6 +223,25 @@ devm_regulator_get(struct device *dev, const char *id)
217 return NULL; 223 return NULL;
218} 224}
219 225
226static inline struct regulator *__must_check
227regulator_get_exclusive(struct device *dev, const char *id)
228{
229 return NULL;
230}
231
232static inline struct regulator *__must_check
233regulator_get_optional(struct device *dev, const char *id)
234{
235 return NULL;
236}
237
238
239static inline struct regulator *__must_check
240devm_regulator_get_optional(struct device *dev, const char *id)
241{
242 return NULL;
243}
244
220static inline void regulator_put(struct regulator *regulator) 245static inline void regulator_put(struct regulator *regulator)
221{ 246{
222} 247}