linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] regulator: add and use a helper for setting supply names
@ 2019-08-30  7:17 Bartosz Golaszewski
  2019-08-30  7:17 ` [PATCH 1/4] regulator: provide regulator_bulk_set_supply_names() Bartosz Golaszewski
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Bartosz Golaszewski @ 2019-08-30  7:17 UTC (permalink / raw)
  To: Jens Axboe, Thierry Reding, Jonathan Hunter, JC Kuo,
	Kishon Vijay Abraham I, Liam Girdwood, Mark Brown, Mathias Nyman,
	Greg Kroah-Hartman
  Cc: linux-ide, linux-tegra, linux-kernel, linux-usb, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

There are ~80 users of regulator bulk APIs that set the supply names
in a for loop before using the bulk helpers.

This series proposes to add a helper function for setting supply names
and uses it in a couple tegra drivers. If accepted: a coccinelle script
should be easy to develop that would address this in other drivers.

Bartosz Golaszewski (4):
  regulator: provide regulator_bulk_set_supply_names()
  ahci: tegra: use regulator_bulk_set_supply_names()
  phy: tegra: use regulator_bulk_set_supply_names()
  usb: host: xhci-tegra: use regulator_bulk_set_supply_names()

 drivers/ata/ahci_tegra.c           |  6 +++---
 drivers/phy/tegra/xusb.c           |  6 +++---
 drivers/regulator/helpers.c        | 21 +++++++++++++++++++++
 drivers/usb/host/xhci-tegra.c      |  5 +++--
 include/linux/regulator/consumer.h | 12 ++++++++++++
 5 files changed, 42 insertions(+), 8 deletions(-)

-- 
2.21.0


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

* [PATCH 1/4] regulator: provide regulator_bulk_set_supply_names()
  2019-08-30  7:17 [PATCH 0/4] regulator: add and use a helper for setting supply names Bartosz Golaszewski
@ 2019-08-30  7:17 ` Bartosz Golaszewski
  2019-09-02  5:39   ` kbuild test robot
                     ` (2 more replies)
  2019-08-30  7:17 ` [PATCH 2/4] ahci: tegra: use regulator_bulk_set_supply_names() Bartosz Golaszewski
                   ` (3 subsequent siblings)
  4 siblings, 3 replies; 10+ messages in thread
From: Bartosz Golaszewski @ 2019-08-30  7:17 UTC (permalink / raw)
  To: Jens Axboe, Thierry Reding, Jonathan Hunter, JC Kuo,
	Kishon Vijay Abraham I, Liam Girdwood, Mark Brown, Mathias Nyman,
	Greg Kroah-Hartman
  Cc: linux-ide, linux-tegra, linux-kernel, linux-usb, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

There are many regulator consumers who - before using the regulator
bulk functions - set the supply names in regulator_bulk_data using
a for loop.

Let's provide a simple helper in the consumer API that allows users
to do the same with a single function call.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/regulator/helpers.c        | 21 +++++++++++++++++++++
 include/linux/regulator/consumer.h | 12 ++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c
index 4986cc5064a1..ca3dc3f3bb29 100644
--- a/drivers/regulator/helpers.c
+++ b/drivers/regulator/helpers.c
@@ -860,3 +860,24 @@ int regulator_get_current_limit_regmap(struct regulator_dev *rdev)
 	return -EINVAL;
 }
 EXPORT_SYMBOL_GPL(regulator_get_current_limit_regmap);
