Skip to contentSkip to conversation

regulator: switch to using [devm_]fwnode_gpiod_get_index

PATCH In review Dmitry Torokhov 5 participants 22 messages Oct 4, 2019 – Oct 7, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover regulator: switch to using [devm_]fwnode_gpiod_get_index

This series swiches regulator drivers form using [devm_]gpiod_get_from_of_node() that is scheduled to be removed in favor of [devm_]fwnode_gpiod_get_index() that behaves more like standard [devm_]gpiod_get_index() and will potentially handle secondary software nodes in cases we need to augment platform firmware.

This depends on the new code that can be found in ib-fwnode-gpiod-get-index immutable branch of Linus' Walleij tree:

git pull git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git ib-fwnode-gpiod-get-index

I hope that it would be possible to pull in this immutable branch and not wait until after 5.5 merge window.

Thanks!

Dmitry Torokhov (7):
regulator: s5m8767: switch to using devm_fwnode_gpiod_get
regulator: slg51000: switch to using fwnode_gpiod_get_index
regulator: tps65090: switch to using devm_fwnode_gpiod_get
regulator: s2mps11: switch to using devm_fwnode_gpiod_get
regulator: da9211: switch to using devm_fwnode_gpiod_get
regulator: tps65132: switch to using devm_fwnode_gpiod_get()
regulator: max77686: switch to using fwnode_gpiod_get_index

 drivers/regulator/da9211-regulator.c   | 12 ++++++------
 drivers/regulator/max77686-regulator.c |  5 +++--
 drivers/regulator/s2mps11.c            |  7 +++----
 drivers/regulator/s5m8767.c            |  7 +++----
 drivers/regulator/slg51000-regulator.c | 13 +++++--------
 drivers/regulator/tps65090-regulator.c | 26 +++++++++++++++-----------
 drivers/regulator/tps65132-regulator.c | 17 ++++++++++-------
 7 files changed, 45 insertions(+), 42 deletions(-)
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
#1 lore raw

PATCH 1/7 regulator: s5m8767: switch to using devm_fwnode_gpiod_get

devm_gpiod_get_from_of_node() is being retired in favor of devm_fwnode_gpiod_get_index(), that behaves similar to devm_gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes.

Let's switch this driver over.

---

 drivers/regulator/s5m8767.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/regulator/s5m8767.c +3 -4
index 6ca27e9d5ef7..bdc07739e9a2 100644
@@ -567,11 +567,10 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
 			continue;
 		}
 
-		rdata->ext_control_gpiod = devm_gpiod_get_from_of_node(
+		rdata->ext_control_gpiod = devm_fwnode_gpiod_get(
 			&pdev->dev,
-			reg_np,
-			"s5m8767,pmic-ext-control-gpios",
-			0,
+			of_fwnode_handle(reg_np),
+			"s5m8767,pmic-ext-control",
 			GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE,
 			"s5m8767");
 		if (PTR_ERR(rdata->ext_control_gpiod) == -ENOENT)
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
#2 lore raw

Re: [PATCH 1/7] regulator: s5m8767: switch to using devm_fwnode_gpiod_get

I love your patch! Yet something to improve:

Hi Dmitry,

I love your patch! Yet something to improve:

[auto build test ERROR on regulator/for-next]
[cannot apply to v5.4-rc1 next-20191004]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Dmitry-Torokhov/regulator-switch-to-using-devm_-fwnode_gpiod_get_index/20191005-085020
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
config: xtensa-allyesconfig (attached as .config)
compiler: xtensa-linux-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=xtensa

If you fix the issue, kindly add following tag

All error/warnings (new ones prefixed by >>):

drivers/regulator/s5m8767.c: In function 's5m8767_pmic_dt_parse_pdata':

>> drivers/regulator/s5m8767.c:570:30: error: implicit declaration of function 'devm_fwnode_gpiod_get'; did you mean 'devm_gpiod_get'? [-Werror=implicit-function-declaration]
      rdata->ext_control_gpiod = devm_fwnode_gpiod_get(
                                 ^~~~~~~~~~~~~~~~~~~~~
                                 devm_gpiod_get
>> drivers/regulator/s5m8767.c:570:28: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
      rdata->ext_control_gpiod = devm_fwnode_gpiod_get(
                               ^

cc1: some warnings being treated as errors

vim +570 drivers/regulator/s5m8767.c

519
520 static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
521 struct sec_platform_data *pdata)
522 {
523 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
524 struct device_node *pmic_np, *regulators_np, *reg_np;
525 struct sec_regulator_data *rdata;
526 struct sec_opmode_data *rmode;
527 unsigned int i, dvs_voltage_nr = 8, ret;
528
529 pmic_np = iodev->dev->of_node;
530 if (!pmic_np) {
531 dev_err(iodev->dev, "could not find pmic sub-node\n");
532 return -ENODEV;
533 }
534
535 regulators_np = of_get_child_by_name(pmic_np, "regulators");
536 if (!regulators_np) {
537 dev_err(iodev->dev, "could not find regulators sub-node\n");
538 return -EINVAL;
539 }
540
541 /* count the number of regulators to be supported in pmic */
542 pdata->num_regulators = of_get_child_count(regulators_np);
543
544 rdata = devm_kcalloc(&pdev->dev,
545 pdata->num_regulators, sizeof(*rdata),
546 GFP_KERNEL);
547 if (!rdata)
548 return -ENOMEM;
549
550 rmode = devm_kcalloc(&pdev->dev,
551 pdata->num_regulators, sizeof(*rmode),
552 GFP_KERNEL);
553 if (!rmode)
554 return -ENOMEM;
555
556 pdata->regulators = rdata;
557 pdata->opmode = rmode;
558 for_each_child_of_node(regulators_np, reg_np) {
559 for (i = 0; i < ARRAY_SIZE(regulators); i++)
560 if (of_node_name_eq(reg_np, regulators[i].name))
561 break;
562
563 if (i == ARRAY_SIZE(regulators)) {
564 dev_warn(iodev->dev,
565 "don't know how to configure regulator %pOFn\n",
566 reg_np);
567 continue;
568 }
569

 > 570			rdata->ext_control_gpiod = devm_fwnode_gpiod_get(

571 &pdev->dev,
572 of_fwnode_handle(reg_np),
573 "s5m8767,pmic-ext-control",
574 GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE,
575 "s5m8767");
576 if (PTR_ERR(rdata->ext_control_gpiod) == -ENOENT)
577 rdata->ext_control_gpiod = NULL;
578 else if (IS_ERR(rdata->ext_control_gpiod))
579 return PTR_ERR(rdata->ext_control_gpiod);
580
581 rdata->id = i;
582 rdata->initdata = of_get_regulator_init_data(
583 &pdev->dev, reg_np,
584 &regulators[i]);
585 rdata->reg_node = reg_np;
586 rdata++;
587 rmode->id = i;
588 if (of_property_read_u32(reg_np, "op_mode",
589 &rmode->mode)) {
590 dev_warn(iodev->dev,
591 "no op_mode property property at %pOF\n",
592 reg_np);
593
594 rmode->mode = S5M8767_OPMODE_NORMAL_MODE;
595 }
596 rmode++;
597 }
598
599 of_node_put(regulators_np);
600
601 if (of_get_property(pmic_np, "s5m8767,pmic-buck2-uses-gpio-dvs", NULL)) {
602 pdata->buck2_gpiodvs = true;
603
604 if (of_property_read_u32_array(pmic_np,
605 "s5m8767,pmic-buck2-dvs-voltage",
606 pdata->buck2_voltage, dvs_voltage_nr)) {
607 dev_err(iodev->dev, "buck2 voltages not specified\n");
608 return -EINVAL;
609 }
610 }
611
612 if (of_get_property(pmic_np, "s5m8767,pmic-buck3-uses-gpio-dvs", NULL)) {
613 pdata->buck3_gpiodvs = true;
614
615 if (of_property_read_u32_array(pmic_np,
616 "s5m8767,pmic-buck3-dvs-voltage",
617 pdata->buck3_voltage, dvs_voltage_nr)) {
618 dev_err(iodev->dev, "buck3 voltages not specified\n");
619 return -EINVAL;
620 }
621 }
622
623 if (of_get_property(pmic_np, "s5m8767,pmic-buck4-uses-gpio-dvs", NULL)) {
624 pdata->buck4_gpiodvs = true;
625
626 if (of_property_read_u32_array(pmic_np,
627 "s5m8767,pmic-buck4-dvs-voltage",
628 pdata->buck4_voltage, dvs_voltage_nr)) {
629 dev_err(iodev->dev, "buck4 voltages not specified\n");
630 return -EINVAL;
631 }
632 }
633
634 if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs ||
635 pdata->buck4_gpiodvs) {
636 ret = s5m8767_pmic_dt_parse_dvs_gpio(iodev, pdata, pmic_np);
637 if (ret)
638 return -EINVAL;
639
640 if (of_property_read_u32(pmic_np,
641 "s5m8767,pmic-buck-default-dvs-idx",
642 &pdata->buck_default_idx)) {
643 pdata->buck_default_idx = 0;
644 } else {
645 if (pdata->buck_default_idx >= 8) {
646 pdata->buck_default_idx = 0;
647 dev_info(iodev->dev,
648 "invalid value for default dvs index, use 0\n");
649 }
650 }
651 }
652
653 ret = s5m8767_pmic_dt_parse_ds_gpio(iodev, pdata, pmic_np);
654 if (ret)
655 return -EINVAL;
656
657 if (of_get_property(pmic_np, "s5m8767,pmic-buck2-ramp-enable", NULL))
658 pdata->buck2_ramp_enable = true;
659
660 if (of_get_property(pmic_np, "s5m8767,pmic-buck3-ramp-enable", NULL))
661 pdata->buck3_ramp_enable = true;
662
663 if (of_get_property(pmic_np, "s5m8767,pmic-buck4-ramp-enable", NULL))
664 pdata->buck4_ramp_enable = true;
665
666 if (pdata->buck2_ramp_enable || pdata->buck3_ramp_enable
667 || pdata->buck4_ramp_enable) {
668 if (of_property_read_u32(pmic_np, "s5m8767,pmic-buck-ramp-delay",
669 &pdata->buck_ramp_delay))
670 pdata->buck_ramp_delay = 0;
671 }
672
673 return 0;
674 }
675 #else
676 static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
677 struct sec_platform_data *pdata)
678 {
679 return 0;
680 }
681 #endif /* CONFIG_OF */
682

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

