drivers/regulator: Import OnePlus Changes

Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
This commit is contained in:
Cyber Knight 2021-09-26 01:50:24 +08:00
parent d0ff892c18
commit dc6592dea8
No known key found for this signature in database
GPG Key ID: 23BD4CCD326E9D64
1 changed files with 29 additions and 39 deletions

View File

@ -1219,7 +1219,7 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
const char *consumer_dev_name,
const char *supply)
{
struct regulator_map *node, *new_node;
struct regulator_map *node;
int has_dev;
if (supply == NULL)
@ -1230,22 +1230,6 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
else
has_dev = 0;
new_node = kzalloc(sizeof(struct regulator_map), GFP_KERNEL);
if (new_node == NULL)
return -ENOMEM;
new_node->regulator = rdev;
new_node->supply = supply;
if (has_dev) {
new_node->dev_name = kstrdup(consumer_dev_name, GFP_KERNEL);
if (new_node->dev_name == NULL) {
kfree(new_node);
return -ENOMEM;
}
}
mutex_lock(&regulator_list_mutex);
list_for_each_entry(node, &regulator_map_list, list) {
if (node->dev_name && consumer_dev_name) {
if (strcmp(node->dev_name, consumer_dev_name) != 0)
@ -1263,19 +1247,26 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
node->regulator->desc->name,
supply,
dev_name(&rdev->dev), rdev_get_name(rdev));
goto fail;
return -EBUSY;
}
list_add(&new_node->list, &regulator_map_list);
mutex_unlock(&regulator_list_mutex);
node = kzalloc(sizeof(struct regulator_map), GFP_KERNEL);
if (node == NULL)
return -ENOMEM;
node->regulator = rdev;
node->supply = supply;
if (has_dev) {
node->dev_name = kstrdup(consumer_dev_name, GFP_KERNEL);
if (node->dev_name == NULL) {
kfree(node);
return -ENOMEM;
}
}
list_add(&node->list, &regulator_map_list);
return 0;
fail:
mutex_unlock(&regulator_list_mutex);
kfree(new_node->dev_name);
kfree(new_node);
return -EBUSY;
}
static void unset_regulator_supplies(struct regulator_dev *rdev)
@ -3984,6 +3975,7 @@ static void regulator_dev_release(struct device *dev)
kfree(rdev->constraints);
of_node_put(rdev->dev.of_node);
kfree(rdev);
rdev = NULL;
}
static struct class regulator_class = {
@ -4474,35 +4466,33 @@ regulator_register(const struct regulator_desc *regulator_desc,
else if (regulator_desc->supply_name)
rdev->supply_name = regulator_desc->supply_name;
/*
* Attempt to resolve the regulator supply, if specified,
* but don't return an error if we fail because we will try
* to resolve it again later as more regulators are added.
*/
if (regulator_resolve_supply(rdev))
rdev_dbg(rdev, "unable to resolve supply\n");
ret = set_machine_constraints(rdev, constraints);
if (ret == -EPROBE_DEFER) {
/* Regulator might be in bypass mode and so needs its supply
* to set the constraints */
/* FIXME: this currently triggers a chicken-and-egg problem
* when creating -SUPPLY symlink in sysfs to a regulator
* that is just being created */
ret = regulator_resolve_supply(rdev);
if (!ret)
ret = set_machine_constraints(rdev, constraints);
else
rdev_dbg(rdev, "unable to resolve supply early: %pe\n",
ERR_PTR(ret));
}
if (ret < 0)
goto wash;
/* add consumers devices */
if (init_data) {
mutex_lock(&regulator_list_mutex);
for (i = 0; i < init_data->num_consumer_supplies; i++) {
ret = set_consumer_device_supply(rdev,
init_data->consumer_supplies[i].dev_name,
init_data->consumer_supplies[i].supply);
if (ret < 0) {
mutex_unlock(&regulator_list_mutex);
dev_err(dev, "Failed to set supply %s\n",
init_data->consumer_supplies[i].supply);
goto unset_supplies;
}
}
mutex_unlock(&regulator_list_mutex);
}
if (!rdev->desc->ops->get_voltage &&