+
+/**
+ * regulator_bulk_set_supply_names - initialize the 'supply' fields in an array
+ *                                   of regulator_bulk_data structs
+ *
+ * @consumers: array of regulator_bulk_data entries to initialize
+ * @supply_names: array of supply name strings
+ * @num_supplies: number of supply names to initialize
+ *
+ * Note: the 'consumers' array must be the size of 'num_supplies'.
+ */
+void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers,
+				     const char *const *supply_names,
+				     unsigned int num_supplies)
+{
+	unsigned int i;
+
+	for (i = 0; i < num_supplies; i++)
+		consumers[i].supply = supply_names[i];
+}
+EXPORT_SYMBOL_GPL(regulator_bulk_set_supply_names);
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index 815983419375..6d2181a76987 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -281,6 +281,12 @@ void devm_regulator_unregister_notifier(struct regulator *regulator,
 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,
+				     const char *const *supply_names,
+				     unsigned int num_supplies);
+
 #else
 
 /*
@@ -580,6 +586,12 @@ static inline int regulator_list_voltage(struct regulator *regulator, unsigned s
 	return -EINVAL;
 }
 
+void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers,
+				     const char *const *supply_names,
+				     unsigned int num_supplies)
+{
+}
+
 #endif
 
 static inline int regulator_set_voltage_triplet(struct regulator *regulator,
-- 
2.21.0


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

* [PATCH 2/4] ahci: tegra: use regulator_bulk_set_supply_names()
  2019-08-30  7:17 [PATCH 0/4] regulator: add and use a helper for setting supply names Bartosz Golaszewski
  2019-08-30  7:17 ` [PATCH 1/4] regulator: provide regulator_bulk_set_supply_names() Bartosz Golaszewski
@ 2019-08-30  7:17 ` Bartosz Golaszewski
  2019-08-30  7:17 ` [PATCH 3/4] phy: " Bartosz Golaszewski
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Bartosz Golaszewski @ 2019-08-30  7:17 UTC (permalink / raw)
  To: Jens Axboe, Thierry Reding, Jonathan Hunter, JC Kuo,
	Kishon Vijay Abraham I, Liam Girdwood, Mark Brown, Mathias Nyman,
	Greg Kroah-Hartman
  Cc: linux-ide, linux-tegra, linux-kernel, linux-usb, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Use the new regulator helper instead of a for loop.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/ata/ahci_tegra.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/ata/ahci_tegra.c b/drivers/ata/ahci_tegra.c
index e3163dae5e85..cb55ebc1725b 100644
--- a/drivers/ata/ahci_tegra.c
+++ b/drivers/ata/ahci_tegra.c
@@ -483,7 +483,6 @@ static int tegra_ahci_probe(struct platform_device *pdev)
 	struct tegra_ahci_priv *tegra;
 	struct resource *res;
 	int ret;
-	unsigned int i;
 
 	hpriv = ahci_platform_get_resources(pdev, 0);
 	if (IS_ERR(hpriv))
@@ -543,8 +542,9 @@ static int tegra_ahci_probe(struct platform_device *pdev)
 	if (!tegra->supplies)
 		return -ENOMEM;
 
-	for (i = 0; i < tegra->soc->num_supplies; i++)
-		tegra->supplies[i].supply = tegra->soc->supply_names[i];
+	regulator_bulk_set_supply_names(tegra->supplies,
+					tegra->soc->supply_names,
+					tegra->soc->num_supplies);
 
 	ret = devm_regulator_bulk_get(&pdev->dev,
 				      tegra->soc->num_supplies,
-- 
2.21.0


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

* [PATCH 3/4] phy: tegra: use regulator_bulk_set_supply_names()
  2019-08-30  7:17 [PATCH 0/4] regulator: add and use a helper for setting supply names Bartosz Golaszewski
  2019-08-30  7:17 ` [PATCH 1/4] regulator: provide regulator_bulk_set_supply_names() Bartosz Golaszewski
  2019-08-30  7:17 ` [PATCH 2/4] ahci: tegra: use regulator_bulk_set_supply_names() Bartosz Golaszewski
@ 2019-08-30  7:17 ` Bartosz Golaszewski
  2019-08-30  7:17 ` [PATCH 4/4] usb: host: xhci-tegra: " Bartosz Golaszewski
  2019-08-30  8:15 ` [PATCH 0/4] regulator: add and use a helper for setting supply names Thierry Reding
  4 siblings, 0 replies; 10+ messages in thread
From: Bartosz Golaszewski @ 2019-08-30  7:17 UTC (permalink / raw)
  To: Jens Axboe, Thierry Reding, Jonathan Hunter, JC Kuo,
	Kishon Vijay Abraham I, Liam Girdwood, Mark Brown, Mathias Nyman,
	Greg Kroah-Hartman
  Cc: linux-ide, linux-tegra, linux-kernel, linux-usb, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Use the new regulator helper instead of a for loop.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/phy/tegra/xusb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
index 2ea8497af82a..faf1137d1432 100644
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -862,7 +862,6 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
 	struct tegra_xusb_padctl *padctl;
 	const struct of_device_id *match;
 	struct resource *res;
-	unsigned int i;
 	int err;
 
 	/* for backwards compatibility with old device trees */
@@ -907,8 +906,9 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
 		goto remove;
 	}
 
