summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2024-08-22 23:58:11 +0300
committerMark Brown <broonie@kernel.org>2024-08-22 23:58:11 +0300
commitbff5ca83791801b33c1e973e81d077ddc7530e33 (patch)
tree297e371a4418e66bb770de2b45cad26b632b2d4b /drivers
parentb8195520e8b486a0922b4baf511a2fd19bbfc25f (diff)
parentbfefa214d179f13d01cf1b64a7efbabf586b0c49 (diff)
downloadlinux-bff5ca83791801b33c1e973e81d077ddc7530e33.tar.xz
regulator: Minor cleanups
Merge series from Chen-Yu Tsai <wenst@chromium.org>: Here are some cleanups for some bits that I saw while reworking my I2C device tree component prober to use of_regulator_bulk_get_all(). These are not directly related to that series, so I send them separately here.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/regulator/core.c2
-rw-r--r--drivers/regulator/of_regulator.c23
2 files changed, 14 insertions, 11 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 7674b7f2df14..9029de5395ee 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2183,7 +2183,7 @@ struct regulator *_regulator_get(struct device *dev, const char *id,
}
if (id == NULL) {
- pr_err("get() with no identifier\n");
+ dev_err(dev, "regulator request with no identifier\n");
return ERR_PTR(-EINVAL);
}
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 03afc160fc72..d557f7b1ec7c 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -747,19 +747,19 @@ static int is_supply_name(const char *name)
* This helper function allows drivers to get several regulator
* consumers in one operation. If any of the regulators cannot be
* acquired then any regulators that were allocated will be freed
- * before returning to the caller.
+ * before returning to the caller, and @consumers will not be
+ * changed.
*/
int of_regulator_bulk_get_all(struct device *dev, struct device_node *np,
struct regulator_bulk_data **consumers)
{
int num_consumers = 0;
struct regulator *tmp;
+ struct regulator_bulk_data *_consumers = NULL;
struct property *prop;
int i, n = 0, ret;
char name[64];
- *consumers = NULL;
-
/*
* first pass: get numbers of xxx-supply
* second pass: fill consumers
@@ -769,7 +769,7 @@ restart:
i = is_supply_name(prop->name);
if (i == 0)
continue;
- if (!*consumers) {
+ if (!_consumers) {
num_consumers++;
continue;
} else {
@@ -777,28 +777,31 @@ restart:
name[i] = '\0';
tmp = regulator_get(dev, name);
if (IS_ERR(tmp)) {
- ret = -EINVAL;
+ ret = PTR_ERR(tmp);
goto error;
}
- (*consumers)[n].consumer = tmp;
+ _consumers[n].consumer = tmp;
n++;
continue;
}
}
- if (*consumers)
+ if (_consumers) {
+ *consumers = _consumers;
return num_consumers;
+ }
if (num_consumers == 0)
return 0;
- *consumers = kmalloc_array(num_consumers,
+ _consumers = kmalloc_array(num_consumers,
sizeof(struct regulator_bulk_data),
GFP_KERNEL);
- if (!*consumers)
+ if (!_consumers)
return -ENOMEM;
goto restart;
error:
while (--n >= 0)
- regulator_put(consumers[n]->consumer);
+ regulator_put(_consumers[n].consumer);
+ kfree(_consumers);
return ret;
}
EXPORT_SYMBOL_GPL(of_regulator_bulk_get_all);