#3 lore raw

Re: [PATCH 1/7] regulator: s5m8767: switch to using devm_fwnode_gpiod_get

In reply to Dmitry Torokhov
I love your patch! Perhaps something to improve:

Hi Dmitry,

I love your patch! Perhaps something to improve:

[auto build test WARNING on regulator/for-next]
[cannot apply to v5.4-rc1 next-20191004]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Dmitry-Torokhov/regulator-switch-to-using-devm_-fwnode_gpiod_get_index/20191005-085020
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
config: nds32-allyesconfig (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

All warnings (new ones prefixed by >>):

drivers/regulator/s5m8767.c: In function 's5m8767_pmic_dt_parse_pdata':
drivers/regulator/s5m8767.c:570:30: error: implicit declaration of function 'devm_fwnode_gpiod_get'; did you mean 'devm_gpiod_get'? [-Werror=implicit-function-declaration]

      rdata->ext_control_gpiod = devm_fwnode_gpiod_get(
                                 ^~~~~~~~~~~~~~~~~~~~~
                                 devm_gpiod_get
>> drivers/regulator/s5m8767.c:570:28: warning: assignment to 'struct gpio_desc *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
      rdata->ext_control_gpiod = devm_fwnode_gpiod_get(
                               ^

cc1: some warnings being treated as errors

vim +570 drivers/regulator/s5m8767.c

519
520 static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
521 struct sec_platform_data *pdata)
522 {
523 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
524 struct device_node *pmic_np, *regulators_np, *reg_np;
525 struct sec_regulator_data *rdata;
526 struct sec_opmode_data *rmode;
527 unsigned int i, dvs_voltage_nr = 8, ret;
528
529 pmic_np = iodev->dev->of_node;
530 if (!pmic_np) {
531 dev_err(iodev->dev, "could not find pmic sub-node\n");
532 return -ENODEV;
533 }
534
535 regulators_np = of_get_child_by_name(pmic_np, "regulators");
536 if (!regulators_np) {
537 dev_err(iodev->dev, "could not find regulators sub-node\n");
538 return -EINVAL;
539 }
540
541 /* count the number of regulators to be supported in pmic */
542 pdata->num_regulators = of_get_child_count(regulators_np);
543
544 rdata = devm_kcalloc(&pdev->dev,
545 pdata->num_regulators, sizeof(*rdata),
546 GFP_KERNEL);
547 if (!rdata)
548 return -ENOMEM;
549
550 rmode = devm_kcalloc(&pdev->dev,
551 pdata->num_regulators, sizeof(*rmode),
552 GFP_KERNEL);
553 if (!rmode)
554 return -ENOMEM;
555
556 pdata->regulators = rdata;
557 pdata->opmode = rmode;
558 for_each_child_of_node(regulators_np, reg_np) {
559 for (i = 0; i < ARRAY_SIZE(regulators); i++)
560 if (of_node_name_eq(reg_np, regulators[i].name))
561 break;
562
563 if (i == ARRAY_SIZE(regulators)) {
564 dev_warn(iodev->dev,
565 "don't know how to configure regulator %pOFn\n",
566 reg_np);
567 continue;
568 }
569

 > 570			rdata->ext_control_gpiod = devm_fwnode_gpiod_get(

571 &pdev->dev,
572 of_fwnode_handle(reg_np),
573 "s5m8767,pmic-ext-control",
574 GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE,
575 "s5m8767");
576 if (PTR_ERR(rdata->ext_control_gpiod) == -ENOENT)
577 rdata->ext_control_gpiod = NULL;
578 else if (IS_ERR(rdata->ext_control_gpiod))
579 return PTR_ERR(rdata->ext_control_gpiod);
580
581 rdata->id = i;
582 rdata->initdata = of_get_regulator_init_data(
583 &pdev->dev, reg_np,
584 &regulators[i]);
585 rdata->reg_node = reg_np;
586 rdata++;
587 rmode->id = i;
588 if (of_property_read_u32(reg_np, "op_mode",
589 &rmode->mode)) {
590 dev_warn(iodev->dev,
591 "no op_mode property property at %pOF\n",
592 reg_np);
593
594 rmode->mode = S5M8767_OPMODE_NORMAL_MODE;
595 }
596 rmode++;
597 }
598
599 of_node_put(regulators_np);
600
601 if (of_get_property(pmic_np, "s5m8767,pmic-buck2-uses-gpio-dvs", NULL)) {
602 pdata->buck2_gpiodvs = true;
603
604 if (of_property_read_u32_array(pmic_np,
605 "s5m8767,pmic-buck2-dvs-voltage",
606 pdata->buck2_voltage, dvs_voltage_nr)) {
607 dev_err(iodev->dev, "buck2 voltages not specified\n");
608 return -EINVAL;
609 }
610 }
611
612 if (of_get_property(pmic_np, "s5m8767,pmic-buck3-uses-gpio-dvs", NULL)) {
613 pdata->buck3_gpiodvs = true;
614
615 if (of_property_read_u32_array(pmic_np,
616 "s5m8767,pmic-buck3-dvs-voltage",
617 pdata->buck3_voltage, dvs_voltage_nr)) {
618 dev_err(iodev->dev, "buck3 voltages not specified\n");
619 return -EINVAL;
620 }
621 }
622
623 if (of_get_property(pmic_np, "s5m8767,pmic-buck4-uses-gpio-dvs", NULL)) {
624 pdata->buck4_gpiodvs = true;
625
626 if (of_property_read_u32_array(pmic_np,
627 "s5m8767,pmic-buck4-dvs-voltage",
628 pdata->buck4_voltage, dvs_voltage_nr)) {
629 dev_err(iodev->dev, "buck4 voltages not specified\n");
630 return -EINVAL;
631 }
632 }
633
634 if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs ||
635 pdata->buck4_gpiodvs) {
636 ret = s5m8767_pmic_dt_parse_dvs_gpio(iodev, pdata, pmic_np);
637 if (ret)
638 return -EINVAL;
639
640 if (of_property_read_u32(pmic_np,
641 "s5m8767,pmic-buck-default-dvs-idx",
642 &pdata->buck_default_idx)) {
643 pdata->buck_default_idx = 0;
644 } else {
645 if (pdata->buck_default_idx >= 8) {
646 pdata->buck_default_idx = 0;
647 dev_info(iodev->dev,
648 "invalid value for default dvs index, use 0\n");
649 }
650 }
651 }
652
653 ret = s5m8767_pmic_dt_parse_ds_gpio(iodev, pdata, pmic_np);
654 if (ret)
655 return -EINVAL;
656
657 if (of_get_property(pmic_np, "s5m8767,pmic-buck2-ramp-enable", NULL))
658 pdata->buck2_ramp_enable = true;
659
660 if (of_get_property(pmic_np, "s5m8767,pmic-buck3-ramp-enable", NULL))
661 pdata->buck3_ramp_enable = true;
662
663 if (of_get_property(pmic_np, "s5m8767,pmic-buck4-ramp-enable", NULL))
664 pdata->buck4_ramp_enable = true;
665
666 if (pdata->buck2_ramp_enable || pdata->buck3_ramp_enable
667 || pdata->buck4_ramp_enable) {
668 if (of_property_read_u32(pmic_np, "s5m8767,pmic-buck-ramp-delay",
669 &pdata->buck_ramp_delay))
670 pdata->buck_ramp_delay = 0;
671 }
672
673 return 0;
674 }
675 #else
676 static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
677 struct sec_platform_data *pdata)
678 {
679 return 0;
680 }
681 #endif /* CONFIG_OF */
682

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

