The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2 00/12] regulator/core: Trivial cleanups and improvements
@ 2024-04-29 14:45 Michał Mirosław
  2024-04-29 14:45 ` [PATCH v2 01/12] regulator/core: _regulator_get: simplify error returns Michał Mirosław
                   ` (11 more replies)
  0 siblings, 12 replies; 18+ messages in thread
From: Michał Mirosław @ 2024-04-29 14:45 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown; +Cc: linux-kernel

This is a random set of cleanups, dead code removal and minor
optimizations.  This is a v2 of patchset sent long time ago, extended
with a couple more entries (one including a driver cleanup to enable
further changes). Tested on Tegra3 (ARM) and x86 devices.

v2:
 - added regulator_dev.reg_data cleanup patches
 - added a missing hunk in patch 6
 - removed an extra change from patch 5
 (Note: skipping changelogs in the patches, as the update has no relevant
  material changes there)

Michał Mirosław (12):
  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/tps68470: use rdev_get_drvdata()
  regulator/core: use dev_to_rdev() for device -> regulator_dev cast
  regulator/core: remove regulator_get/set_drvdata
  regulator/core: use rdev->dev.driver_data

 drivers/regulator/core.c               | 180 ++++++++-----------------
 drivers/regulator/tps68470-regulator.c |   4 +-
 include/linux/regulator/consumer.h     |  14 --
 include/linux/regulator/driver.h       |   9 +-
 include/linux/regulator/machine.h      |   7 +-
 5 files changed, 62 insertions(+), 152 deletions(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 02/12] regulator/core: set_consumer_device_supply: remove `has_dev`
  2024-04-29 14:45 [PATCH v2 00/12] regulator/core: Trivial cleanups and improvements Michał Mirosław
  2024-04-29 14:45 ` [PATCH v2 01/12] regulator/core: _regulator_get: simplify error returns Michał Mirosław
@ 2024-04-29 14:45 ` Michał Mirosław
  2024-04-29 14:45 ` [PATCH v2 04/12] regulator/core: regulator_bulk_get: remove redundant NULL stores Michał Mirosław
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Michał Mirosław @ 2024-04-29 14:45 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 62dd3ac19e6d..5db3bf08145c 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1738,16 +1738,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;
@@ -1755,7 +1749,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 related	[flat|nested] 18+ messages in thread

* [PATCH v2 01/12] regulator/core: _regulator_get: simplify error returns
  2024-04-29 14:45 [PATCH v2 00/12] regulator/core: Trivial cleanups and improvements Michał Mirosław
@ 2024-04-29 14:45 ` Michał Mirosław
  2024-04-29 14:45 ` [PATCH v2 02/12] regulator/core: set_consumer_device_supply: remove `has_dev` Michał Mirosław
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Michał Mirosław @ 2024-04-29 14:45 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 dabac9772741..62dd3ac19e6d 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2222,15 +2222,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(&regulator_list_mutex);
@@ -2238,32 +2236,28 @@ struct regulator *_regulator_get(struct device *dev, const char *id,
 	mutex_unlock(&regulator_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 related	[flat|nested] 18+ messages in thread

* [PATCH v2 04/12] regulator/core: regulator_bulk_get: remove redundant NULL stores
  2024-04-29 14:45 [PATCH v2 00/12] regulator/core: Trivial cleanups and improvements Michał Mirosław
  2024-04-29 14:45 ` [PATCH v2 01/12] regulator/core: _regulator_get: simplify error returns Michał Mirosław
  2024-04-29 14:45 ` [PATCH v2 02/12] regulator/core: set_consumer_device_supply: remove `has_dev` Michał Mirosław
@ 2024-04-29 14:45 ` Michał Mirosław
  2024-04-29 16:01   ` Mark Brown
  2024-04-29 14:45 ` [PATCH v2 03/12] regulator/core: of_get_child_regulator: remove goto Michał Mirosław
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 18+ messages in thread
From: Michał Mirosław @ 2024-04-29 14:45 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 3d7147fabbed..a1573a7ff2b2 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -4872,11 +4872,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,
@@ -4885,7 +4881,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 related	[flat|nested] 18+ messages in thread

* [PATCH v2 03/12] regulator/core: of_get_child_regulator: remove goto
  2024-04-29 14:45 [PATCH v2 00/12] regulator/core: Trivial cleanups and improvements Michał Mirosław
                   ` (2 preceding siblings ...)
  2024-04-29 14:45 ` [PATCH v2 04/12] regulator/core: regulator_bulk_get: remove redundant NULL stores Michał Mirosław
@ 2024-04-29 14:45 ` Michał Mirosław
  2024-04-29 14:45 ` [PATCH v2 06/12] regulator/core: remove regulator_init callback Michał Mirosław
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Michał Mirosław @ 2024-04-29 14:45 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 5db3bf08145c..3d7147fabbed 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -438,18 +438,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 related	[flat|nested] 18+ messages in thread

