You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
regulator: core: have _regulator_get() accept get_type argument
Instead of separate "exclusive" and "allow_dummy" arguments, that formed 3 valid combinations (normal, exclusive and optional) and an invalid one, let's accept explicit "get_type", like we did in devm-managed code. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
7d245afa24
commit
a8bd42a977
@@ -1580,14 +1580,19 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Internal regulator request function */
|
/* Internal regulator request function */
|
||||||
static struct regulator *_regulator_get(struct device *dev, const char *id,
|
struct regulator *_regulator_get(struct device *dev, const char *id,
|
||||||
bool exclusive, bool allow_dummy)
|
enum regulator_get_type get_type)
|
||||||
{
|
{
|
||||||
struct regulator_dev *rdev;
|
struct regulator_dev *rdev;
|
||||||
struct regulator *regulator;
|
struct regulator *regulator;
|
||||||
const char *devname = NULL;
|
const char *devname = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (get_type >= MAX_GET_TYPE) {
|
||||||
|
dev_err(dev, "invalid type %d in %s\n", get_type, __func__);
|
||||||
|
return ERR_PTR(-EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
if (id == NULL) {
|
if (id == NULL) {
|
||||||
pr_err("get() with no identifier\n");
|
pr_err("get() with no identifier\n");
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
@@ -1616,7 +1621,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
|
|||||||
* Assume that a regulator is physically present and enabled
|
* Assume that a regulator is physically present and enabled
|
||||||
* even if it isn't hooked up and just provide a dummy.
|
* even if it isn't hooked up and just provide a dummy.
|
||||||
*/
|
*/
|
||||||
if (have_full_constraints() && allow_dummy) {
|
if (have_full_constraints() && get_type == NORMAL_GET) {
|
||||||
pr_warn("%s supply %s not found, using dummy regulator\n",
|
pr_warn("%s supply %s not found, using dummy regulator\n",
|
||||||
devname, id);
|
devname, id);
|
||||||
|
|
||||||
@@ -1624,7 +1629,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
|
|||||||
get_device(&rdev->dev);
|
get_device(&rdev->dev);
|
||||||
goto found;
|
goto found;
|
||||||
/* Don't log an error when called from regulator_get_optional() */
|
/* Don't log an error when called from regulator_get_optional() */
|
||||||
} else if (!have_full_constraints() || exclusive) {
|
} else if (!have_full_constraints() || get_type == EXCLUSIVE_GET) {
|
||||||
dev_warn(dev, "dummy supplies not allowed\n");
|
dev_warn(dev, "dummy supplies not allowed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1637,7 +1642,7 @@ found:
|
|||||||
return regulator;
|
return regulator;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exclusive && rdev->open_count) {
|
if (get_type == EXCLUSIVE_GET && rdev->open_count) {
|
||||||
regulator = ERR_PTR(-EBUSY);
|
regulator = ERR_PTR(-EBUSY);
|
||||||
put_device(&rdev->dev);
|
put_device(&rdev->dev);
|
||||||
return regulator;
|
return regulator;
|
||||||
@@ -1665,7 +1670,7 @@ found:
|
|||||||
}
|
}
|
||||||
|
|
||||||
rdev->open_count++;
|
rdev->open_count++;
|
||||||
if (exclusive) {
|
if (get_type == EXCLUSIVE_GET) {
|
||||||
rdev->exclusive = 1;
|
rdev->exclusive = 1;
|
||||||
|
|
||||||
ret = _regulator_is_enabled(rdev);
|
ret = _regulator_is_enabled(rdev);
|
||||||
@@ -1693,7 +1698,7 @@ found:
|
|||||||
*/
|
*/
|
||||||
struct regulator *regulator_get(struct device *dev, const char *id)
|
struct regulator *regulator_get(struct device *dev, const char *id)
|
||||||
{
|
{
|
||||||
return _regulator_get(dev, id, false, true);
|
return _regulator_get(dev, id, NORMAL_GET);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(regulator_get);
|
EXPORT_SYMBOL_GPL(regulator_get);
|
||||||
|
|
||||||
@@ -1720,7 +1725,7 @@ EXPORT_SYMBOL_GPL(regulator_get);
|
|||||||
*/
|
*/
|
||||||
struct regulator *regulator_get_exclusive(struct device *dev, const char *id)
|
struct regulator *regulator_get_exclusive(struct device *dev, const char *id)
|
||||||
{
|
{
|
||||||
return _regulator_get(dev, id, true, false);
|
return _regulator_get(dev, id, EXCLUSIVE_GET);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(regulator_get_exclusive);
|
EXPORT_SYMBOL_GPL(regulator_get_exclusive);
|
||||||
|
|
||||||
@@ -1746,7 +1751,7 @@ EXPORT_SYMBOL_GPL(regulator_get_exclusive);
|
|||||||
*/
|
*/
|
||||||
struct regulator *regulator_get_optional(struct device *dev, const char *id)
|
struct regulator *regulator_get_optional(struct device *dev, const char *id)
|
||||||
{
|
{
|
||||||
return _regulator_get(dev, id, false, false);
|
return _regulator_get(dev, id, OPTIONAL_GET);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(regulator_get_optional);
|
EXPORT_SYMBOL_GPL(regulator_get_optional);
|
||||||
|
|
||||||
|
|||||||
@@ -19,12 +19,6 @@
|
|||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
enum {
|
|
||||||
NORMAL_GET,
|
|
||||||
EXCLUSIVE_GET,
|
|
||||||
OPTIONAL_GET,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void devm_regulator_release(struct device *dev, void *res)
|
static void devm_regulator_release(struct device *dev, void *res)
|
||||||
{
|
{
|
||||||
regulator_put(*(struct regulator **)res);
|
regulator_put(*(struct regulator **)res);
|
||||||
@@ -39,20 +33,7 @@ static struct regulator *_devm_regulator_get(struct device *dev, const char *id,
|
|||||||
if (!ptr)
|
if (!ptr)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
switch (get_type) {
|
regulator = _regulator_get(dev, id, get_type);
|
||||||
case NORMAL_GET:
|
|
||||||
regulator = regulator_get(dev, id);
|
|
||||||
break;
|
|
||||||
case EXCLUSIVE_GET:
|
|
||||||
regulator = regulator_get_exclusive(dev, id);
|
|
||||||
break;
|
|
||||||
case OPTIONAL_GET:
|
|
||||||
regulator = regulator_get_optional(dev, id);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
regulator = ERR_PTR(-EINVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!IS_ERR(regulator)) {
|
if (!IS_ERR(regulator)) {
|
||||||
*ptr = regulator;
|
*ptr = regulator;
|
||||||
devres_add(dev, ptr);
|
devres_add(dev, ptr);
|
||||||
|
|||||||
@@ -51,4 +51,14 @@ regulator_of_get_init_data(struct device *dev,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
enum regulator_get_type {
|
||||||
|
NORMAL_GET,
|
||||||
|
EXCLUSIVE_GET,
|
||||||
|
OPTIONAL_GET,
|
||||||
|
MAX_GET_TYPE
|
||||||
|
};
|
||||||
|
|
||||||
|
struct regulator *_regulator_get(struct device *dev, const char *id,
|
||||||
|
enum regulator_get_type get_type);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user