-	for (i = 0; i < padctl->soc->num_supplies; i++)
-		padctl->supplies[i].supply = padctl->soc->supply_names[i];
+	regulator_bulk_set_supply_names(padctl->supplies,
+					padctl->soc->supply_names,
+					padctl->soc->num_supplies);
 
 	err = devm_regulator_bulk_get(&pdev->dev, padctl->soc->num_supplies,
 				      padctl->supplies);
-- 
2.21.0


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

* [PATCH 4/4] usb: host: xhci-tegra: use regulator_bulk_set_supply_names()
  2019-08-30  7:17 [PATCH 0/4] regulator: add and use a helper for setting supply names Bartosz Golaszewski
                   ` (2 preceding siblings ...)
  2019-08-30  7:17 ` [PATCH 3/4] phy: " Bartosz Golaszewski
@ 2019-08-30  7:17 ` Bartosz Golaszewski
  2019-08-30  8:15 ` [PATCH 0/4] regulator: add and use a helper for setting supply names Thierry Reding
  4 siblings, 0 replies; 10+ messages in thread
From: Bartosz Golaszewski @ 2019-08-30  7:17 UTC (permalink / raw)
  To: Jens Axboe, Thierry Reding, Jonathan Hunter, JC Kuo,
	Kishon Vijay Abraham I, Liam Girdwood, Mark Brown, Mathias Nyman,
	Greg Kroah-Hartman
  Cc: linux-ide, linux-tegra, linux-kernel, linux-usb, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Use the new regulator helper instead of a for loop.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/usb/host/xhci-tegra.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
index dafc65911fc0..9ed573bc89aa 100644
--- a/drivers/usb/host/xhci-tegra.c
+++ b/drivers/usb/host/xhci-tegra.c
@@ -1128,8 +1128,9 @@ static int tegra_xusb_probe(struct platform_device *pdev)
 		goto put_powerdomains;
 	}
 
-	for (i = 0; i < tegra->soc->num_supplies; i++)
-		tegra->supplies[i].supply = tegra->soc->supply_names[i];
+	regulator_bulk_set_supply_names(tegra->supplies,
+					tegra->soc->supply_names,
+					tegra->soc->num_supplies);
 
 	err = devm_regulator_bulk_get(&pdev->dev, tegra->soc->num_supplies,
 				      tegra->supplies);
-- 
2.21.0


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

* Re: [PATCH 0/4] regulator: add and use a helper for setting supply names
  2019-08-30  7:17 [PATCH 0/4] regulator: add and use a helper for setting supply names Bartosz Golaszewski
                   ` (3 preceding siblings ...)
  2019-08-30  7:17 ` [PATCH 4/4] usb: host: xhci-tegra: " Bartosz Golaszewski
@ 2019-08-30  8:15 ` Thierry Reding
  2019-08-30 11:06   ` Bartosz Golaszewski
  4 siblings, 1 reply; 10+ messages in thread
From: Thierry Reding @ 2019-08-30  8:15 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Jens Axboe, Jonathan Hunter, JC Kuo, Kishon Vijay Abraham I,
	Liam Girdwood, Mark Brown, Mathias Nyman, Greg Kroah-Hartman,
	linux-ide, linux-tegra, linux-kernel, linux-usb,
	Bartosz Golaszewski

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

On Fri, Aug 30, 2019 at 09:17:36AM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> There are ~80 users of regulator bulk APIs that set the supply names
> in a for loop before using the bulk helpers.
> 
> This series proposes to add a helper function for setting supply names
> and uses it in a couple tegra drivers. If accepted: a coccinelle script
> should be easy to develop that would address this in other drivers.
> 
> Bartosz Golaszewski (4):
>   regulator: provide regulator_bulk_set_supply_names()
>   ahci: tegra: use regulator_bulk_set_supply_names()
>   phy: tegra: use regulator_bulk_set_supply_names()
>   usb: host: xhci-tegra: use regulator_bulk_set_supply_names()
> 
>  drivers/ata/ahci_tegra.c           |  6 +++---
>  drivers/phy/tegra/xusb.c           |  6 +++---
>  drivers/regulator/helpers.c        | 21 +++++++++++++++++++++
>  drivers/usb/host/xhci-tegra.c      |  5 +++--
>  include/linux/regulator/consumer.h | 12 ++++++++++++
>  5 files changed, 42 insertions(+), 8 deletions(-)