* [PATCH v2 06/12] regulator/core: remove regulator_init callback
  2024-04-29 14:45 [PATCH v2 00/12] regulator/core: Trivial cleanups and improvements Michał Mirosław
                   ` (3 preceding siblings ...)
  2024-04-29 14:45 ` [PATCH v2 03/12] regulator/core: of_get_child_regulator: remove goto Michał Mirosław
@ 2024-04-29 14:45 ` Michał Mirosław
  2024-04-29 14:45 ` [PATCH v2 05/12] regulator/core: regulator_ena_gpio_ctrl: pull in ena_gpio state handling Michał Mirosław
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Michał Mirosław @ 2024-04-29 14:45 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
8c44e448583c ("regulator: stpmic1: Simplify regulators registration").

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/regulator/core.c          | 7 -------
 include/linux/regulator/machine.h | 7 ++-----
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 4cb30e49c03d..be45983e1d23 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -5679,13 +5679,6 @@ regulator_register(struct device *dev,
 		resolved_early = true;
 	}
 
-	/* perform any regulator specific init */
-	if (init_data && init_data->regulator_init) {
-		ret = init_data->regulator_init(rdev->reg_data);
-		if (ret < 0)
-			goto wash;
-	}
-
 	if (config->ena_gpiod) {
 		ret = regulator_ena_gpio_request(rdev, config);
 		if (ret != 0) {
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index 0cd76d264727..7c39dbc33290 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -274,8 +274,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 */
@@ -285,9 +284,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 related	[flat|nested] 18+ messages in thread

* [PATCH v2 05/12] regulator/core: regulator_ena_gpio_ctrl: pull in ena_gpio state handling
  2024-04-29 14:45 [PATCH v2 00/12] regulator/core: Trivial cleanups and improvements Michał Mirosław
                   ` (4 preceding siblings ...)
  2024-04-29 14:45 ` [PATCH v2 06/12] regulator/core: remove regulator_init callback Michał Mirosław
@ 2024-04-29 14:45 ` Michał Mirosław
  2024-04-29 14:45 ` [PATCH v2 08/12] regulator/core: set_consumer_device_supply: avoid copying const data Michał Mirosław
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Michał Mirosław @ 2024-04-29 14:45 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 | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index a1573a7ff2b2..4cb30e49c03d 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2625,6 +2625,10 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable)
 	if (!pin)
 		return -EINVAL;
 
+	if (rdev->ena_gpio_state == enable)
+		return 0;
+	rdev->ena_gpio_state = enable;
+
 	if (enable) {
 		/* Enable GPIO at initial use */
 		if (pin->enable_count == 0)
@@ -2744,12 +2748,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)
@@ -2963,13 +2964,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 related	[flat|nested] 18+ messages in thread

* [PATCH v2 07/12] regulator/core: remove regulator_get_init_drvdata()
  2024-04-29 14:45 [PATCH v2 00/12] regulator/core: Trivial cleanups and improvements Michał Mirosław
                   ` (6 preceding siblings ...)
  2024-04-29 14:45 ` [PATCH v2 08/12] regulator/core: set_consumer_device_supply: avoid copying const data Michał Mirosław
@ 2024-04-29 14:45 ` Michał Mirosław
  2024-04-29 14:45 ` [PATCH v2 09/12] regulator/tps68470: use rdev_get_drvdata() Michał Mirosław
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Michał Mirosław @ 2024-04-29 14:45 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 be45983e1d23..efb68a5c85af 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -5955,12 +5955,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 22a07c0900a4..c1334601cf02 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -753,7 +753,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 related	[flat|nested] 18+ messages in thread

* [PATCH v2 08/12] regulator/core: set_consumer_device_supply: avoid copying const data
  2024-04-29 14:45 [PATCH v2 00/12] regulator/core: Trivial cleanups and improvements Michał Mirosław
                   ` (5 preceding siblings ...)
  2024-04-29 14:45 ` [PATCH v2 05/12] regulator/core: regulator_ena_gpio_ctrl: pull in ena_gpio state handling Michał Mirosław
@ 2024-04-29 14:45 ` Michał Mirosław
  2024-04-29 14:45 ` [PATCH v2 07/12] regulator/core: remove regulator_get_init_drvdata() Michał Mirosław
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Michał Mirosław @ 2024-04-29 14:45 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 efb68a5c85af..431e1c164b11 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1747,7 +1747,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;
@@ -1782,7 +1782,7 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
 
 fail:
 	mutex_unlock(&regulator_list_mutex);
-	kfree(new_node->dev_name);
+	kfree_const(new_node->dev_name);
 	kfree(new_node);
 	return -EBUSY;
 }