maintainer
#4 lore raw

Applied "regulator: s5m8767: switch to using devm_fwnode_gpiod_get" to the regulator tree

In reply to Dmitry Torokhov

The patch

regulator: s5m8767: switch to using devm_fwnode_gpiod_get

has been applied to the regulator tree at

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

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

Quoted 1 line

From 5be0e549e18f8ad7efa81b3e054ca094b7782f55 Mon Sep 17 00:00:00 2001

From: Dmitry Torokhov <[email protected]>
Date: Fri, 4 Oct 2019 16:10:11 -0700
Subject: [PATCH] regulator: s5m8767: switch to using devm_fwnode_gpiod_get

devm_gpiod_get_from_of_node() is being retired in favor of devm_fwnode_gpiod_get_index(), that behaves similar to devm_gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes.

Let's switch this driver over.

---
 drivers/regulator/s5m8767.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/regulator/s5m8767.c +3 -4
index 6ca27e9d5ef7..bdc07739e9a2 100644
@@ -567,11 +567,10 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
 			continue;
 		}
 
-		rdata->ext_control_gpiod = devm_gpiod_get_from_of_node(
+		rdata->ext_control_gpiod = devm_fwnode_gpiod_get(
 			&pdev->dev,
-			reg_np,
-			"s5m8767,pmic-ext-control-gpios",
-			0,
+			of_fwnode_handle(reg_np),
+			"s5m8767,pmic-ext-control",
 			GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE,
 			"s5m8767");
 		if (PTR_ERR(rdata->ext_control_gpiod) == -ENOENT)
Signature · 1 line
2.20.1
#5 lore raw

PATCH 2/7 regulator: slg51000: switch to using fwnode_gpiod_get_index

In reply to Dmitry Torokhov

devm_gpiod_get_from_of_node() is being retired in favor of [devm_]fwnode_gpiod_get_index(), that behaves similar to devm_gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes.

Let's switch this driver over.

Note that now that we have a good non-devm API for getting GPIO from arbitrary firmware node, there is no reason to use devm API here as regulator core takes care of managing lifetime of "enable" GPIO and we were immediately detaching requested GPIO from devm anyway.

---

 drivers/regulator/slg51000-regulator.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/regulator/slg51000-regulator.c +5 -8
index a0565daecace..bf1a3508ebc4 100644
@@ -198,17 +198,14 @@ static int slg51000_of_parse_cb(struct device_node *np,
 				const struct regulator_desc *desc,
 				struct regulator_config *config)
 {
-	struct slg51000 *chip = config->driver_data;
 	struct gpio_desc *ena_gpiod;
-	enum gpiod_flags gflags = GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE;
 
-	ena_gpiod = devm_gpiod_get_from_of_node(chip->dev, np,
-						"enable-gpios", 0,
-						gflags, "gpio-en-ldo");
-	if (!IS_ERR(ena_gpiod)) {
+	ena_gpiod = fwnode_gpiod_get_index(of_fwnode_handle(np), "enable", 0,
+					   GPIOD_OUT_LOW |
+						GPIOD_FLAGS_BIT_NONEXCLUSIVE,
+					   "gpio-en-ldo");
+	if (!IS_ERR(ena_gpiod))
 		config->ena_gpiod = ena_gpiod;
-		devm_gpiod_unhinge(chip->dev, config->ena_gpiod);
-	}
 
 	return 0;
 }
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
#6 lore raw

Re: [PATCH 2/7] regulator: slg51000: switch to using fwnode_gpiod_get_index

I love your patch! Yet something to improve:

Hi Dmitry,

I love your patch! Yet something to improve:

[auto build test ERROR on regulator/for-next]
[cannot apply to v5.4-rc1 next-20191004]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Dmitry-Torokhov/regulator-switch-to-using-devm_-fwnode_gpiod_get_index/20191005-085020
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-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=sh

If you fix the issue, kindly add following tag

All error/warnings (new ones prefixed by >>):

drivers/regulator/slg51000-regulator.c: In function 'slg51000_of_parse_cb':

>> drivers/regulator/slg51000-regulator.c:203:14: error: implicit declaration of function 'fwnode_gpiod_get_index'; did you mean 'devm_gpiod_get_index'? [-Werror=implicit-function-declaration]
     ena_gpiod = fwnode_gpiod_get_index(of_fwnode_handle(np), "enable", 0,
                 ^~~~~~~~~~~~~~~~~~~~~~
                 devm_gpiod_get_index
>> drivers/regulator/slg51000-regulator.c:203:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]

ena_gpiod = fwnode_gpiod_get_index(of_fwnode_handle(np), "enable", 0,
^
cc1: some warnings being treated as errors

vim +203 drivers/regulator/slg51000-regulator.c

196
197 static int slg51000_of_parse_cb(struct device_node *np,
198 const struct regulator_desc *desc,
199 struct regulator_config *config)
200 {
201 struct gpio_desc *ena_gpiod;
202

 > 203		ena_gpiod = fwnode_gpiod_get_index(of_fwnode_handle(np), "enable", 0,

204 GPIOD_OUT_LOW |
205 GPIOD_FLAGS_BIT_NONEXCLUSIVE,
206 "gpio-en-ldo");
207 if (!IS_ERR(ena_gpiod))
208 config->ena_gpiod = ena_gpiod;
209
210 return 0;
211 }
212

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

maintainer
#7 lore raw

Applied "regulator: slg51000: switch to using fwnode_gpiod_get_index" to the regulator tree

In reply to Dmitry Torokhov

The patch

regulator: slg51000: switch to using fwnode_gpiod_get_index

has been applied to the regulator tree at

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

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 de2cd1a552673f370f8ea39a0241f764fbcf39e5 Mon Sep 17 00:00:00 2001
From: Dmitry Torokhov <[email protected]>
Date: Fri, 4 Oct 2019 16:10:12 -0700
Subject: [PATCH] regulator: slg51000: switch to using fwnode_gpiod_get_index

devm_gpiod_get_from_of_node() is being retired in favor of [devm_]fwnode_gpiod_get_index(), that behaves similar to devm_gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes.

Let's switch this driver over.

Note that now that we have a good non-devm API for getting GPIO from arbitrary firmware node, there is no reason to use devm API here as regulator core takes care of managing lifetime of "enable" GPIO and we were immediately detaching requested GPIO from devm anyway.

---
 drivers/regulator/slg51000-regulator.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/regulator/slg51000-regulator.c +5 -8
index a0565daecace..bf1a3508ebc4 100644
@@ -198,17 +198,14 @@ static int slg51000_of_parse_cb(struct device_node *np,
 				const struct regulator_desc *desc,
 				struct regulator_config *config)
 {
-	struct slg51000 *chip = config->driver_data;
 	struct gpio_desc *ena_gpiod;
-	enum gpiod_flags gflags = GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE;
 
-	ena_gpiod = devm_gpiod_get_from_of_node(chip->dev, np,
-						"enable-gpios", 0,
-						gflags, "gpio-en-ldo");
-	if (!IS_ERR(ena_gpiod)) {
+	ena_gpiod = fwnode_gpiod_get_index(of_fwnode_handle(np), "enable", 0,
+					   GPIOD_OUT_LOW |
+						GPIOD_FLAGS_BIT_NONEXCLUSIVE,
+					   "gpio-en-ldo");
+	if (!IS_ERR(ena_gpiod))
 		config->ena_gpiod = ena_gpiod;
-		devm_gpiod_unhinge(chip->dev, config->ena_gpiod);
-	}
 
 	return 0;
 }
Signature · 1 line
2.20.1
#8 lore raw

PATCH 3/7 regulator: tps65090: switch to using devm_fwnode_gpiod_get

In reply to Dmitry Torokhov

devm_gpiod_get_from_of_node() is being retired in favor of devm_fwnode_gpiod_get_index(), that behaves similar to devm_gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes.

Let's switch this driver over.

---

 drivers/regulator/tps65090-regulator.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)
drivers/regulator/tps65090-regulator.c +15 -11
index 10ea4b5a0f55..f0b660e9f15f 100644
@@ -346,16 +346,20 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data(
 	for (idx = 0; idx < ARRAY_SIZE(tps65090_matches); idx++) {
 		struct regulator_init_data *ri_data;
 		struct tps65090_regulator_plat_data *rpdata;
+		struct device_node *np;
 
 		rpdata = &reg_pdata[idx];
 		ri_data = tps65090_matches[idx].init_data;
-		if (!ri_data || !tps65090_matches[idx].of_node)
+		if (!ri_data)
+			continue;
+
+		np = tps65090_matches[idx].of_node;
+		if (!np)
 			continue;
 
 		rpdata->reg_init_data = ri_data;
-		rpdata->enable_ext_control = of_property_read_bool(
-					tps65090_matches[idx].of_node,
-					"ti,enable-ext-control");
+		rpdata->enable_ext_control = of_property_read_bool(np,
+						"ti,enable-ext-control");
 		if (rpdata->enable_ext_control) {
 			enum gpiod_flags gflags;
 
@@ -366,11 +370,12 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data(
 				gflags = GPIOD_OUT_LOW;
 			gflags |= GPIOD_FLAGS_BIT_NONEXCLUSIVE;
 
-			rpdata->gpiod = devm_gpiod_get_from_of_node(&pdev->dev,
-								    tps65090_matches[idx].of_node,
-								    "dcdc-ext-control-gpios", 0,
-								    gflags,
-								    "tps65090");
+			rpdata->gpiod = devm_fwnode_gpiod_get(
+							&pdev->dev,
+							of_fwnode_handle(np),
+							"dcdc-ext-control",
+							gflags,
+							"tps65090");
 			if (PTR_ERR(rpdata->gpiod) == -ENOENT) {
 				dev_err(&pdev->dev,
 					"could not find DCDC external control GPIO\n");
@@ -379,8 +384,7 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data(
 				return ERR_CAST(rpdata->gpiod);
 		}
 
-		if (of_property_read_u32(tps65090_matches[idx].of_node,
-					 "ti,overcurrent-wait",
+		if (of_property_read_u32(np, "ti,overcurrent-wait",
 					 &rpdata->overcurrent_wait) == 0)
 			rpdata->overcurrent_wait_valid = true;
 
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
maintainer
#9 lore raw

Applied "regulator: tps65090: switch to using devm_fwnode_gpiod_get" to the regulator tree

The patch

regulator: tps65090: switch to using devm_fwnode_gpiod_get

has been applied to the regulator tree at

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

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 51d98ff8616a3c46233bdd1b714b8f19537bc9a8 Mon Sep 17 00:00:00 2001
From: Dmitry Torokhov <[email protected]>
Date: Fri, 4 Oct 2019 16:10:13 -0700
Subject: [PATCH] regulator: tps65090: switch to using devm_fwnode_gpiod_get

devm_gpiod_get_from_of_node() is being retired in favor of devm_fwnode_gpiod_get_index(), that behaves similar to devm_gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes.

Let's switch this driver over.

---
 drivers/regulator/tps65090-regulator.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)
drivers/regulator/tps65090-regulator.c +15 -11
index 10ea4b5a0f55..f0b660e9f15f 100644
@@ -346,16 +346,20 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data(
 	for (idx = 0; idx < ARRAY_SIZE(tps65090_matches); idx++) {
 		struct regulator_init_data *ri_data;
 		struct tps65090_regulator_plat_data *rpdata;
+		struct device_node *np;
 
 		rpdata = &reg_pdata[idx];
 		ri_data = tps65090_matches[idx].init_data;
-		if (!ri_data || !tps65090_matches[idx].of_node)
+		if (!ri_data)
+			continue;
+
+		np = tps65090_matches[idx].of_node;
+		if (!np)
 			continue;
 
 		rpdata->reg_init_data = ri_data;
-		rpdata->enable_ext_control = of_property_read_bool(
-					tps65090_matches[idx].of_node,
-					"ti,enable-ext-control");
+		rpdata->enable_ext_control = of_property_read_bool(np,
+						"ti,enable-ext-control");
 		if (rpdata->enable_ext_control) {
 			enum gpiod_flags gflags;
 
@@ -366,11 +370,12 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data(
 				gflags = GPIOD_OUT_LOW;
 			gflags |= GPIOD_FLAGS_BIT_NONEXCLUSIVE;
 
-			rpdata->gpiod = devm_gpiod_get_from_of_node(&pdev->dev,
-								    tps65090_matches[idx].of_node,
-								    "dcdc-ext-control-gpios", 0,
-								    gflags,
-								    "tps65090");
+			rpdata->gpiod = devm_fwnode_gpiod_get(
+							&pdev->dev,
+							of_fwnode_handle(np),
+							"dcdc-ext-control",
+							gflags,
+							"tps65090");
 			if (PTR_ERR(rpdata->gpiod) == -ENOENT) {
 				dev_err(&pdev->dev,
 					"could not find DCDC external control GPIO\n");
@@ -379,8 +384,7 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data(
 				return ERR_CAST(rpdata->gpiod);
 		}
 
-		if (of_property_read_u32(tps65090_matches[idx].of_node,
-					 "ti,overcurrent-wait",
+		if (of_property_read_u32(np, "ti,overcurrent-wait",
 					 &rpdata->overcurrent_wait) == 0)
 			rpdata->overcurrent_wait_valid = true;
 
Signature · 1 line
2.20.1
#10 lore raw

PATCH 4/7 regulator: s2mps11: switch to using devm_fwnode_gpiod_get

In reply to Dmitry Torokhov

devm_gpiod_get_from_of_node() is being retired in favor of devm_fwnode_gpiod_get_index(), that behaves similar to devm_gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes.

Let's switch this driver over.

---

 drivers/regulator/s2mps11.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/regulator/s2mps11.c +3 -4
index 5bc00884cf51..4f2dc5ebffdc 100644
@@ -844,10 +844,9 @@ static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev,
 		if (!rdata[reg].init_data || !rdata[reg].of_node)
 			continue;
 
-		gpio[reg] = devm_gpiod_get_from_of_node(&pdev->dev,
-				rdata[reg].of_node,
-				"samsung,ext-control-gpios",
-				0,
+		gpio[reg] = devm_fwnode_gpiod_get(&pdev->dev,
+				of_fwnode_handle(rdata[reg].of_node),
+				"samsung,ext-control",
 				GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE,
 				"s2mps11-regulator");
 		if (PTR_ERR(gpio[reg]) == -ENOENT)
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
maintainer
#11 lore raw

Applied "regulator: s2mps11: switch to using devm_fwnode_gpiod_get" to the regulator tree

The patch

regulator: s2mps11: switch to using devm_fwnode_gpiod_get

has been applied to the regulator tree at

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

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

Quoted 1 line

From de2792b507675641885075bc99e283de861b1ce6 Mon Sep 17 00:00:00 2001

From: Dmitry Torokhov <[email protected]>
Date: Fri, 4 Oct 2019 16:10:14 -0700
Subject: [PATCH] regulator: s2mps11: switch to using devm_fwnode_gpiod_get

devm_gpiod_get_from_of_node() is being retired in favor of devm_fwnode_gpiod_get_index(), that behaves similar to devm_gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes.

Let's switch this driver over.

---
 drivers/regulator/s2mps11.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/regulator/s2mps11.c +3 -4
index 5bc00884cf51..4f2dc5ebffdc 100644
@@ -844,10 +844,9 @@ static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev,
 		if (!rdata[reg].init_data || !rdata[reg].of_node)
 			continue;
 
-		gpio[reg] = devm_gpiod_get_from_of_node(&pdev->dev,
-				rdata[reg].of_node,
-				"samsung,ext-control-gpios",
-				0,
+		gpio[reg] = devm_fwnode_gpiod_get(&pdev->dev,
+				of_fwnode_handle(rdata[reg].of_node),
+				"samsung,ext-control",
 				GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE,
 				"s2mps11-regulator");
 		if (PTR_ERR(gpio[reg]) == -ENOENT)
Signature · 1 line
2.20.1
#12 lore raw

PATCH 5/7 regulator: da9211: switch to using devm_fwnode_gpiod_get

In reply to Dmitry Torokhov

devm_gpiod_get_from_of_node() is being retired in favor of devm_fwnode_gpiod_get_index(), that behaves similar to devm_gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes.

Let's switch this driver over.

---

 drivers/regulator/da9211-regulator.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/regulator/da9211-regulator.c +6 -6
index bf80748f1ccc..523dc1b95826 100644
@@ -283,12 +283,12 @@ static struct da9211_pdata *da9211_parse_regulators_dt(
 
 		pdata->init_data[n] = da9211_matches[i].init_data;
 		pdata->reg_node[n] = da9211_matches[i].of_node;
-		pdata->gpiod_ren[n] = devm_gpiod_get_from_of_node(dev,
-				  da9211_matches[i].of_node,
-				  "enable-gpios",
-				  0,
-				  GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE,
-				  "da9211-enable");
+		pdata->gpiod_ren[n] = devm_fwnode_gpiod_get(dev,
+					of_fwnode_handle(pdata->reg_node[n]),
+					"enable",
+					GPIOD_OUT_HIGH |
+						GPIOD_FLAGS_BIT_NONEXCLUSIVE,
+					"da9211-enable");
 		if (IS_ERR(pdata->gpiod_ren[n]))
 			pdata->gpiod_ren[n] = NULL;
 		n++;
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
#13 lore raw

Re: [PATCH 5/7] regulator: da9211: switch to using devm_fwnode_gpiod_get

I love your patch! Yet something to improve:

Hi Dmitry,

I love your patch! Yet something to improve:

[auto build test ERROR on regulator/for-next]
[cannot apply to v5.4-rc1 next-20191004]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Dmitry-Torokhov/regulator-switch-to-using-devm_-fwnode_gpiod_get_index/20191005-085020
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-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=sh

If you fix the issue, kindly add following tag

All error/warnings (new ones prefixed by >>):

drivers/regulator/da9211-regulator.c: In function 'da9211_parse_regulators_dt':

>> drivers/regulator/da9211-regulator.c:286:25: error: implicit declaration of function 'devm_fwnode_gpiod_get'; did you mean 'devm_gpiod_get'? [-Werror=implicit-function-declaration]
      pdata->gpiod_ren[n] = devm_fwnode_gpiod_get(dev,
                            ^~~~~~~~~~~~~~~~~~~~~
                            devm_gpiod_get
>> drivers/regulator/da9211-regulator.c:286:23: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
      pdata->gpiod_ren[n] = devm_fwnode_gpiod_get(dev,
                          ^

cc1: some warnings being treated as errors

vim +286 drivers/regulator/da9211-regulator.c

245
246 #ifdef CONFIG_OF
247 static struct of_regulator_match da9211_matches[] = {
248 [DA9211_ID_BUCKA] = { .name = "BUCKA" },
249 [DA9211_ID_BUCKB] = { .name = "BUCKB" },
250 };
251
252 static struct da9211_pdata *da9211_parse_regulators_dt(
253 struct device *dev)
254 {
255 struct da9211_pdata *pdata;
256 struct device_node *node;
257 int i, num, n;
258
259 node = of_get_child_by_name(dev->of_node, "regulators");
260 if (!node) {
261 dev_err(dev, "regulators node not found\n");
262 return ERR_PTR(-ENODEV);
263 }
264
265 num = of_regulator_match(dev, node, da9211_matches,
266 ARRAY_SIZE(da9211_matches));
267 of_node_put(node);
268 if (num < 0) {
269 dev_err(dev, "Failed to match regulators\n");
270 return ERR_PTR(-EINVAL);
271 }
272
273 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
274 if (!pdata)
275 return ERR_PTR(-ENOMEM);
276
277 pdata->num_buck = num;
278
279 n = 0;
280 for (i = 0; i < ARRAY_SIZE(da9211_matches); i++) {
281 if (!da9211_matches[i].init_data)
282 continue;
283
284 pdata->init_data[n] = da9211_matches[i].init_data;
285 pdata->reg_node[n] = da9211_matches[i].of_node;

 > 286			pdata->gpiod_ren[n] = devm_fwnode_gpiod_get(dev,

287 of_fwnode_handle(pdata->reg_node[n]),
288 "enable",
289 GPIOD_OUT_HIGH |
290 GPIOD_FLAGS_BIT_NONEXCLUSIVE,
291 "da9211-enable");
292 if (IS_ERR(pdata->gpiod_ren[n]))
293 pdata->gpiod_ren[n] = NULL;
294 n++;
295 }
296
297 return pdata;
298 }
299 #else
300 static struct da9211_pdata *da9211_parse_regulators_dt(
301 struct device *dev)
302 {
303 return ERR_PTR(-ENODEV);
304 }
305 #endif
306

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

Acked-by on v1 5/7
#14 lore raw

RE: [PATCH 5/7] regulator: da9211: switch to using devm_fwnode_gpiod_get

In reply to Dmitry Torokhov
Quoted 8 lines · Dmitry Torokhov

devm_gpiod_get_from_of_node() is being retired in favor of devm_fwnode_gpiod_get_index(), that behaves similar to devm_gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes.

Let's switch this driver over.

Quoted 35 lines

---

 drivers/regulator/da9211-regulator.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/regulator/da9211- renamed from drivers/regulator/da9211-regulator.c +0 -0

regulator.c
index bf80748f1ccc..523dc1b95826 100644

drivers/regulator/da9211-regulator.c +5 -6
@@ -283,12 +283,12 @@ static struct da9211_pdata
 *da9211_parse_regulators_dt(
 
 		pdata->init_data[n] = da9211_matches[i].init_data;
 		pdata->reg_node[n] = da9211_matches[i].of_node;
-		pdata->gpiod_ren[n] = devm_gpiod_get_from_of_node(dev,
-				  da9211_matches[i].of_node,
-				  "enable-gpios",
-				  0,
-				  GPIOD_OUT_HIGH |
 GPIOD_FLAGS_BIT_NONEXCLUSIVE,
-				  "da9211-enable");
+		pdata->gpiod_ren[n] = devm_fwnode_gpiod_get(dev,
+					of_fwnode_handle(pdata-
 >reg_node[n]),
+					"enable",
+					GPIOD_OUT_HIGH |
+

GPIOD_FLAGS_BIT_NONEXCLUSIVE,

drivers/regulator/da9211-regulator.c +1 -1
+					"da9211-enable");
 		if (IS_ERR(pdata->gpiod_ren[n]))
 			pdata->gpiod_ren[n] = NULL;
 		n++;
--

2.23.0.581.g78d2f28ef7-goog

maintainer
#15 lore raw

Applied "regulator: da9211: switch to using devm_fwnode_gpiod_get" to the regulator tree

In reply to Dmitry Torokhov

The patch

regulator: da9211: switch to using devm_fwnode_gpiod_get

has been applied to the regulator tree at

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

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 61d2fc3cf8f557193c8c362ea75f06fa5a0abcfe Mon Sep 17 00:00:00 2001
From: Dmitry Torokhov <[email protected]>
Date: Fri, 4 Oct 2019 16:10:15 -0700
Subject: [PATCH] regulator: da9211: switch to using devm_fwnode_gpiod_get

devm_gpiod_get_from_of_node() is being retired in favor of devm_fwnode_gpiod_get_index(), that behaves similar to devm_gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes.

Let's switch this driver over.

---
 drivers/regulator/da9211-regulator.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/regulator/da9211-regulator.c +6 -6
index bf80748f1ccc..523dc1b95826 100644
@@ -283,12 +283,12 @@ static struct da9211_pdata *da9211_parse_regulators_dt(
 
 		pdata->init_data[n] = da9211_matches[i].init_data;
 		pdata->reg_node[n] = da9211_matches[i].of_node;
-		pdata->gpiod_ren[n] = devm_gpiod_get_from_of_node(dev,
-				  da9211_matches[i].of_node,
-				  "enable-gpios",
-				  0,
-				  GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE,
-				  "da9211-enable");
+		pdata->gpiod_ren[n] = devm_fwnode_gpiod_get(dev,
+					of_fwnode_handle(pdata->reg_node[n]),
+					"enable",
+					GPIOD_OUT_HIGH |
+						GPIOD_FLAGS_BIT_NONEXCLUSIVE,
+					"da9211-enable");
 		if (IS_ERR(pdata->gpiod_ren[n]))
 			pdata->gpiod_ren[n] = NULL;
 		n++;
Signature · 1 line
2.20.1
#16 lore raw

PATCH 6/7 regulator: tps65132: switch to using devm_fwnode_gpiod_get()

In reply to Dmitry Torokhov

devm_fwnode_get_index_gpiod_from_child() is going away as the name is too unwieldy, let's switch to using the new devm_fwnode_gpiod_get().

Note that we no longer need to check for NULL as devm_fwnode_gpiod_get() will return -ENOENT if GPIO is missing.

---

 drivers/regulator/tps65132-regulator.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/regulator/tps65132-regulator.c +10 -7
index e302bd01a084..7b0e38f8d627 100644
@@ -136,9 +136,10 @@ static int tps65132_of_parse_cb(struct device_node *np,
 	struct tps65132_reg_pdata *rpdata = &tps->reg_pdata[desc->id];
 	int ret;
 
-	rpdata->en_gpiod = devm_fwnode_get_index_gpiod_from_child(tps->dev,
-					"enable", 0, &np->fwnode, 0, "enable");
-	if (IS_ERR_OR_NULL(rpdata->en_gpiod)) {
+	rpdata->en_gpiod = devm_fwnode_gpiod_get(tps->dev, of_fwnode_handle(np),
+						 "enable", GPIOD_ASIS,
+						 "enable");
+	if (IS_ERR(rpdata->en_gpiod)) {
 		ret = PTR_ERR(rpdata->en_gpiod);
 
 		/* Ignore the error other than probe defer */
@@ -147,10 +148,12 @@ static int tps65132_of_parse_cb(struct device_node *np,
 		return 0;
 	}
 
-	rpdata->act_dis_gpiod = devm_fwnode_get_index_gpiod_from_child(
-					tps->dev, "active-discharge", 0,
-					&np->fwnode, 0, "active-discharge");
-	if (IS_ERR_OR_NULL(rpdata->act_dis_gpiod)) {
+	rpdata->act_dis_gpiod = devm_fwnode_gpiod_get(tps->dev,
+						      of_fwnode_handle(np),
+						      "active-discharge",
+						      GPIOD_ASIS,
+						      "active-discharge");
+	if (IS_ERR(rpdata->act_dis_gpiod)) {
 		ret = PTR_ERR(rpdata->act_dis_gpiod);
 
 		/* Ignore the error other than probe defer */
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
maintainer
#17 lore raw

Applied "regulator: tps65132: switch to using devm_fwnode_gpiod_get()" to the regulator tree

The patch

regulator: tps65132: switch to using devm_fwnode_gpiod_get()

has been applied to the regulator tree at

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

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 22803ca3c56b02e5bb8a4eb14104114009fd1c65 Mon Sep 17 00:00:00 2001
From: Dmitry Torokhov <[email protected]>
Date: Fri, 4 Oct 2019 16:10:16 -0700
Subject: [PATCH] regulator: tps65132: switch to using devm_fwnode_gpiod_get()

devm_fwnode_get_index_gpiod_from_child() is going away as the name is too unwieldy, let's switch to using the new devm_fwnode_gpiod_get().

Note that we no longer need to check for NULL as devm_fwnode_gpiod_get() will return -ENOENT if GPIO is missing.

---
 drivers/regulator/tps65132-regulator.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/regulator/tps65132-regulator.c +10 -7
index e302bd01a084..7b0e38f8d627 100644
@@ -136,9 +136,10 @@ static int tps65132_of_parse_cb(struct device_node *np,
 	struct tps65132_reg_pdata *rpdata = &tps->reg_pdata[desc->id];
 	int ret;
 
-	rpdata->en_gpiod = devm_fwnode_get_index_gpiod_from_child(tps->dev,
-					"enable", 0, &np->fwnode, 0, "enable");
-	if (IS_ERR_OR_NULL(rpdata->en_gpiod)) {
+	rpdata->en_gpiod = devm_fwnode_gpiod_get(tps->dev, of_fwnode_handle(np),
+						 "enable", GPIOD_ASIS,
+						 "enable");
+	if (IS_ERR(rpdata->en_gpiod)) {
 		ret = PTR_ERR(rpdata->en_gpiod);
 
 		/* Ignore the error other than probe defer */
@@ -147,10 +148,12 @@ static int tps65132_of_parse_cb(struct device_node *np,
 		return 0;
 	}
 
-	rpdata->act_dis_gpiod = devm_fwnode_get_index_gpiod_from_child(
-					tps->dev, "active-discharge", 0,
-					&np->fwnode, 0, "active-discharge");
-	if (IS_ERR_OR_NULL(rpdata->act_dis_gpiod)) {
+	rpdata->act_dis_gpiod = devm_fwnode_gpiod_get(tps->dev,
+						      of_fwnode_handle(np),
+						      "active-discharge",
+						      GPIOD_ASIS,
+						      "active-discharge");
+	if (IS_ERR(rpdata->act_dis_gpiod)) {
 		ret = PTR_ERR(rpdata->act_dis_gpiod);
 
 		/* Ignore the error other than probe defer */
Signature · 1 line
2.20.1
#18 lore raw

PATCH 7/7 regulator: max77686: switch to using fwnode_gpiod_get_index

In reply to Dmitry Torokhov

gpiod_get_from_of_node() is being retired in favor of fwnode_gpiod_get_index(), that behaves similar to gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes.

Let's switch this driver over.

---

 drivers/regulator/max77686-regulator.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/regulator/max77686-regulator.c +3 -2
index c8e579e99316..9089ec608fcc 100644
@@ -256,8 +256,9 @@ static int max77686_of_parse_cb(struct device_node *np,
 	case MAX77686_BUCK8:
 	case MAX77686_BUCK9:
 	case MAX77686_LDO20 ... MAX77686_LDO22:
-		config->ena_gpiod = gpiod_get_from_of_node(np,
-				"maxim,ena-gpios",
+		config->ena_gpiod = fwnode_gpiod_get_index(
+				of_fwnode_handle(np),
+				"maxim,ena",
 				0,
 				GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE,
 				"max77686-regulator");
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
#19 lore raw

Re: [PATCH 7/7] regulator: max77686: switch to using fwnode_gpiod_get_index

I love your patch! Yet something to improve:

Hi Dmitry,

I love your patch! Yet something to improve:

[auto build test ERROR on regulator/for-next]
[cannot apply to v5.4-rc1 next-20191004]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Dmitry-Torokhov/regulator-switch-to-using-devm_-fwnode_gpiod_get_index/20191005-085020
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-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=sh

If you fix the issue, kindly add following tag

All error/warnings (new ones prefixed by >>):

drivers//regulator/max77686-regulator.c: In function 'max77686_of_parse_cb':

>> drivers//regulator/max77686-regulator.c:259:23: error: implicit declaration of function 'fwnode_gpiod_get_index'; did you mean 'devm_gpiod_get_index'? [-Werror=implicit-function-declaration]
      config->ena_gpiod = fwnode_gpiod_get_index(
                          ^~~~~~~~~~~~~~~~~~~~~~
                          devm_gpiod_get_index
>> drivers//regulator/max77686-regulator.c:259:21: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
      config->ena_gpiod = fwnode_gpiod_get_index(
                        ^

cc1: some warnings being treated as errors

vim +259 drivers//regulator/max77686-regulator.c

247
248 static int max77686_of_parse_cb(struct device_node *np,
249 const struct regulator_desc *desc,
250 struct regulator_config *config)
251 {
252 struct max77686_data *max77686 = config->driver_data;
253 int ret;
254
255 switch (desc->id) {
256 case MAX77686_BUCK8:
257 case MAX77686_BUCK9:
258 case MAX77686_LDO20 ... MAX77686_LDO22:

 > 259			config->ena_gpiod = fwnode_gpiod_get_index(

260 of_fwnode_handle(np),
261 "maxim,ena",
262 0,
263 GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE,
264 "max77686-regulator");
265 if (IS_ERR(config->ena_gpiod))
266 config->ena_gpiod = NULL;
267 break;
268 default:
269 return 0;
270 }
271
272 if (config->ena_gpiod) {
273 set_bit(desc->id, max77686->gpio_enabled);
274
275 ret = regmap_update_bits(config->regmap, desc->enable_reg,
276 desc->enable_mask,
277 MAX77686_GPIO_CONTROL);
278 if (ret) {
279 gpiod_put(config->ena_gpiod);
280 config->ena_gpiod = NULL;
281 }
282 }
283
284 return 0;
285 }
286

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

maintainer
#20 lore raw

Applied "regulator: max77686: switch to using fwnode_gpiod_get_index" to the regulator tree

In reply to Dmitry Torokhov

The patch

regulator: max77686: switch to using fwnode_gpiod_get_index

has been applied to the regulator tree at

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

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 0b2ba815fb5cbfab253f175d0b0d0d93d7ab9b5d Mon Sep 17 00:00:00 2001
From: Dmitry Torokhov <[email protected]>
Date: Fri, 4 Oct 2019 16:10:17 -0700
Subject: [PATCH] regulator: max77686: switch to using fwnode_gpiod_get_index

gpiod_get_from_of_node() is being retired in favor of fwnode_gpiod_get_index(), that behaves similar to gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes.

Let's switch this driver over.

---
 drivers/regulator/max77686-regulator.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/regulator/max77686-regulator.c +3 -2
index c8e579e99316..9089ec608fcc 100644
@@ -256,8 +256,9 @@ static int max77686_of_parse_cb(struct device_node *np,
 	case MAX77686_BUCK8:
 	case MAX77686_BUCK9:
 	case MAX77686_LDO20 ... MAX77686_LDO22:
-		config->ena_gpiod = gpiod_get_from_of_node(np,
-				"maxim,ena-gpios",
+		config->ena_gpiod = fwnode_gpiod_get_index(
+				of_fwnode_handle(np),
+				"maxim,ena",
 				0,
 				GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE,
 				"max77686-regulator");
Signature · 1 line
2.20.1
Reviewed-by on the v1 series
#21 lore raw
In reply to Dmitry Torokhov
Quoted 5 lines · Dmitry Torokhov

This series swiches regulator drivers form using [devm_]gpiod_get_from_of_node() that is scheduled to be removed in favor of [devm_]fwnode_gpiod_get_index() that behaves more like standard [devm_]gpiod_get_index() and will potentially handle secondary software nodes in cases we need to augment platform firmware.

The series:

Too bad with the build robots being unable to parse the pull deps. Now they hammer out complaints.

Yours,
Linus Walleij