The diffstat here suggests that this isn't really helpful. Even if you
subtract the regulator code that adds the new helper, you actually have
a zero diffstat (and a positive one in one case).

Instead, why don't we take this one step further and roll a bit more of
the boilerplate into the new helper, something along these lines:

	struct regulator_bulk_data *
	devm_regulator_bulk_get_from_names(struct device *dev,
					   const char * const *supply_names,
					   unsigned int num_supplies)
	{
		struct regulator_bulk_data *data;
		unsigned int i;
		int err;

		data = devm_kcalloc(dev, num_supplies, sizeof(*data));
		if (!data)
			return ERR_PTR(-ENOMEM);

		for (i = 0; i < num_supplies; i++)
			data[i].supply = supply_names[i];

		err = devm_regulator_bulk_get(dev, num_supplies, data);
		if (err < 0)
			return ERR_PTR(err);

		return data;
	}

That seems to be still a very common pattern and gets rid of a lot more
boilerplate, so your diffstat will actually start to be negative at some
point.

I suppose one could add a non-managed variant for this as well, but I'm
counting 6 uses of regulator_bulk_get() vs. ~140 uses of the managed
variant, so I'm not sure it's worth it.

Thierry

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

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

* Re: [PATCH 0/4] regulator: add and use a helper for setting supply names
  2019-08-30  8:15 ` [PATCH 0/4] regulator: add and use a helper for setting supply names Thierry Reding
@ 2019-08-30 11:06   ` Bartosz Golaszewski
  0 siblings, 0 replies; 10+ messages in thread
From: Bartosz Golaszewski @ 2019-08-30 11:06 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Jens Axboe, Jonathan Hunter, JC Kuo, Kishon Vijay Abraham I,
	Liam Girdwood, Mark Brown, Mathias Nyman, Greg Kroah-Hartman,
	linux-ide, linux-tegra, Linux Kernel Mailing List, linux-usb,
	Bartosz Golaszewski

pt., 30 sie 2019 o 10:15 Thierry Reding <thierry.reding@gmail.com> napisał(a):
>
> On Fri, Aug 30, 2019 at 09:17:36AM +0200, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> >
> > There are ~80 users of regulator bulk APIs that set the supply names
> > in a for loop before using the bulk helpers.
> >
> > This series proposes to add a helper function for setting supply names
> > and uses it in a couple tegra drivers. If accepted: a coccinelle script
> > should be easy to develop that would address this in other drivers.
> >
> > Bartosz Golaszewski (4):
> >   regulator: provide regulator_bulk_set_supply_names()
> >   ahci: tegra: use regulator_bulk_set_supply_names()
> >   phy: tegra: use regulator_bulk_set_supply_names()
> >   usb: host: xhci-tegra: use regulator_bulk_set_supply_names()
> >
> >  drivers/ata/ahci_tegra.c           |  6 +++---
> >  drivers/phy/tegra/xusb.c           |  6 +++---
> >  drivers/regulator/helpers.c        | 21 +++++++++++++++++++++
> >  drivers/usb/host/xhci-tegra.c      |  5 +++--
> >  include/linux/regulator/consumer.h | 12 ++++++++++++
> >  5 files changed, 42 insertions(+), 8 deletions(-)
>
> The diffstat here suggests that this isn't really helpful. Even if you
> subtract the regulator code that adds the new helper, you actually have
> a zero diffstat (and a positive one in one case).
>

You are right when it comes to LoC stats, but bloat-o-meter says it's
quite useful when it comes to actual code size.

This is what we're adding:

$ ./scripts/bloat-o-meter drivers/regulator/helpers.o.old
drivers/regulator/helpers.o
add/remove: 3/0 grow/shrink: 0/0 up/down: 72/0 (72)
Function                                     old     new   delta
regulator_bulk_set_supply_names                -      32     +32
__kstrtab_regulator_bulk_set_supply_names       -      32     +32
__ksymtab_regulator_bulk_set_supply_names       -       8      +8
Total: Before=4438, After=4510, chg +1.62%

And this is what we're removing just from one driver:

$ ./scripts/bloat-o-meter ./drivers/ata/ahci_tegra.o.old
./drivers/ata/ahci_tegra.o
add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-52 (-52)
Function                                     old     new   delta
tegra_ahci_probe                            1688    1636     -52
Total: Before=3474, After=3422, chg -1.50%