@@ -1794,7 +1794,7 @@ static void unset_regulator_supplies(struct regulator_dev *rdev)
 	list_for_each_entry_safe(node, n, &regulator_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 related	[flat|nested] 18+ messages in thread

* [PATCH v2 09/12] regulator/tps68470: use rdev_get_drvdata()
  2024-04-29 14:45 [PATCH v2 00/12] regulator/core: Trivial cleanups and improvements Michał Mirosław
                   ` (7 preceding siblings ...)
  2024-04-29 14:45 ` [PATCH v2 07/12] regulator/core: remove regulator_get_init_drvdata() Michał Mirosław
@ 2024-04-29 14:45 ` Michał Mirosław
  2024-04-29 14:45 ` [PATCH v2 10/12] regulator/core: use dev_to_rdev() for device -> regulator_dev cast Michał Mirosław
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Michał Mirosław @ 2024-04-29 14:45 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown; +Cc: linux-kernel

Replace uses of rdev->reg_data with the official wrapper.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/regulator/tps68470-regulator.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/tps68470-regulator.c b/drivers/regulator/tps68470-regulator.c
index de7db7690f6b..326a3b942488 100644
--- a/drivers/regulator/tps68470-regulator.c
+++ b/drivers/regulator/tps68470-regulator.c
@@ -56,7 +56,7 @@ static const struct linear_range tps68470_core_ranges[] = {
 
 static int tps68470_regulator_enable(struct regulator_dev *rdev)
 {
-	struct tps68470_regulator_data *data = rdev->reg_data;
+	struct tps68470_regulator_data *data = rdev_get_drvdata(rdev);
 	int ret;
 
 	/* The Core buck regulator needs the PMIC's PLL to be enabled */
@@ -73,7 +73,7 @@ static int tps68470_regulator_enable(struct regulator_dev *rdev)
 
 static int tps68470_regulator_disable(struct regulator_dev *rdev)
 {
-	struct tps68470_regulator_data *data = rdev->reg_data;
+	struct tps68470_regulator_data *data = rdev_get_drvdata(rdev);
 
 	if (rdev->desc->id == TPS68470_CORE)
 		clk_disable_unprepare(data->clk);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 11/12] regulator/core: remove regulator_get/set_drvdata
  2024-04-29 14:45 [PATCH v2 00/12] regulator/core: Trivial cleanups and improvements Michał Mirosław
                   ` (9 preceding siblings ...)
  2024-04-29 14:45 ` [PATCH v2 10/12] regulator/core: use dev_to_rdev() for device -> regulator_dev cast Michał Mirosław
@ 2024-04-29 14:45 ` Michał Mirosław
  2024-04-29 14:45 ` [PATCH v2 12/12] regulator/core: use rdev->dev.driver_data Michał Mirosław
  11 siblings, 0 replies; 18+ messages in thread
From: Michał Mirosław @ 2024-04-29 14:45 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown; +Cc: linux-kernel

There are no users of accessing regulator driver data via `struct
regulator` and there shouldn't be any as the struct is representing
a power consumer not the regulator itself.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/regulator/core.c           | 24 ------------------------
 include/linux/regulator/consumer.h | 14 --------------
 2 files changed, 38 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index d7192530d3e0..010f4db2ce60 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -5908,30 +5908,6 @@ void *rdev_get_drvdata(struct regulator_dev *rdev)
 }
 EXPORT_SYMBOL_GPL(rdev_get_drvdata);
 
-/**
- * regulator_get_drvdata - get regulator driver data
- * @regulator: regulator
- *
- * Get regulator driver private data. This call can be used in the consumer
- * driver context when non API regulator specific functions need to be called.
- */
-void *regulator_get_drvdata(struct regulator *regulator)
-{
-	return regulator->rdev->reg_data;
-}
-EXPORT_SYMBOL_GPL(regulator_get_drvdata);
-
-/**
- * regulator_set_drvdata - set regulator driver data
- * @regulator: regulator
- * @data: data
- */
-void regulator_set_drvdata(struct regulator *regulator, void *data)
-{
-	regulator->rdev->reg_data = data;
-}
-EXPORT_SYMBOL_GPL(regulator_set_drvdata);
-
 /**
  * rdev_get_id - get regulator ID
  * @rdev: regulator
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index 4660582a3302..ee84adba390a 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -268,10 +268,6 @@ int regulator_suspend_disable(struct regulator_dev *rdev,
 int regulator_set_suspend_voltage(struct regulator *regulator, int min_uV,
 				  int max_uV, suspend_state_t state);
 
-/* driver data - core doesn't touch */
-void *regulator_get_drvdata(struct regulator *regulator);
-void regulator_set_drvdata(struct regulator *regulator, void *data);
-
 /* misc helpers */
 
 void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers,
@@ -607,16 +603,6 @@ static inline int regulator_set_suspend_voltage(struct regulator *regulator,
 	return -EINVAL;
 }
 
-static inline void *regulator_get_drvdata(struct regulator *regulator)
-{
-	return NULL;
-}
-
-static inline void regulator_set_drvdata(struct regulator *regulator,
-	void *data)
-{
-}
-
 static inline int regulator_count_voltages(struct regulator *regulator)
 {
 	return 0;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 10/12] regulator/core: use dev_to_rdev() for device -> regulator_dev cast
  2024-04-29 14:45 [PATCH v2 00/12] regulator/core: Trivial cleanups and improvements Michał Mirosław
                   ` (8 preceding siblings ...)
  2024-04-29 14:45 ` [PATCH v2 09/12] regulator/tps68470: use rdev_get_drvdata() Michał Mirosław
@ 2024-04-29 14:45 ` Michał Mirosław
  2024-04-29 14:45 ` [PATCH v2 11/12] regulator/core: remove regulator_get/set_drvdata Michał Mirosław
  2024-04-29 14:45 ` [PATCH v2 12/12] regulator/core: use rdev->dev.driver_data Michał Mirosław
  11 siblings, 0 replies; 18+ messages in thread
From: Michał Mirosław @ 2024-04-29 14:45 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown; +Cc: linux-kernel

There is 1:1 relationship between regulator_dev and device (rdev->dev)
structures.  Since we already have dev_to_rdev() to follow from
&rdev->dev to the rdev, use it instead of dereferencing a pointer.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/regulator/core.c | 51 ++++++++++++++++++++--------------------
 1 file changed, 25 insertions(+), 26 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 431e1c164b11..d7192530d3e0 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -650,7 +650,7 @@ regulator_get_suspend_state_check(struct regulator_dev *rdev, suspend_state_t st
 static ssize_t microvolts_show(struct device *dev,
 			       struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 	int uV;
 
 	regulator_lock(rdev);
@@ -666,7 +666,7 @@ static DEVICE_ATTR_RO(microvolts);
 static ssize_t microamps_show(struct device *dev,
 			      struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 
 	return sprintf(buf, "%d\n", _regulator_get_current_limit(rdev));
 }
@@ -675,7 +675,7 @@ static DEVICE_ATTR_RO(microamps);
 static ssize_t name_show(struct device *dev, struct device_attribute *attr,
 			 char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 
 	return sprintf(buf, "%s\n", rdev_get_name(rdev));
 }
@@ -704,7 +704,7 @@ static ssize_t regulator_print_opmode(char *buf, int mode)
 static ssize_t opmode_show(struct device *dev,
 			   struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 
 	return regulator_print_opmode(buf, _regulator_get_mode(rdev));
 }
@@ -723,7 +723,7 @@ static ssize_t regulator_print_state(char *buf, int state)
 static ssize_t state_show(struct device *dev,
 			  struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 	ssize_t ret;
 
 	regulator_lock(rdev);
@@ -737,7 +737,7 @@ static DEVICE_ATTR_RO(state);
 static ssize_t status_show(struct device *dev,
 			   struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 	int status;
 	char *label;
 
@@ -784,7 +784,7 @@ static DEVICE_ATTR_RO(status);
 static ssize_t min_microamps_show(struct device *dev,
 				  struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 
 	if (!rdev->constraints)
 		return sprintf(buf, "constraint not defined\n");
@@ -796,7 +796,7 @@ static DEVICE_ATTR_RO(min_microamps);
 static ssize_t max_microamps_show(struct device *dev,
 				  struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 
 	if (!rdev->constraints)
 		return sprintf(buf, "constraint not defined\n");
@@ -808,7 +808,7 @@ static DEVICE_ATTR_RO(max_microamps);
 static ssize_t min_microvolts_show(struct device *dev,
 				   struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 
 	if (!rdev->constraints)
 		return sprintf(buf, "constraint not defined\n");
@@ -820,7 +820,7 @@ static DEVICE_ATTR_RO(min_microvolts);
 static ssize_t max_microvolts_show(struct device *dev,
 				   struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 
 	if (!rdev->constraints)
 		return sprintf(buf, "constraint not defined\n");
@@ -832,7 +832,7 @@ static DEVICE_ATTR_RO(max_microvolts);
 static ssize_t requested_microamps_show(struct device *dev,
 					struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 	struct regulator *regulator;
 	int uA = 0;
 
@@ -849,7 +849,7 @@ static DEVICE_ATTR_RO(requested_microamps);
 static ssize_t num_users_show(struct device *dev, struct device_attribute *attr,
 			      char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 	return sprintf(buf, "%d\n", rdev->use_count);
 }
 static DEVICE_ATTR_RO(num_users);
@@ -857,7 +857,7 @@ static DEVICE_ATTR_RO(num_users);
 static ssize_t type_show(struct device *dev, struct device_attribute *attr,
 			 char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 
 	switch (rdev->desc->type) {
 	case REGULATOR_VOLTAGE:
@@ -872,7 +872,7 @@ static DEVICE_ATTR_RO(type);
 static ssize_t suspend_mem_microvolts_show(struct device *dev,
 					   struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 
 	return sprintf(buf, "%d\n", rdev->constraints->state_mem.uV);
 }
@@ -881,7 +881,7 @@ static DEVICE_ATTR_RO(suspend_mem_microvolts);
 static ssize_t suspend_disk_microvolts_show(struct device *dev,
 					    struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 
 	return sprintf(buf, "%d\n", rdev->constraints->state_disk.uV);
 }
@@ -890,7 +890,7 @@ static DEVICE_ATTR_RO(suspend_disk_microvolts);
 static ssize_t suspend_standby_microvolts_show(struct device *dev,
 					       struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 
 	return sprintf(buf, "%d\n", rdev->constraints->state_standby.uV);
 }
@@ -899,7 +899,7 @@ static DEVICE_ATTR_RO(suspend_standby_microvolts);
 static ssize_t suspend_mem_mode_show(struct device *dev,
 				     struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 
 	return regulator_print_opmode(buf,
 		rdev->constraints->state_mem.mode);
@@ -909,7 +909,7 @@ static DEVICE_ATTR_RO(suspend_mem_mode);
 static ssize_t suspend_disk_mode_show(struct device *dev,
 				      struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 
 	return regulator_print_opmode(buf,
 		rdev->constraints->state_disk.mode);
@@ -919,7 +919,7 @@ static DEVICE_ATTR_RO(suspend_disk_mode);
 static ssize_t suspend_standby_mode_show(struct device *dev,
 					 struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 
 	return regulator_print_opmode(buf,
 		rdev->constraints->state_standby.mode);
@@ -929,7 +929,7 @@ static DEVICE_ATTR_RO(suspend_standby_mode);
 static ssize_t suspend_mem_state_show(struct device *dev,
 				      struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 
 	return regulator_print_state(buf,
 			rdev->constraints->state_mem.enabled);
@@ -939,7 +939,7 @@ static DEVICE_ATTR_RO(suspend_mem_state);
 static ssize_t suspend_disk_state_show(struct device *dev,
 				       struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 
 	return regulator_print_state(buf,
 			rdev->constraints->state_disk.enabled);
@@ -949,7 +949,7 @@ static DEVICE_ATTR_RO(suspend_disk_state);
 static ssize_t suspend_standby_state_show(struct device *dev,
 					  struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 
 	return regulator_print_state(buf,
 			rdev->constraints->state_standby.enabled);
@@ -959,7 +959,7 @@ static DEVICE_ATTR_RO(suspend_standby_state);
 static ssize_t bypass_show(struct device *dev,
 			   struct device_attribute *attr, char *buf)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 	const char *report;
 	bool bypass;
 	int ret;
@@ -983,7 +983,7 @@ static DEVICE_ATTR_RO(bypass);
 	{										\
 		int ret;								\
 		unsigned int flags;							\
-		struct regulator_dev *rdev = dev_get_drvdata(dev);			\
+		struct regulator_dev *rdev = dev_to_rdev(dev);				\
 		ret = _regulator_get_error_flags(rdev, &flags);				\
 		if (ret)								\
 			return ret;							\
@@ -5278,7 +5278,7 @@ static const struct attribute_group *regulator_dev_groups[] = {
 
 static void regulator_dev_release(struct device *dev)
 {
-	struct regulator_dev *rdev = dev_get_drvdata(dev);
+	struct regulator_dev *rdev = dev_to_rdev(dev);
 
 	debugfs_remove_recursive(rdev->debugfs);
 	kfree(rdev->constraints);
@@ -5588,7 +5588,6 @@ regulator_register(struct device *dev,
 		goto rinse;
 	}
 	device_initialize(&rdev->dev);
-	dev_set_drvdata(&rdev->dev, rdev);
 	rdev->dev.class = &regulator_class;
 	spin_lock_init(&rdev->err_lock);
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 12/12] regulator/core: use rdev->dev.driver_data
  2024-04-29 14:45 [PATCH v2 00/12] regulator/core: Trivial cleanups and improvements Michał Mirosław
                   ` (10 preceding siblings ...)
  2024-04-29 14:45 ` [PATCH v2 11/12] regulator/core: remove regulator_get/set_drvdata Michał Mirosław
@ 2024-04-29 14:45 ` Michał Mirosław
  2024-04-30  2:54   ` kernel test robot
  2024-04-30  4:53   ` kernel test robot
  11 siblings, 2 replies; 18+ messages in thread
From: Michał Mirosław @ 2024-04-29 14:45 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown; +Cc: linux-kernel

Move rdev->reg_data to rdev->dev.driver_data to follow the linux device
model more closely.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/regulator/core.c          | 15 +--------------
 include/linux/regulator/driver.h  |  8 +++++---
 include/linux/regulator/machine.h |  2 +-
 3 files changed, 7 insertions(+), 18 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 010f4db2ce60..ea2a5efd9a4b 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -5630,7 +5630,7 @@ regulator_register(struct device *dev,
 	}
 
 	ww_mutex_init(&rdev->mutex, &regulator_ww_class);
-	rdev->reg_data = config->driver_data;
+	dev_set_drvdata(&rdev->dev, config->driver_data);
 	rdev->owner = regulator_desc->owner;
 	rdev->desc = regulator_desc;
 	if (config->regmap)
@@ -5895,19 +5895,6 @@ void regulator_has_full_constraints(void)
 }
 EXPORT_SYMBOL_GPL(regulator_has_full_constraints);
 
-/**
- * rdev_get_drvdata - get rdev regulator driver data
- * @rdev: regulator
- *
- * Get rdev regulator driver private data. This call can be used in the
- * regulator driver context.
- */
-void *rdev_get_drvdata(struct regulator_dev *rdev)
-{
-	return rdev->reg_data;
-}
-EXPORT_SYMBOL_GPL(rdev_get_drvdata);
-
 /**
  * rdev_get_id - get regulator ID
  * @rdev: regulator
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index c1334601cf02..680c23b13249 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -632,8 +632,6 @@ struct regulator_dev {
 
 	struct delayed_work disable_work;
 
-	void *reg_data;		/* regulator_dev data */
-
 	struct dentry *debugfs;
 
 	struct regulator_enable_gpio *ena_pin;
@@ -707,7 +705,11 @@ void regulator_irq_helper_cancel(void **handle);
 int regulator_irq_map_event_simple(int irq, struct regulator_irq_data *rid,
 				   unsigned long *dev_mask);
 
-void *rdev_get_drvdata(struct regulator_dev *rdev);
+static inline void *rdev_get_drvdata(const struct regulator_dev *rdev)
+{
+	return dev_get_drvdata(&rdev->dev);
+}
+
 struct device *rdev_get_dev(struct regulator_dev *rdev);
 struct regmap *rdev_get_regmap(struct regulator_dev *rdev);
 int rdev_get_id(struct regulator_dev *rdev);
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index 7c39dbc33290..378f051d4e70 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -274,7 +274,7 @@ struct regulator_consumer_supply {
  * @num_consumer_supplies: Number of consumer device supplies.
  * @consumer_supplies: Consumer device supply configuration.
  *
- * @driver_data: Pointer copied to regulator_dev.reg_data.
+ * @driver_data: Pointer copied to regulator_dev's drvdata.
  */
 struct regulator_init_data {
 	const char *supply_regulator;        /* or NULL for system supply */
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 04/12] regulator/core: regulator_bulk_get: remove redundant NULL stores
  2024-04-29 14:45 ` [PATCH v2 04/12] regulator/core: regulator_bulk_get: remove redundant NULL stores Michał Mirosław
@ 2024-04-29 16:01   ` Mark Brown
  2024-05-01 10:55     ` Michał Mirosław
  0 siblings, 1 reply; 18+ messages in thread
From: Mark Brown @ 2024-04-29 16:01 UTC (permalink / raw)
  To: Michał Mirosław; +Cc: Liam Girdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 354 bytes --]

On Mon, Apr 29, 2024 at 04:45:28PM +0200, Michał Mirosław wrote:
> 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.

This doesn't seem good from a robustness point of view and should be
nowhere near a fast path.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 12/12] regulator/core: use rdev->dev.driver_data
  2024-04-29 14:45 ` [PATCH v2 12/12] regulator/core: use rdev->dev.driver_data Michał Mirosław
@ 2024-04-30  2:54   ` kernel test robot
  2024-04-30  4:53   ` kernel test robot
  1 sibling, 0 replies; 18+ messages in thread
From: kernel test robot @ 2024-04-30  2:54 UTC (permalink / raw)
  To: Michał Mirosław, Liam Girdwood, Mark Brown
  Cc: llvm, 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.9-rc6 next-20240429]
[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/20240429-225643
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
patch link:    https://lore.kernel.org/r/0a480abe4913f0169f9693f6f959fbe1a397ae93.1714399603.git.mirq-linux%40rere.qmqm.pl
patch subject: [PATCH v2 12/12] regulator/core: use rdev->dev.driver_data
config: arm-randconfig-001-20240430 (https://download.01.org/0day-ci/archive/20240430/202404301020.eKVj3WAI-lkp@intel.com/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 37ae4ad0eef338776c7e2cffb3896153d43dcd90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240430/202404301020.eKVj3WAI-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/202404301020.eKVj3WAI-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from drivers/pinctrl/renesas/pfc-sh73a0.c:12:
   In file included from include/linux/regulator/driver.h:18:
   In file included from include/linux/regulator/consumer.h:35:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:21:
   In file included from include/linux/mm.h:2208:
   include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     522 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
>> drivers/pinctrl/renesas/pfc-sh73a0.c:4027:28: error: no member named 'reg_data' in 'struct regulator_dev'
    4027 |         struct sh_pfc *pfc = reg->reg_data;
         |                              ~~~  ^
   drivers/pinctrl/renesas/pfc-sh73a0.c:4060:28: error: no member named 'reg_data' in 'struct regulator_dev'
    4060 |         struct sh_pfc *pfc = reg->reg_data;
         |                              ~~~  ^
   1 warning and 2 errors generated.


vim +4027 drivers/pinctrl/renesas/pfc-sh73a0.c

5d5166dc39bcbe drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2012-12-15  4020  
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4021  /* -----------------------------------------------------------------------------
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4022   * VCCQ MC0 regulator
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4023   */
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4024  
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4025  static void sh73a0_vccq_mc0_endisable(struct regulator_dev *reg, bool enable)
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4026  {
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21 @4027  	struct sh_pfc *pfc = reg->reg_data;
5b46ac3a772363 drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-12-11  4028  	void __iomem *addr = pfc->windows[1].virt + 4;
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4029  	unsigned long flags;
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4030  	u32 value;
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4031  
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4032  	spin_lock_irqsave(&pfc->lock, flags);
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4033  
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4034  	value = ioread32(addr);
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4035  
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4036  	if (enable)
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4037  		value |= BIT(28);
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4038  	else
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4039  		value &= ~BIT(28);
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4040  
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4041  	iowrite32(value, addr);
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4042  
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4043  	spin_unlock_irqrestore(&pfc->lock, flags);
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4044  }
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4045  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 12/12] regulator/core: use rdev->dev.driver_data
  2024-04-29 14:45 ` [PATCH v2 12/12] regulator/core: use rdev->dev.driver_data Michał Mirosław
  2024-04-30  2:54   ` kernel test robot
@ 2024-04-30  4:53   ` kernel test robot
  2024-05-01 11:11     ` Michał Mirosław
  1 sibling, 1 reply; 18+ messages in thread
From: kernel test robot @ 2024-04-30  4:53 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.9-rc6 next-20240429]
[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/20240429-225643
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
patch link:    https://lore.kernel.org/r/0a480abe4913f0169f9693f6f959fbe1a397ae93.1714399603.git.mirq-linux%40rere.qmqm.pl
patch subject: [PATCH v2 12/12] regulator/core: use rdev->dev.driver_data
config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20240430/202404301218.URkWO6dj-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240430/202404301218.URkWO6dj-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/202404301218.URkWO6dj-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/pinctrl/renesas/pfc-sh73a0.c: In function 'sh73a0_vccq_mc0_endisable':
>> drivers/pinctrl/renesas/pfc-sh73a0.c:4027:33: error: 'struct regulator_dev' has no member named 'reg_data'
    4027 |         struct sh_pfc *pfc = reg->reg_data;
         |                                 ^~
   drivers/pinctrl/renesas/pfc-sh73a0.c: In function 'sh73a0_vccq_mc0_is_enabled':
   drivers/pinctrl/renesas/pfc-sh73a0.c:4060:33: error: 'struct regulator_dev' has no member named 'reg_data'
    4060 |         struct sh_pfc *pfc = reg->reg_data;
         |                                 ^~


vim +4027 drivers/pinctrl/renesas/pfc-sh73a0.c

5d5166dc39bcbe drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2012-12-15  4020  
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4021  /* -----------------------------------------------------------------------------
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4022   * VCCQ MC0 regulator
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4023   */
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4024  
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4025  static void sh73a0_vccq_mc0_endisable(struct regulator_dev *reg, bool enable)
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4026  {
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21 @4027  	struct sh_pfc *pfc = reg->reg_data;
5b46ac3a772363 drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-12-11  4028  	void __iomem *addr = pfc->windows[1].virt + 4;
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4029  	unsigned long flags;
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4030  	u32 value;
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4031  
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4032  	spin_lock_irqsave(&pfc->lock, flags);
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4033  
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4034  	value = ioread32(addr);
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4035  
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4036  	if (enable)
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4037  		value |= BIT(28);
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4038  	else
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4039  		value &= ~BIT(28);
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4040  
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4041  	iowrite32(value, addr);
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4042  
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4043  	spin_unlock_irqrestore(&pfc->lock, flags);
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4044  }
ea770ad2ec054e drivers/pinctrl/sh-pfc/pfc-sh73a0.c Laurent Pinchart 2013-04-21  4045  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 04/12] regulator/core: regulator_bulk_get: remove redundant NULL stores
  2024-04-29 16:01   ` Mark Brown
@ 2024-05-01 10:55     ` Michał Mirosław
  0 siblings, 0 replies; 18+ messages in thread
From: Michał Mirosław @ 2024-05-01 10:55 UTC (permalink / raw)
  To: Mark Brown; +Cc: Liam Girdwood, linux-kernel

On Tue, Apr 30, 2024 at 01:01:28AM +0900, Mark Brown wrote:
> On Mon, Apr 29, 2024 at 04:45:28PM +0200, Michał Mirosław wrote:
> > 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.
> 
> This doesn't seem good from a robustness point of view and should be
> nowhere near a fast path.

I take it you'd prefer to have the function fixed to clear the other
pointers? I'll do that in the v3 then.

Best Regards
Michał Mirosław

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 12/12] regulator/core: use rdev->dev.driver_data
  2024-04-30  4:53   ` kernel test robot
@ 2024-05-01 11:11     ` Michał Mirosław
  0 siblings, 0 replies; 18+ messages in thread
