* [PATCH 0/9] regulator/core: Trivial cleanups and improvements
@ 2023-08-30 21:38 Michał Mirosław
2023-08-30 21:38 ` [PATCH 1/9] regulator/core: _regulator_get: simplify error returns Michał Mirosław
` (8 more replies)
0 siblings, 9 replies; 14+ messages in thread
From: Michał Mirosław @ 2023-08-30 21:38 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown; +Cc: linux-kernel
This is a random set of cleanups, dead code removal and minor optimizations.
Most patches are applicable independently; those that aren't share a bit
of context, but are nevertheless logically separate.
Michał Mirosław (9):
regulator/core: _regulator_get: simplify error returns
regulator/core: set_consumer_device_supply: remove `has_dev`
regulator/core: of_get_child_regulator: remove goto
regulator/core: regulator_bulk_get: remove redundant NULL stores
regulator/core: regulator_ena_gpio_ctrl: pull in ena_gpio state
handling
regulator/core: remove regulator_init callback
regulator/core: remove regulator_get_init_drvdata()
regulator/core: set_consumer_device_supply: avoid copying const data
regulator/core: make regulator_class const
drivers/regulator/core.c | 93 ++++++++++---------------------
drivers/regulator/internal.h | 2 +-
include/linux/regulator/driver.h | 1 -
include/linux/regulator/machine.h | 7 +--
4 files changed, 33 insertions(+), 70 deletions(-)
--
2.39.2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/9] regulator/core: set_consumer_device_supply: remove `has_dev`
2023-08-30 21:38 [PATCH 0/9] regulator/core: Trivial cleanups and improvements Michał Mirosław
2023-08-30 21:38 ` [PATCH 1/9] regulator/core: _regulator_get: simplify error returns Michał Mirosław
@ 2023-08-30 21:38 ` Michał Mirosław
2023-08-30 21:38 ` [PATCH 4/9] regulator/core: regulator_bulk_get: remove redundant NULL stores Michał Mirosław
` (6 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Michał Mirosław @ 2023-08-30 21:38 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown; +Cc: linux-kernel
`has_dev` is only ever used once to check if the name is non-NULL.
Inline the check and make the intent obvious.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
drivers/regulator/core.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index d440cd137c38..a467be1f198b 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1726,16 +1726,10 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
const char *supply)
{
struct regulator_map *node, *new_node;
- int has_dev;
if (supply == NULL)
return -EINVAL;
- if (consumer_dev_name != NULL)
- has_dev = 1;
- else
- has_dev = 0;
-
new_node = kzalloc(sizeof(struct regulator_map), GFP_KERNEL);
if (new_node == NULL)
return -ENOMEM;
@@ -1743,7 +1737,7 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
new_node->regulator = rdev;
new_node->supply = supply;
- if (has_dev) {
+ if (consumer_dev_name != NULL) {
new_node->dev_name = kstrdup(consumer_dev_name, GFP_KERNEL);
if (new_node->dev_name == NULL) {
kfree(new_node);
--
2.39.2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/9] regulator/core: _regulator_get: simplify error returns
2023-08-30 21:38 [PATCH 0/9] regulator/core: Trivial cleanups and improvements Michał Mirosław
@ 2023-08-30 21:38 ` Michał Mirosław
2023-08-30 21:38 ` [PATCH 2/9] regulator/core: set_consumer_device_supply: remove `has_dev` Michał Mirosław
` (7 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Michał Mirosław @ 2023-08-30 21:38 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown; +Cc: linux-kernel
Remove unnecessary stores to `regulator`.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
drivers/regulator/core.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 662711063433..d440cd137c38 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2209,15 +2209,13 @@ struct regulator *_regulator_get(struct device *dev, const char *id,
}
if (rdev->exclusive) {
- regulator = ERR_PTR(-EPERM);
put_device(&rdev->dev);
- return regulator;
+ return ERR_PTR(-EPERM);
}
if (get_type == EXCLUSIVE_GET && rdev->open_count) {
- regulator = ERR_PTR(-EBUSY);
put_device(&rdev->dev);
- return regulator;
+ return ERR_PTR(-EBUSY);
}
mutex_lock(®ulator_list_mutex);
@@ -2225,32 +2223,28 @@ struct regulator *_regulator_get(struct device *dev, const char *id,
mutex_unlock(®ulator_list_mutex);
if (ret != 0) {
- regulator = ERR_PTR(-EPROBE_DEFER);
put_device(&rdev->dev);
- return regulator;
+ return ERR_PTR(-EPROBE_DEFER);
}
ret = regulator_resolve_supply(rdev);
if (ret < 0) {
- regulator = ERR_PTR(ret);
put_device(&rdev->dev);
- return regulator;
+ return ERR_PTR(ret);
}
if (!try_module_get(rdev->owner)) {
- regulator = ERR_PTR(-EPROBE_DEFER);
put_device(&rdev->dev);
- return regulator;
+ return ERR_PTR(-EPROBE_DEFER);
}
regulator_lock(rdev);
regulator = create_regulator(rdev, dev, id);
regulator_unlock(rdev);
if (regulator == NULL) {
- regulator = ERR_PTR(-ENOMEM);
module_put(rdev->owner);
put_device(&rdev->dev);
- return regulator;
+ return ERR_PTR(-ENOMEM);
}
rdev->open_count++;
--
2.39.2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 4/9] regulator/core: regulator_bulk_get: remove redundant NULL stores
2023-08-30 21:38 [PATCH 0/9] regulator/core: Trivial cleanups and improvements Michał Mirosław
2023-08-30 21:38 ` [PATCH 1/9] regulator/core: _regulator_get: simplify error returns Michał Mirosław
2023-08-30 21:38 ` [PATCH 2/9] regulator/core: set_consumer_device_supply: remove `has_dev` Michał Mirosław
@ 2023-08-30 21:38 ` Michał Mirosław
2023-08-30 21:38 ` [PATCH 3/9] regulator/core: of_get_child_regulator: remove goto Michał Mirosław
` (5 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Michał Mirosław @ 2023-08-30 21:38 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown; +Cc: linux-kernel
On error, callers of regulator_bulk_get() pass the error up and don't
use the pointers in consumers[]. The function is documented to release
all regulators if any request fails.
Note: if an i-th regulator_get() failed only the i-th pointer was
cleared. This is another suggestion that the clearing was unnecessary.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
drivers/regulator/core.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 3703aa3f5636..63d16fe59e84 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -4829,11 +4829,7 @@ static int _notifier_call_chain(struct regulator_dev *rdev,
int _regulator_bulk_get(struct device *dev, int num_consumers,
struct regulator_bulk_data *consumers, enum regulator_get_type get_type)
{
- int i;
- int ret;
-
- for (i = 0; i < num_consumers; i++)
- consumers[i].consumer = NULL;
+ int ret, i;
for (i = 0; i < num_consumers; i++) {
consumers[i].consumer = _regulator_get(dev,
@@ -4842,7 +4838,6 @@ int _regulator_bulk_get(struct device *dev, int num_consumers,
ret = dev_err_probe(dev, PTR_ERR(consumers[i].consumer),
"Failed to get supply '%s'",
consumers[i].supply);
- consumers[i].consumer = NULL;
goto err;
}
--
2.39.2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 3/9] regulator/core: of_get_child_regulator: remove goto
2023-08-30 21:38 [PATCH 0/9] regulator/core: Trivial cleanups and improvements Michał Mirosław
` (2 preceding siblings ...)
2023-08-30 21:38 ` [PATCH 4/9] regulator/core: regulator_bulk_get: remove redundant NULL stores Michał Mirosław
@ 2023-08-30 21:38 ` Michał Mirosław
2023-08-30 21:38 ` [PATCH 5/9] regulator/core: regulator_ena_gpio_ctrl: pull in ena_gpio state handling Michał Mirosław
` (4 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Michał Mirosław @ 2023-08-30 21:38 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown; +Cc: linux-kernel
Because of_node_put() handles NULL properly (like kfree() et al)
we can call it also after the loop ends (due to child == NULL).
This makes the gotos redundant.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
drivers/regulator/core.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index a467be1f198b..3703aa3f5636 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -426,18 +426,15 @@ static struct device_node *of_get_child_regulator(struct device_node *parent,
for_each_child_of_node(parent, child) {
regnode = of_parse_phandle(child, prop_name, 0);
+ if (regnode)
+ break;
- if (!regnode) {
- regnode = of_get_child_regulator(child, prop_name);
- if (regnode)
- goto err_node_put;
- } else {
- goto err_node_put;
- }
+ regnode = of_get_child_regulator(child, prop_name);
+ if (regnode)
+ break;
}
- return NULL;
-err_node_put:
+ /* Release the node if the loop was exited early. */
of_node_put(child);
return regnode;
}
--
2.39.2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 7/9] regulator/core: remove regulator_get_init_drvdata()
2023-08-30 21:38 [PATCH 0/9] regulator/core: Trivial cleanups and improvements Michał Mirosław
` (4 preceding siblings ...)
2023-08-30 21:38 ` [PATCH 5/9] regulator/core: regulator_ena_gpio_ctrl: pull in ena_gpio state handling Michał Mirosław
@ 2023-08-30 21:38 ` Michał Mirosław
2023-08-30 21:38 ` [PATCH 6/9] regulator/core: remove regulator_init callback Michał Mirosław
` (2 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Michał Mirosław @ 2023-08-30 21:38 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown; +Cc: linux-kernel
There are no in-tree users.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
drivers/regulator/core.c | 6 ------
include/linux/regulator/driver.h | 1 -
2 files changed, 7 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index c8d1b12ee43b..7c4ba090d88d 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -5881,12 +5881,6 @@ struct regmap *rdev_get_regmap(struct regulator_dev *rdev)
}
EXPORT_SYMBOL_GPL(rdev_get_regmap);
-void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data)
-{
- return reg_init_data->driver_data;
-}
-EXPORT_SYMBOL_GPL(regulator_get_init_drvdata);
-
#ifdef CONFIG_DEBUG_FS
static int supply_map_show(struct seq_file *sf, void *data)
{
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 4b7eceb3828b..827888b4b16c 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -758,7 +758,6 @@ int regulator_set_active_discharge_regmap(struct regulator_dev *rdev,
int regulator_set_current_limit_regmap(struct regulator_dev *rdev,
int min_uA, int max_uA);
int regulator_get_current_limit_regmap(struct regulator_dev *rdev);
-void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data);
int regulator_find_closest_bigger(unsigned int target, const unsigned int *table,
unsigned int num_sel, unsigned int *sel);
int regulator_set_ramp_delay_regmap(struct regulator_dev *rdev, int ramp_delay);
--
2.39.2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 5/9] regulator/core: regulator_ena_gpio_ctrl: pull in ena_gpio state handling
2023-08-30 21:38 [PATCH 0/9] regulator/core: Trivial cleanups and improvements Michał Mirosław
` (3 preceding siblings ...)
2023-08-30 21:38 ` [PATCH 3/9] regulator/core: of_get_child_regulator: remove goto Michał Mirosław
@ 2023-08-30 21:38 ` Michał Mirosław
2023-08-31 11:13 ` Mark Brown
2023-08-30 21:38 ` [PATCH 7/9] regulator/core: remove regulator_get_init_drvdata() Michał Mirosław
` (3 subsequent siblings)
8 siblings, 1 reply; 14+ messages in thread
From: Michał Mirosław @ 2023-08-30 21:38 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown; +Cc: linux-kernel
Deduplicate `ena_gpio_state` handling by pulling it into
regulator_ena_gpio_ctrl().
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
drivers/regulator/core.c | 30 +++++++++++-------------------
1 file changed, 11 insertions(+), 19 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 63d16fe59e84..c8d1b12ee43b 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2601,6 +2601,9 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable)
if (!pin)
return -EINVAL;
+ if (rdev->ena_gpio_state == enable)
+ return 0;
+
if (enable) {
/* Enable GPIO at initial use */
if (pin->enable_count == 0)
@@ -2608,18 +2611,14 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable)
pin->enable_count++;
} else {
- if (pin->enable_count > 1) {
- pin->enable_count--;
- return 0;
- }
-
/* Disable GPIO if not used */
- if (pin->enable_count <= 1) {
+ if (pin->enable_count-- <= 1) {
gpiod_set_value_cansleep(pin->gpiod, 0);
pin->enable_count = 0;
}
}
+ rdev->ena_gpio_state = enable;
return 0;
}
@@ -2720,12 +2719,9 @@ static int _regulator_do_enable(struct regulator_dev *rdev)
}
if (rdev->ena_pin) {
- if (!rdev->ena_gpio_state) {
- ret = regulator_ena_gpio_ctrl(rdev, true);
- if (ret < 0)
- return ret;
- rdev->ena_gpio_state = 1;
- }
+ ret = regulator_ena_gpio_ctrl(rdev, true);
+ if (ret < 0)
+ return ret;
} else if (rdev->desc->ops->enable) {
ret = rdev->desc->ops->enable(rdev);
if (ret < 0)
@@ -2938,13 +2934,9 @@ static int _regulator_do_disable(struct regulator_dev *rdev)
trace_regulator_disable(rdev_get_name(rdev));
if (rdev->ena_pin) {
- if (rdev->ena_gpio_state) {
- ret = regulator_ena_gpio_ctrl(rdev, false);
- if (ret < 0)
- return ret;
- rdev->ena_gpio_state = 0;
- }
-
+ ret = regulator_ena_gpio_ctrl(rdev, false);
+ if (ret < 0)
+ return ret;
} else if (rdev->desc->ops->disable) {
ret = rdev->desc->ops->disable(rdev);
if (ret != 0)
--
2.39.2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 6/9] regulator/core: remove regulator_init callback
2023-08-30 21:38 [PATCH 0/9] regulator/core: Trivial cleanups and improvements Michał Mirosław
` (5 preceding siblings ...)
2023-08-30 21:38 ` [PATCH 7/9] regulator/core: remove regulator_get_init_drvdata() Michał Mirosław
@ 2023-08-30 21:38 ` Michał Mirosław
2023-09-01 16:09 ` kernel test robot
2023-08-30 21:38 ` [PATCH 8/9] regulator/core: set_consumer_device_supply: avoid copying const data Michał Mirosław
2023-08-30 21:38 ` [PATCH 9/9] regulator/core: make regulator_class const Michał Mirosław
8 siblings, 1 reply; 14+ messages in thread
From: Michał Mirosław @ 2023-08-30 21:38 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown; +Cc: linux-kernel
There are no in-tree users. The only usage went away in 2019 in commit
8c44e448583c ("regulator: stpmic1: Simplify regulators registration").
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
include/linux/regulator/machine.h | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index 621b7f4a3639..2d4ae9c01cde 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -256,8 +256,7 @@ struct regulator_consumer_supply {
* @num_consumer_supplies: Number of consumer device supplies.
* @consumer_supplies: Consumer device supply configuration.
*
- * @regulator_init: Callback invoked when the regulator has been registered.
- * @driver_data: Data passed to regulator_init.
+ * @driver_data: Pointer copied to regulator_dev.reg_data.
*/
struct regulator_init_data {
const char *supply_regulator; /* or NULL for system supply */
@@ -267,9 +266,7 @@ struct regulator_init_data {
int num_consumer_supplies;
struct regulator_consumer_supply *consumer_supplies;
- /* optional regulator machine specific init */
- int (*regulator_init)(void *driver_data);
- void *driver_data; /* core does not touch this */
+ void *driver_data;
};
#ifdef CONFIG_REGULATOR
--
2.39.2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 9/9] regulator/core: make regulator_class const
2023-08-30 21:38 [PATCH 0/9] regulator/core: Trivial cleanups and improvements Michał Mirosław
` (7 preceding siblings ...)
2023-08-30 21:38 ` [PATCH 8/9] regulator/core: set_consumer_device_supply: avoid copying const data Michał Mirosław
@ 2023-08-30 21:38 ` Michał Mirosław
8 siblings, 0 replies; 14+ messages in thread
From: Michał Mirosław @ 2023-08-30 21:38 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown; +Cc: linux-kernel
The `struct class` is passed only to class_register() and a const
pointer there. Make the data also const.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
drivers/regulator/core.c | 3 ++-
drivers/regulator/internal.h | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 8ab4de7cadcb..fedda29a2176 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -5797,7 +5797,7 @@ static const struct dev_pm_ops __maybe_unused regulator_pm_ops = {
};
#endif
-struct class regulator_class = {
+const struct class regulator_class = {
.name = "regulator",
.dev_release = regulator_dev_release,
.dev_groups = regulator_dev_groups,
@@ -5805,6 +5805,7 @@ struct class regulator_class = {
.pm = ®ulator_pm_ops,
#endif
};
+
/**
* regulator_has_full_constraints - the system has fully specified constraints
*
diff --git a/drivers/regulator/internal.h b/drivers/regulator/internal.h
index fb4433068d29..77a502141089 100644
--- a/drivers/regulator/internal.h
+++ b/drivers/regulator/internal.h
@@ -58,7 +58,7 @@ struct regulator {
struct dentry *debugfs;
};
-extern struct class regulator_class;
+extern const struct class regulator_class;
static inline struct regulator_dev *dev_to_rdev(struct device *dev)
{
--
2.39.2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 8/9] regulator/core: set_consumer_device_supply: avoid copying const data
2023-08-30 21:38 [PATCH 0/9] regulator/core: Trivial cleanups and improvements Michał Mirosław
` (6 preceding siblings ...)
2023-08-30 21:38 ` [PATCH 6/9] regulator/core: remove regulator_init callback Michał Mirosław
@ 2023-08-30 21:38 ` Michał Mirosław
2023-08-30 21:38 ` [PATCH 9/9] regulator/core: make regulator_class const Michał Mirosław
8 siblings, 0 replies; 14+ messages in thread
From: Michał Mirosław @ 2023-08-30 21:38 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown; +Cc: linux-kernel
As consumer_dev_name might as well be const, don't copy it if not
required.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
drivers/regulator/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 7c4ba090d88d..8ab4de7cadcb 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1735,7 +1735,7 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
new_node->supply = supply;
if (consumer_dev_name != NULL) {
- new_node->dev_name = kstrdup(consumer_dev_name, GFP_KERNEL);
+ new_node->dev_name = kstrdup_const(consumer_dev_name, GFP_KERNEL);
if (new_node->dev_name == NULL) {
kfree(new_node);
return -ENOMEM;
@@ -1770,7 +1770,7 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
fail:
mutex_unlock(®ulator_list_mutex);
- kfree(new_node->dev_name);
+ kfree_const(new_node->dev_name);
kfree(new_node);
return -EBUSY;
}
@@ -1782,7 +1782,7 @@ static void unset_regulator_supplies(struct regulator_dev *rdev)
list_for_each_entry_safe(node, n, ®ulator_map_list, list) {
if (rdev == node->regulator) {
list_del(&node->list);
- kfree(node->dev_name);
+ kfree_const(node->dev_name);
kfree(node);
}
}
--
2.39.2
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 5/9] regulator/core: regulator_ena_gpio_ctrl: pull in ena_gpio state handling
2023-08-30 21:38 ` [PATCH 5/9] regulator/core: regulator_ena_gpio_ctrl: pull in ena_gpio state handling Michał Mirosław
@ 2023-08-31 11:13 ` Mark Brown
2023-08-31 12:36 ` Michał Mirosław
0 siblings, 1 reply; 14+ messages in thread
From: Mark Brown @ 2023-08-31 11:13 UTC (permalink / raw)
To: Michał Mirosław; +Cc: Liam Girdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 469 bytes --]
On Wed, Aug 30, 2023 at 11:38:56PM +0200, Michał Mirosław wrote:
> - if (pin->enable_count > 1) {
> - pin->enable_count--;
> - return 0;
> - }
> -
> /* Disable GPIO if not used */
> - if (pin->enable_count <= 1) {
> + if (pin->enable_count-- <= 1) {
The goal isn't to write the minimum number of lines possible - this just
makes the logic harder to follow and for bonus points isn't obviously
related to the chnages described in changelog.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 5/9] regulator/core: regulator_ena_gpio_ctrl: pull in ena_gpio state handling
2023-08-31 11:13 ` Mark Brown
@ 2023-08-31 12:36 ` Michał Mirosław
[not found] ` <1c102d15cb8f20141f0bfd1e42d5ac8a98947154.1693485621.git.mirq-linux@rere.qmqm.pl>
0 siblings, 1 reply; 14+ messages in thread
From: Michał Mirosław @ 2023-08-31 12:36 UTC (permalink / raw)
To: Mark Brown; +Cc: Liam Girdwood, linux-kernel
On Thu, Aug 31, 2023 at 12:13:16PM +0100, Mark Brown wrote:
> On Wed, Aug 30, 2023 at 11:38:56PM +0200, Michał Mirosław wrote:
>
> > - if (pin->enable_count > 1) {
> > - pin->enable_count--;
> > - return 0;
> > - }
> > -
> > /* Disable GPIO if not used */
> > - if (pin->enable_count <= 1) {
> > + if (pin->enable_count-- <= 1) {
>
> The goal isn't to write the minimum number of lines possible - this just
> makes the logic harder to follow and for bonus points isn't obviously
> related to the chnages described in changelog.
I see that I missed this fragment when splitting patches. I'll resend
without this part if the other ones are good to go.
Best Regards
Michał Mirosław
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 5/9 fixed] regulator/core: regulator_ena_gpio_ctrl: pull in ena_gpio state handling
[not found] ` <1c102d15cb8f20141f0bfd1e42d5ac8a98947154.1693485621.git.mirq-linux@rere.qmqm.pl>
@ 2023-08-31 13:32 ` Mark Brown
0 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2023-08-31 13:32 UTC (permalink / raw)
To: Michał Mirosław; +Cc: Liam Girdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 484 bytes --]
On Thu, Aug 31, 2023 at 02:44:28PM +0200, Michał Mirosław wrote:
> Deduplicate `ena_gpio_state` handling by pulling it into
> regulator_ena_gpio_ctrl().
>
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
> This is a fixed version of patch #5 with the extra code change removed.
> I'll resend the series if needed after other patches are reviewed.
Please don't do this, it just makes everything harder to follow. Send
the whole series when resending.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 6/9] regulator/core: remove regulator_init callback
2023-08-30 21:38 ` [PATCH 6/9] regulator/core: remove regulator_init callback Michał Mirosław
@ 2023-09-01 16:09 ` kernel test robot
0 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2023-09-01 16:09 UTC (permalink / raw)
To: Michał Mirosław, Liam Girdwood, Mark Brown
Cc: oe-kbuild-all, linux-kernel
Hi Michał,
kernel test robot noticed the following build errors:
[auto build test ERROR on broonie-regulator/for-next]
[also build test ERROR on linus/master v6.5 next-20230831]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Micha-Miros-aw/regulator-core-_regulator_get-simplify-error-returns/20230831-065946
base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
patch link: https://lore.kernel.org/r/67b78825385762957b121db2c5d71b119517a7ce.1693431144.git.mirq-linux%40rere.qmqm.pl
patch subject: [PATCH 6/9] regulator/core: remove regulator_init callback
config: arc-allmodconfig (https://download.01.org/0day-ci/archive/20230901/202309012355.YuIQ9kqC-lkp@intel.com/config)
compiler: arceb-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230901/202309012355.YuIQ9kqC-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309012355.YuIQ9kqC-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/regulator/core.c: In function 'regulator_register':
>> drivers/regulator/core.c:5609:35: error: 'const struct regulator_init_data' has no member named 'regulator_init'
5609 | if (init_data && init_data->regulator_init) {
| ^~
drivers/regulator/core.c:5610:32: error: 'const struct regulator_init_data' has no member named 'regulator_init'
5610 | ret = init_data->regulator_init(rdev->reg_data);
| ^~
vim +5609 drivers/regulator/core.c
d8ca7d184b33af Dmitry Osipenko 2019-06-24 5446
414c70cb91c445 Liam Girdwood 2008-04-30 5447 /**
414c70cb91c445 Liam Girdwood 2008-04-30 5448 * regulator_register - register regulator
8f3cbcd6b44003 ChiYuan Huang 2022-12-06 5449 * @dev: the device that drive the regulator
69279fb9a95051 Mark Brown 2008-12-31 5450 * @regulator_desc: regulator to register
f47531b1aa86e0 Krzysztof Kozlowski 2015-01-12 5451 * @cfg: runtime configuration for regulator
414c70cb91c445 Liam Girdwood 2008-04-30 5452 *
414c70cb91c445 Liam Girdwood 2008-04-30 5453 * Called by regulator drivers to register a regulator.
0384618a79ccfa Axel Lin 2013-01-03 5454 * Returns a valid pointer to struct regulator_dev on success
0384618a79ccfa Axel Lin 2013-01-03 5455 * or an ERR_PTR() on error.
414c70cb91c445 Liam Girdwood 2008-04-30 5456 */
65f26846b90611 Mark Brown 2012-04-03 5457 struct regulator_dev *
8f3cbcd6b44003 ChiYuan Huang 2022-12-06 5458 regulator_register(struct device *dev,
8f3cbcd6b44003 ChiYuan Huang 2022-12-06 5459 const struct regulator_desc *regulator_desc,
1b3de223385d6b Krzysztof Kozlowski 2015-01-05 5460 const struct regulator_config *cfg)
414c70cb91c445 Liam Girdwood 2008-04-30 5461 {
c172708d38a401 Mark Brown 2012-04-04 5462 const struct regulator_init_data *init_data;
1b3de223385d6b Krzysztof Kozlowski 2015-01-05 5463 struct regulator_config *config = NULL;
72dca06f62c504 Aniroop Mathur 2014-12-28 5464 static atomic_t regulator_no = ATOMIC_INIT(-1);
414c70cb91c445 Liam Girdwood 2008-04-30 5465 struct regulator_dev *rdev;
0edb040d416ab3 Linus Walleij 2018-12-06 5466 bool dangling_cfg_gpiod = false;
0edb040d416ab3 Linus Walleij 2018-12-06 5467 bool dangling_of_gpiod = false;
a5766f11cfd3a0 Liam Girdwood 2008-10-10 5468 int ret, i;
520fb178212d1d Christian Kohlschütter 2022-08-29 5469 bool resolved_early = false;
414c70cb91c445 Liam Girdwood 2008-04-30 5470
0edb040d416ab3 Linus Walleij 2018-12-06 5471 if (cfg == NULL)
414c70cb91c445 Liam Girdwood 2008-04-30 5472 return ERR_PTR(-EINVAL);
0edb040d416ab3 Linus Walleij 2018-12-06 5473 if (cfg->ena_gpiod)
0edb040d416ab3 Linus Walleij 2018-12-06 5474 dangling_cfg_gpiod = true;
0edb040d416ab3 Linus Walleij 2018-12-06 5475 if (regulator_desc == NULL) {
0edb040d416ab3 Linus Walleij 2018-12-06 5476 ret = -EINVAL;
0edb040d416ab3 Linus Walleij 2018-12-06 5477 goto rinse;
0edb040d416ab3 Linus Walleij 2018-12-06 5478 }
414c70cb91c445 Liam Girdwood 2008-04-30 5479
8f3cbcd6b44003 ChiYuan Huang 2022-12-06 5480 WARN_ON(!dev || !cfg->dev);
32c8fad438200b Mark Brown 2012-04-11 5481
0edb040d416ab3 Linus Walleij 2018-12-06 5482 if (regulator_desc->name == NULL || regulator_desc->ops == NULL) {
0edb040d416ab3 Linus Walleij 2018-12-06 5483 ret = -EINVAL;
0edb040d416ab3 Linus Walleij 2018-12-06 5484 goto rinse;
0edb040d416ab3 Linus Walleij 2018-12-06 5485 }
414c70cb91c445 Liam Girdwood 2008-04-30 5486
cd78dfc6c6e321 Diego Liziero 2009-04-14 5487 if (regulator_desc->type != REGULATOR_VOLTAGE &&
0edb040d416ab3 Linus Walleij 2018-12-06 5488 regulator_desc->type != REGULATOR_CURRENT) {
0edb040d416ab3 Linus Walleij 2018-12-06 5489 ret = -EINVAL;
0edb040d416ab3 Linus Walleij 2018-12-06 5490 goto rinse;
0edb040d416ab3 Linus Walleij 2018-12-06 5491 }
414c70cb91c445 Liam Girdwood 2008-04-30 5492
476c2d83c7ffb2 Mark Brown 2010-12-10 5493 /* Only one of each should be implemented */
476c2d83c7ffb2 Mark Brown 2010-12-10 5494 WARN_ON(regulator_desc->ops->get_voltage &&
476c2d83c7ffb2 Mark Brown 2010-12-10 5495 regulator_desc->ops->get_voltage_sel);
e8eef82b2c652d Mark Brown 2010-12-12 5496 WARN_ON(regulator_desc->ops->set_voltage &&
e8eef82b2c652d Mark Brown 2010-12-12 5497 regulator_desc->ops->set_voltage_sel);
476c2d83c7ffb2 Mark Brown 2010-12-10 5498
476c2d83c7ffb2 Mark Brown 2010-12-10 5499 /* If we're using selectors we must implement list_voltage. */
476c2d83c7ffb2 Mark Brown 2010-12-10 5500 if (regulator_desc->ops->get_voltage_sel &&
476c2d83c7ffb2 Mark Brown 2010-12-10 5501 !regulator_desc->ops->list_voltage) {
0edb040d416ab3 Linus Walleij 2018-12-06 5502 ret = -EINVAL;
0edb040d416ab3 Linus Walleij 2018-12-06 5503 goto rinse;
476c2d83c7ffb2 Mark Brown 2010-12-10 5504 }
e8eef82b2c652d Mark Brown 2010-12-12 5505 if (regulator_desc->ops->set_voltage_sel &&
e8eef82b2c652d Mark Brown 2010-12-12 5506 !regulator_desc->ops->list_voltage) {
0edb040d416ab3 Linus Walleij 2018-12-06 5507 ret = -EINVAL;
0edb040d416ab3 Linus Walleij 2018-12-06 5508 goto rinse;
e8eef82b2c652d Mark Brown 2010-12-12 5509 }
476c2d83c7ffb2 Mark Brown 2010-12-10 5510
414c70cb91c445 Liam Girdwood 2008-04-30 5511 rdev = kzalloc(sizeof(struct regulator_dev), GFP_KERNEL);
0edb040d416ab3 Linus Walleij 2018-12-06 5512 if (rdev == NULL) {
0edb040d416ab3 Linus Walleij 2018-12-06 5513 ret = -ENOMEM;
0edb040d416ab3 Linus Walleij 2018-12-06 5514 goto rinse;
0edb040d416ab3 Linus Walleij 2018-12-06 5515 }
d3c731564e09b6 Michał Mirosław 2020-08-12 5516 device_initialize(&rdev->dev);
7111c6d1b31b42 Matti Vaittinen 2021-06-03 5517 spin_lock_init(&rdev->err_lock);
414c70cb91c445 Liam Girdwood 2008-04-30 5518
1b3de223385d6b Krzysztof Kozlowski 2015-01-05 5519 /*
1b3de223385d6b Krzysztof Kozlowski 2015-01-05 5520 * Duplicate the config so the driver could override it after
1b3de223385d6b Krzysztof Kozlowski 2015-01-05 5521 * parsing init data.
1b3de223385d6b Krzysztof Kozlowski 2015-01-05 5522 */
1b3de223385d6b Krzysztof Kozlowski 2015-01-05 5523 config = kmemdup(cfg, sizeof(*cfg), GFP_KERNEL);
1b3de223385d6b Krzysztof Kozlowski 2015-01-05 5524 if (config == NULL) {
0edb040d416ab3 Linus Walleij 2018-12-06 5525 ret = -ENOMEM;
d3c731564e09b6 Michał Mirosław 2020-08-12 5526 goto clean;
1b3de223385d6b Krzysztof Kozlowski 2015-01-05 5527 }
1b3de223385d6b Krzysztof Kozlowski 2015-01-05 5528
bfa21a0dfe6915 Krzysztof Kozlowski 2015-01-05 5529 init_data = regulator_of_get_init_data(dev, regulator_desc, config,
a0c7b164ad115e Mark Brown 2014-09-09 5530 &rdev->dev.of_node);
f8970d341eec73 Marco Felsch 2019-09-17 5531
f8970d341eec73 Marco Felsch 2019-09-17 5532 /*
f8970d341eec73 Marco Felsch 2019-09-17 5533 * Sometimes not all resources are probed already so we need to take
f8970d341eec73 Marco Felsch 2019-09-17 5534 * that into account. This happens most the time if the ena_gpiod comes
f8970d341eec73 Marco Felsch 2019-09-17 5535 * from a gpio extender or something else.
f8970d341eec73 Marco Felsch 2019-09-17 5536 */
f8970d341eec73 Marco Felsch 2019-09-17 5537 if (PTR_ERR(init_data) == -EPROBE_DEFER) {
f8970d341eec73 Marco Felsch 2019-09-17 5538 ret = -EPROBE_DEFER;
d3c731564e09b6 Michał Mirosław 2020-08-12 5539 goto clean;
f8970d341eec73 Marco Felsch 2019-09-17 5540 }
f8970d341eec73 Marco Felsch 2019-09-17 5541
0edb040d416ab3 Linus Walleij 2018-12-06 5542 /*
0edb040d416ab3 Linus Walleij 2018-12-06 5543 * We need to keep track of any GPIO descriptor coming from the
0edb040d416ab3 Linus Walleij 2018-12-06 5544 * device tree until we have handled it over to the core. If the
0edb040d416ab3 Linus Walleij 2018-12-06 5545 * config that was passed in to this function DOES NOT contain
0edb040d416ab3 Linus Walleij 2018-12-06 5546 * a descriptor, and the config after this call DOES contain
48f1b4efd67c92 Krzysztof Kozlowski 2019-01-08 5547 * a descriptor, we definitely got one from parsing the device
0edb040d416ab3 Linus Walleij 2018-12-06 5548 * tree.
0edb040d416ab3 Linus Walleij 2018-12-06 5549 */
0edb040d416ab3 Linus Walleij 2018-12-06 5550 if (!cfg->ena_gpiod && config->ena_gpiod)
0edb040d416ab3 Linus Walleij 2018-12-06 5551 dangling_of_gpiod = true;
a0c7b164ad115e Mark Brown 2014-09-09 5552 if (!init_data) {
a0c7b164ad115e Mark Brown 2014-09-09 5553 init_data = config->init_data;
a0c7b164ad115e Mark Brown 2014-09-09 5554 rdev->dev.of_node = of_node_get(config->of_node);
a0c7b164ad115e Mark Brown 2014-09-09 5555 }
a0c7b164ad115e Mark Brown 2014-09-09 5556
f8702f9e4aa7b4 Dmitry Osipenko 2018-11-19 5557 ww_mutex_init(&rdev->mutex, ®ulator_ww_class);
c172708d38a401 Mark Brown 2012-04-04 5558 rdev->reg_data = config->driver_data;
414c70cb91c445 Liam Girdwood 2008-04-30 5559 rdev->owner = regulator_desc->owner;
414c70cb91c445 Liam Girdwood 2008-04-30 5560 rdev->desc = regulator_desc;
3a4b0a07fa69cb Mark Brown 2012-05-08 5561 if (config->regmap)
65b19ce6c22328 Mark Brown 2012-04-15 5562 rdev->regmap = config->regmap;
52b84dac436a68 AnilKumar Ch 2012-09-07 5563 else if (dev_get_regmap(dev, NULL))
3a4b0a07fa69cb Mark Brown 2012-05-08 5564 rdev->regmap = dev_get_regmap(dev, NULL);
52b84dac436a68 AnilKumar Ch 2012-09-07 5565 else if (dev->parent)
52b84dac436a68 AnilKumar Ch 2012-09-07 5566 rdev->regmap = dev_get_regmap(dev->parent, NULL);
414c70cb91c445 Liam Girdwood 2008-04-30 5567 INIT_LIST_HEAD(&rdev->consumer_list);
414c70cb91c445 Liam Girdwood 2008-04-30 5568 INIT_LIST_HEAD(&rdev->list);
414c70cb91c445 Liam Girdwood 2008-04-30 5569 BLOCKING_INIT_NOTIFIER_HEAD(&rdev->notifier);
da07ecd93b1968 Mark Brown 2011-09-11 5570 INIT_DELAYED_WORK(&rdev->disable_work, regulator_disable_work);
414c70cb91c445 Liam Girdwood 2008-04-30 5571
520fb178212d1d Christian Kohlschütter 2022-08-29 5572 if (init_data && init_data->supply_regulator)
520fb178212d1d Christian Kohlschütter 2022-08-29 5573 rdev->supply_name = init_data->supply_regulator;
520fb178212d1d Christian Kohlschütter 2022-08-29 5574 else if (regulator_desc->supply_name)
520fb178212d1d Christian Kohlschütter 2022-08-29 5575 rdev->supply_name = regulator_desc->supply_name;
daad134d66492a Krzysztof Adamski 2016-02-22 5576
a5766f11cfd3a0 Liam Girdwood 2008-10-10 5577 /* register with sysfs */
a5766f11cfd3a0 Liam Girdwood 2008-10-10 5578 rdev->dev.class = ®ulator_class;
0debed5b117d11 ChiYuan Huang 2022-12-14 5579 rdev->dev.parent = config->dev;
72dca06f62c504 Aniroop Mathur 2014-12-28 5580 dev_set_name(&rdev->dev, "regulator.%lu",
39138818a4f5c6 Aniroop Mathur 2014-12-29 5581 (unsigned long) atomic_inc_return(®ulator_no));
9177514ce34902 Vladimir Zapolskiy 2020-07-24 5582 dev_set_drvdata(&rdev->dev, rdev);
414c70cb91c445 Liam Girdwood 2008-04-30 5583
74f544c1fc0339 Mike Rapoport 2008-11-25 5584 /* set regulator constraints */
9a8f5e07200dd8 Mark Brown 2011-11-29 5585 if (init_data)
57a6ad482af256 Michał Mirosław 2020-11-13 5586 rdev->constraints = kmemdup(&init_data->constraints,
57a6ad482af256 Michał Mirosław 2020-11-13 5587 sizeof(*rdev->constraints),
57a6ad482af256 Michał Mirosław 2020-11-13 5588 GFP_KERNEL);
57a6ad482af256 Michał Mirosław 2020-11-13 5589 else
57a6ad482af256 Michał Mirosław 2020-11-13 5590 rdev->constraints = kzalloc(sizeof(*rdev->constraints),
57a6ad482af256 Michał Mirosław 2020-11-13 5591 GFP_KERNEL);
57a6ad482af256 Michał Mirosław 2020-11-13 5592 if (!rdev->constraints) {
57a6ad482af256 Michał Mirosław 2020-11-13 5593 ret = -ENOMEM;
57a6ad482af256 Michał Mirosław 2020-11-13 5594 goto wash;
57a6ad482af256 Michał Mirosław 2020-11-13 5595 }
9a8f5e07200dd8 Mark Brown 2011-11-29 5596
8a866d527ac044 Christian Kohlschütter 2022-08-18 5597 if ((rdev->supply_name && !rdev->supply) &&
8a866d527ac044 Christian Kohlschütter 2022-08-18 5598 (rdev->constraints->always_on ||
8a866d527ac044 Christian Kohlschütter 2022-08-18 5599 rdev->constraints->boot_on)) {
8a866d527ac044 Christian Kohlschütter 2022-08-18 5600 ret = regulator_resolve_supply(rdev);
8a866d527ac044 Christian Kohlschütter 2022-08-18 5601 if (ret)
8a866d527ac044 Christian Kohlschütter 2022-08-18 5602 rdev_dbg(rdev, "unable to resolve supply early: %pe\n",
8a866d527ac044 Christian Kohlschütter 2022-08-18 5603 ERR_PTR(ret));
520fb178212d1d Christian Kohlschütter 2022-08-29 5604
520fb178212d1d Christian Kohlschütter 2022-08-29 5605 resolved_early = true;
8a866d527ac044 Christian Kohlschütter 2022-08-18 5606 }
8a866d527ac044 Christian Kohlschütter 2022-08-18 5607
8a866d527ac044 Christian Kohlschütter 2022-08-18 5608 /* perform any regulator specific init */
9a8f5e07200dd8 Mark Brown 2011-11-29 @5609 if (init_data && init_data->regulator_init) {
a5766f11cfd3a0 Liam Girdwood 2008-10-10 5610 ret = init_data->regulator_init(rdev->reg_data);
4fca9545d17b99 David Brownell 2008-11-11 5611 if (ret < 0)
520fb178212d1d Christian Kohlschütter 2022-08-29 5612 goto wash;
414c70cb91c445 Liam Girdwood 2008-04-30 5613 }
414c70cb91c445 Liam Girdwood 2008-04-30 5614
541d052d721506 Linus Walleij 2019-01-29 5615 if (config->ena_gpiod) {
daad134d66492a Krzysztof Adamski 2016-02-22 5616 ret = regulator_ena_gpio_request(rdev, config);
daad134d66492a Krzysztof Adamski 2016-02-22 5617 if (ret != 0) {
61aab5ad27d551 Michał Mirosław 2020-09-26 5618 rdev_err(rdev, "Failed to request enable GPIO: %pe\n",
61aab5ad27d551 Michał Mirosław 2020-09-26 5619 ERR_PTR(ret));
520fb178212d1d Christian Kohlschütter 2022-08-29 5620 goto wash;
daad134d66492a Krzysztof Adamski 2016-02-22 5621 }
0edb040d416ab3 Linus Walleij 2018-12-06 5622 /* The regulator core took over the GPIO descriptor */
0edb040d416ab3 Linus Walleij 2018-12-06 5623 dangling_cfg_gpiod = false;
0edb040d416ab3 Linus Walleij 2018-12-06 5624 dangling_of_gpiod = false;
daad134d66492a Krzysztof Adamski 2016-02-22 5625 }
0178f3e28e2166 Mark Brown 2010-04-26 5626
57a6ad482af256 Michał Mirosław 2020-11-13 5627 ret = set_machine_constraints(rdev);
520fb178212d1d Christian Kohlschütter 2022-08-29 5628 if (ret == -EPROBE_DEFER && !resolved_early) {
aea6cb99703e17 Michał Mirosław 2020-09-26 5629 /* Regulator might be in bypass mode and so needs its supply
69b8821e293aa8 Shubhankar Kuranagatti 2021-04-20 5630 * to set the constraints
69b8821e293aa8 Shubhankar Kuranagatti 2021-04-20 5631 */
aea6cb99703e17 Michał Mirosław 2020-09-26 5632 /* FIXME: this currently triggers a chicken-and-egg problem
aea6cb99703e17 Michał Mirosław 2020-09-26 5633 * when creating -SUPPLY symlink in sysfs to a regulator
69b8821e293aa8 Shubhankar Kuranagatti 2021-04-20 5634 * that is just being created
69b8821e293aa8 Shubhankar Kuranagatti 2021-04-20 5635 */
0917c9db23accb Michał Mirosław 2020-11-13 5636 rdev_dbg(rdev, "will resolve supply early: %s\n",
0917c9db23accb Michał Mirosław 2020-11-13 5637 rdev->supply_name);
aea6cb99703e17 Michał Mirosław 2020-09-26 5638 ret = regulator_resolve_supply(rdev);
aea6cb99703e17 Michał Mirosław 2020-09-26 5639 if (!ret)
57a6ad482af256 Michał Mirosław 2020-11-13 5640 ret = set_machine_constraints(rdev);
aea6cb99703e17 Michał Mirosław 2020-09-26 5641 else
aea6cb99703e17 Michał Mirosław 2020-09-26 5642 rdev_dbg(rdev, "unable to resolve supply early: %pe\n",
aea6cb99703e17 Michał Mirosław 2020-09-26 5643 ERR_PTR(ret));
aea6cb99703e17 Michał Mirosław 2020-09-26 5644 }
45389c47526d1e Jon Hunter 2016-04-26 5645 if (ret < 0)
45389c47526d1e Jon Hunter 2016-04-26 5646 goto wash;
45389c47526d1e Jon Hunter 2016-04-26 5647
f9503385b1877a Dmitry Osipenko 2018-10-05 5648 ret = regulator_init_coupling(rdev);
f9503385b1877a Dmitry Osipenko 2018-10-05 5649 if (ret < 0)
d3d64537c33956 Maciej Purski 2018-04-23 5650 goto wash;
d3d64537c33956 Maciej Purski 2018-04-23 5651
a5766f11cfd3a0 Liam Girdwood 2008-10-10 5652 /* add consumers devices */
9a8f5e07200dd8 Mark Brown 2011-11-29 5653 if (init_data) {
a5766f11cfd3a0 Liam Girdwood 2008-10-10 5654 for (i = 0; i < init_data->num_consumer_supplies; i++) {
a5766f11cfd3a0 Liam Girdwood 2008-10-10 5655 ret = set_consumer_device_supply(rdev,
40f9244f4da897 Mark Brown 2009-06-17 5656 init_data->consumer_supplies[i].dev_name,
a5766f11cfd3a0 Liam Girdwood 2008-10-10 5657 init_data->consumer_supplies[i].supply);
23c2f041efa891 Mark Brown 2011-02-24 5658 if (ret < 0) {
23c2f041efa891 Mark Brown 2011-02-24 5659 dev_err(dev, "Failed to set supply %s\n",
23c2f041efa891 Mark Brown 2011-02-24 5660 init_data->consumer_supplies[i].supply);
d4033b54fc9122 Jani Nikula 2010-04-29 5661 goto unset_supplies;
414c70cb91c445 Liam Girdwood 2008-04-30 5662 }
23c2f041efa891 Mark Brown 2011-02-24 5663 }
45389c47526d1e Jon Hunter 2016-04-26 5664 }
5e3ca2b349b1e2 Javier Martinez Canillas 2016-03-23 5665
fd086045559d90 Matthias Kaehlcke 2017-03-27 5666 if (!rdev->desc->ops->get_voltage &&
fd086045559d90 Matthias Kaehlcke 2017-03-27 5667 !rdev->desc->ops->list_voltage &&
fd086045559d90 Matthias Kaehlcke 2017-03-27 5668 !rdev->desc->fixed_uV)
fd086045559d90 Matthias Kaehlcke 2017-03-27 5669 rdev->is_switch = true;
fd086045559d90 Matthias Kaehlcke 2017-03-27 5670
9177514ce34902 Vladimir Zapolskiy 2020-07-24 5671 ret = device_add(&rdev->dev);
9177514ce34902 Vladimir Zapolskiy 2020-07-24 5672 if (ret != 0)
c438b9d017362b Jon Hunter 2016-04-21 5673 goto unset_supplies;
414c70cb91c445 Liam Girdwood 2008-04-30 5674
1130e5b3ff4a7f Mark Brown 2010-12-21 5675 rdev_init_debugfs(rdev);
5e3ca2b349b1e2 Javier Martinez Canillas 2016-03-23 5676
f9503385b1877a Dmitry Osipenko 2018-10-05 5677 /* try to resolve regulators coupling since a new one was registered */
f9503385b1877a Dmitry Osipenko 2018-10-05 5678 mutex_lock(®ulator_list_mutex);
f9503385b1877a Dmitry Osipenko 2018-10-05 5679 regulator_resolve_coupling(rdev);
f9503385b1877a Dmitry Osipenko 2018-10-05 5680 mutex_unlock(®ulator_list_mutex);
f9503385b1877a Dmitry Osipenko 2018-10-05 5681
5e3ca2b349b1e2 Javier Martinez Canillas 2016-03-23 5682 /* try to resolve regulators supply since a new one was registered */
5e3ca2b349b1e2 Javier Martinez Canillas 2016-03-23 5683 class_for_each_device(®ulator_class, NULL, NULL,
5e3ca2b349b1e2 Javier Martinez Canillas 2016-03-23 5684 regulator_register_resolve_supply);
1b3de223385d6b Krzysztof Kozlowski 2015-01-05 5685 kfree(config);
a5766f11cfd3a0 Liam Girdwood 2008-10-10 5686 return rdev;
4fca9545d17b99 David Brownell 2008-11-11 5687
d4033b54fc9122 Jani Nikula 2010-04-29 5688 unset_supplies:
45389c47526d1e Jon Hunter 2016-04-26 5689 mutex_lock(®ulator_list_mutex);
d4033b54fc9122 Jani Nikula 2010-04-29 5690 unset_regulator_supplies(rdev);
d8ca7d184b33af Dmitry Osipenko 2019-06-24 5691 regulator_remove_coupling(rdev);
45389c47526d1e Jon Hunter 2016-04-26 5692 mutex_unlock(®ulator_list_mutex);
32165230eb6e62 Krzysztof Adamski 2016-02-24 5693 wash:
ba62319a42c50e Yang Yingliang 2022-12-02 5694 regulator_put(rdev->supply);
26c2c997aa1a6c Dmitry Osipenko 2019-10-25 5695 kfree(rdev->coupling_desc.coupled_rdevs);
45389c47526d1e Jon Hunter 2016-04-26 5696 mutex_lock(®ulator_list_mutex);
32165230eb6e62 Krzysztof Adamski 2016-02-24 5697 regulator_ena_gpio_free(rdev);
45389c47526d1e Jon Hunter 2016-04-26 5698 mutex_unlock(®ulator_list_mutex);
5f4b204b6b8153 Zeng Heng 2022-11-16 5699 put_device(&rdev->dev);
5f4b204b6b8153 Zeng Heng 2022-11-16 5700 rdev = NULL;
4fca9545d17b99 David Brownell 2008-11-11 5701 clean:
0edb040d416ab3 Linus Walleij 2018-12-06 5702 if (dangling_of_gpiod)
0edb040d416ab3 Linus Walleij 2018-12-06 5703 gpiod_put(config->ena_gpiod);
5f4b204b6b8153 Zeng Heng 2022-11-16 5704 if (rdev && rdev->dev.of_node)
5f4b204b6b8153 Zeng Heng 2022-11-16 5705 of_node_put(rdev->dev.of_node);
5f4b204b6b8153 Zeng Heng 2022-11-16 5706 kfree(rdev);
a2151374230820 Jon Hunter 2016-03-30 5707 kfree(config);
0edb040d416ab3 Linus Walleij 2018-12-06 5708 rinse:
0edb040d416ab3 Linus Walleij 2018-12-06 5709 if (dangling_cfg_gpiod)
0edb040d416ab3 Linus Walleij 2018-12-06 5710 gpiod_put(cfg->ena_gpiod);
a2151374230820 Jon Hunter 2016-03-30 5711 return ERR_PTR(ret);
414c70cb91c445 Liam Girdwood 2008-04-30 5712 }
a5766f11cfd3a0 Liam Girdwood 2008-10-10 5713 EXPORT_SYMBOL_GPL(regulator_register);
414c70cb91c445 Liam Girdwood 2008-04-30 5714
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2023-09-01 16:10 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-30 21:38 [PATCH 0/9] regulator/core: Trivial cleanups and improvements Michał Mirosław
2023-08-30 21:38 ` [PATCH 1/9] regulator/core: _regulator_get: simplify error returns Michał Mirosław
2023-08-30 21:38 ` [PATCH 2/9] regulator/core: set_consumer_device_supply: remove `has_dev` Michał Mirosław
2023-08-30 21:38 ` [PATCH 4/9] regulator/core: regulator_bulk_get: remove redundant NULL stores Michał Mirosław
2023-08-30 21:38 ` [PATCH 3/9] regulator/core: of_get_child_regulator: remove goto Michał Mirosław
2023-08-30 21:38 ` [PATCH 5/9] regulator/core: regulator_ena_gpio_ctrl: pull in ena_gpio state handling Michał Mirosław
2023-08-31 11:13 ` Mark Brown
2023-08-31 12:36 ` Michał Mirosław
[not found] ` <1c102d15cb8f20141f0bfd1e42d5ac8a98947154.1693485621.git.mirq-linux@rere.qmqm.pl>
2023-08-31 13:32 ` [PATCH 5/9 fixed] " Mark Brown
2023-08-30 21:38 ` [PATCH 7/9] regulator/core: remove regulator_get_init_drvdata() Michał Mirosław
2023-08-30 21:38 ` [PATCH 6/9] regulator/core: remove regulator_init callback Michał Mirosław
2023-09-01 16:09 ` kernel test robot
2023-08-30 21:38 ` [PATCH 8/9] regulator/core: set_consumer_device_supply: avoid copying const data Michał Mirosław
2023-08-30 21:38 ` [PATCH 9/9] regulator/core: make regulator_class const Michał Mirosław
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®