> Instead, why don't we take this one step further and roll a bit more of
> the boilerplate into the new helper, something along these lines:
>
>         struct regulator_bulk_data *
>         devm_regulator_bulk_get_from_names(struct device *dev,
>                                            const char * const *supply_names,
>                                            unsigned int num_supplies)
>         {
>                 struct regulator_bulk_data *data;
>                 unsigned int i;
>                 int err;
>
>                 data = devm_kcalloc(dev, num_supplies, sizeof(*data));
>                 if (!data)
>                         return ERR_PTR(-ENOMEM);
>
>                 for (i = 0; i < num_supplies; i++)
>                         data[i].supply = supply_names[i];
>
>                 err = devm_regulator_bulk_get(dev, num_supplies, data);
>                 if (err < 0)
>                         return ERR_PTR(err);
>
>                 return data;
>         }
>
> That seems to be still a very common pattern and gets rid of a lot more
> boilerplate, so your diffstat will actually start to be negative at some
> point.
>

This looks like a good candidate for the next step, but I'd say this
change is still worth applying.

Bart

> I suppose one could add a non-managed variant for this as well, but I'm
> counting 6 uses of regulator_bulk_get() vs. ~140 uses of the managed
> variant, so I'm not sure it's worth it.
>
> Thierry

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

* Re: [PATCH 1/4] regulator: provide regulator_bulk_set_supply_names()
  2019-08-30  7:17 ` [PATCH 1/4] regulator: provide regulator_bulk_set_supply_names() Bartosz Golaszewski
@ 2019-09-02  5:39   ` kbuild test robot
  2019-09-02  7:46   ` kbuild test robot
  2019-09-02 12:23   ` Applied "regulator: provide regulator_bulk_set_supply_names()" to the regulator tree Mark Brown
  2 siblings, 0 replies; 10+ messages in thread
From: kbuild test robot @ 2019-09-02  5:39 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: kbuild-all, Jens Axboe, Thierry Reding, Jonathan Hunter, JC Kuo,
	Kishon Vijay Abraham I, Liam Girdwood, Mark Brown, Mathias Nyman,
	Greg Kroah-Hartman, linux-ide, linux-tegra, linux-kernel,
	linux-usb, Bartosz Golaszewski

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

Hi Bartosz,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[cannot apply to v5.3-rc6 next-20190830]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Bartosz-Golaszewski/regulator-add-and-use-a-helper-for-setting-supply-names/20190901-140224
config: nds32-allnoconfig (attached as .config)
compiler: nds32le-linux-gcc (GCC) 8.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=8.1.0 make.cross ARCH=nds32 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   nds32le-linux-ld: drivers/of/platform.o: in function `regulator_bulk_set_supply_names':
>> platform.c:(.text+0xe8): multiple definition of `regulator_bulk_set_supply_names'; drivers/usb/phy/of.o:of.c:(.text+0x0): first defined here

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 5184 bytes --]

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

* Re: [PATCH 1/4] regulator: provide regulator_bulk_set_supply_names()
  2019-08-30  7:17 ` [PATCH 1/4] regulator: provide regulator_bulk_set_supply_names() Bartosz Golaszewski
  2019-09-02  5:39   ` kbuild test robot
@ 2019-09-02  7:46   ` kbuild test robot
  2019-09-02 12:23   ` Applied "regulator: provide regulator_bulk_set_supply_names()" to the regulator tree Mark Brown
  2 siblings, 0 replies; 10+ messages in thread
From: kbuild test robot @ 2019-09-02  7:46 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: kbuild-all, Jens Axboe, Thierry Reding, Jonathan Hunter, JC Kuo,
	Kishon Vijay Abraham I, Liam Girdwood, Mark Brown, Mathias Nyman,
	Greg Kroah-Hartman, linux-ide, linux-tegra, linux-kernel,
	linux-usb, Bartosz Golaszewski

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

Hi Bartosz,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[cannot apply to v5.3-rc6 next-20190830]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Bartosz-Golaszewski/regulator-add-and-use-a-helper-for-setting-supply-names/20190901-140224
config: c6x-evmc6678_defconfig (attached as .config)
compiler: c6x-elf-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=c6x 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/of/platform.o: In function `regulator_bulk_set_supply_names':
>> platform.c:(.text+0xc80): multiple definition of `regulator_bulk_set_supply_names'
   drivers/usb/phy/of.o:of.c:(.text+0xa8): first defined here

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 5989 bytes --]

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