From: Michał Mirosław @ 2024-05-01 11:11 UTC (permalink / raw)
  To: kernel test robot; +Cc: Liam Girdwood, Mark Brown, oe-kbuild-all, linux-kernel

On Tue, Apr 30, 2024 at 12:53:02PM +0800, kernel test robot wrote:
> Hi Michał,
> 
> kernel test robot noticed the following build errors:
[...]
>    drivers/pinctrl/renesas/pfc-sh73a0.c: In function 'sh73a0_vccq_mc0_endisable':
> >> drivers/pinctrl/renesas/pfc-sh73a0.c:4027:33: error: 'struct regulator_dev' has no member named 'reg_data'
>     4027 |         struct sh_pfc *pfc = reg->reg_data;
>          |                                 ^~
>    drivers/pinctrl/renesas/pfc-sh73a0.c: In function 'sh73a0_vccq_mc0_is_enabled':
>    drivers/pinctrl/renesas/pfc-sh73a0.c:4060:33: error: 'struct regulator_dev' has no member named 'reg_data'
>     4060 |         struct sh_pfc *pfc = reg->reg_data;
>          |                                 ^~

A patch for the driver coming in v3.

Best Regards
Michał Mirosław

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2024-05-01 11:11 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-29 14:45 [PATCH v2 00/12] regulator/core: Trivial cleanups and improvements Michał Mirosław
2024-04-29 14:45 ` [PATCH v2 01/12] regulator/core: _regulator_get: simplify error returns Michał Mirosław
2024-04-29 14:45 ` [PATCH v2 02/12] regulator/core: set_consumer_device_supply: remove `has_dev` Michał Mirosław
2024-04-29 14:45 ` [PATCH v2 04/12] regulator/core: regulator_bulk_get: remove redundant NULL stores Michał Mirosław
2024-04-29 16:01   ` Mark Brown
2024-05-01 10:55     ` Michał Mirosław
2024-04-29 14:45 ` [PATCH v2 03/12] regulator/core: of_get_child_regulator: remove goto Michał Mirosław
2024-04-29 14:45 ` [PATCH v2 06/12] regulator/core: remove regulator_init callback Michał Mirosław
2024-04-29 14:45 ` [PATCH v2 05/12] regulator/core: regulator_ena_gpio_ctrl: pull in ena_gpio state handling Michał Mirosław
2024-04-29 14:45 ` [PATCH v2 08/12] regulator/core: set_consumer_device_supply: avoid copying const data Michał Mirosław
2024-04-29 14:45 ` [PATCH v2 07/12] regulator/core: remove regulator_get_init_drvdata() Michał Mirosław
2024-04-29 14:45 ` [PATCH v2 09/12] regulator/tps68470: use rdev_get_drvdata() Michał Mirosław
2024-04-29 14:45 ` [PATCH v2 10/12] regulator/core: use dev_to_rdev() for device -> regulator_dev cast Michał Mirosław
2024-04-29 14:45 ` [PATCH v2 11/12] regulator/core: remove regulator_get/set_drvdata Michał Mirosław
2024-04-29 14:45 ` [PATCH v2 12/12] regulator/core: use rdev->dev.driver_data Michał Mirosław
2024-04-30  2:54   ` kernel test robot
2024-04-30  4:53   ` kernel test robot
2024-05-01 11:11     ` 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