* Applied "regulator: provide regulator_bulk_set_supply_names()" to the regulator tree
  2019-08-30  7:17 ` [PATCH 1/4] regulator: provide regulator_bulk_set_supply_names() Bartosz Golaszewski
  2019-09-02  5:39   ` kbuild test robot
  2019-09-02  7:46   ` kbuild test robot
@ 2019-09-02 12:23   ` Mark Brown
  2 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2019-09-02 12:23 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Greg Kroah-Hartman, JC Kuo, Jens Axboe, Jonathan Hunter,
	Kishon Vijay Abraham I, Liam Girdwood, linux-ide, linux-kernel,
	linux-tegra, linux-usb, Mark Brown, Mathias Nyman,
	Thierry Reding

The patch

   regulator: provide regulator_bulk_set_supply_names()

has been applied to the regulator tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-5.4

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From d0087e72710ca7d1b309bf427286da58418ea89e Mon Sep 17 00:00:00 2001
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Date: Fri, 30 Aug 2019 09:17:37 +0200
Subject: [PATCH] regulator: provide regulator_bulk_set_supply_names()

There are many regulator consumers who - before using the regulator
bulk functions - set the supply names in regulator_bulk_data using
a for loop.

Let's provide a simple helper in the consumer API that allows users
to do the same with a single function call.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Link: https://lore.kernel.org/r/20190830071740.4267-2-brgl@bgdev.pl
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/regulator/helpers.c        | 21 +++++++++++++++++++++
 include/linux/regulator/consumer.h | 12 ++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c
index 4986cc5064a1..ca3dc3f3bb29 100644
--- a/drivers/regulator/helpers.c
+++ b/drivers/regulator/helpers.c
@@ -860,3 +860,24 @@ int regulator_get_current_limit_regmap(struct regulator_dev *rdev)
 	return -EINVAL;
 }
 EXPORT_SYMBOL_GPL(regulator_get_current_limit_regmap);
+
+/**
+ * regulator_bulk_set_supply_names - initialize the 'supply' fields in an array
+ *                                   of regulator_bulk_data structs
+ *
+ * @consumers: array of regulator_bulk_data entries to initialize
+ * @supply_names: array of supply name strings
+ * @num_supplies: number of supply names to initialize
+ *
+ * Note: the 'consumers' array must be the size of 'num_supplies'.
+ */
+void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers,
+				     const char *const *supply_names,
+				     unsigned int num_supplies)
+{
+	unsigned int i;
+
+	for (i = 0; i < num_supplies; i++)
+		consumers[i].supply = supply_names[i];
+}
+EXPORT_SYMBOL_GPL(regulator_bulk_set_supply_names);
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index 815983419375..6d2181a76987 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -281,6 +281,12 @@ void devm_regulator_unregister_notifier(struct regulator *regulator,
 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,
+				     const char *const *supply_names,
+				     unsigned int num_supplies);
+
 #else
 
 /*
@@ -580,6 +586,12 @@ static inline int regulator_list_voltage(struct regulator *regulator, unsigned s
 	return -EINVAL;
 }
 
+void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers,
+				     const char *const *supply_names,
+				     unsigned int num_supplies)
+{
+}
+
 #endif
 
 static inline int regulator_set_voltage_triplet(struct regulator *regulator,
-- 
2.20.1


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

end of thread, other threads:[~2019-09-02 12:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-30  7:17 [PATCH 0/4] regulator: add and use a helper for setting supply names Bartosz Golaszewski
2019-08-30  7:17 ` [PATCH 1/4] regulator: provide regulator_bulk_set_supply_names() Bartosz Golaszewski
2019-09-02  5:39   ` kbuild test robot
2019-09-02  7:46   ` kbuild test robot
2019-09-02 12:23   ` Applied "regulator: provide regulator_bulk_set_supply_names()" to the regulator tree Mark Brown
2019-08-30  7:17 ` [PATCH 2/4] ahci: tegra: use regulator_bulk_set_supply_names() Bartosz Golaszewski
2019-08-30  7:17 ` [PATCH 3/4] phy: " Bartosz Golaszewski
2019-08-30  7:17 ` [PATCH 4/4] usb: host: xhci-tegra: " Bartosz Golaszewski
2019-08-30  8:15 ` [PATCH 0/4] regulator: add and use a helper for setting supply names Thierry Reding
2019-08-30 11:06   ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).