Skip to contentSkip to conversation

regulator: mt6370: Use 'fwnode_gpiod_get_index' to fix gpio parsing

PATCH In review cy_huang 3 participants 6 messages Jun 29, 2022 – Jun 30, 2022

Subsystems (2)
lore
Share & tools
lore

cy_huang

author
#0 lore raw

PATCH 1/2 regulator: mt6370: Use 'fwnode_gpiod_get_index' to fix gpio parsing

From: ChiYuan Huang <[email protected]>

From the common binding, 'enable-gpio' or 'enable-gpios' are all well for external 'enable' gpio.

'gpiod_get_from_of_node' only parse the 'enable' property, it need to add the gpio suffix. It's more convenient to use fwnode_gpiod_get_index. Although fwnode parsing is not preferred, but 'of_parse_cb' already can guarantee the callback will only be used by regulator of_node parsing.

---
 drivers/regulator/mt6370-regulator.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/regulator/mt6370-regulator.c +2 -1
index bc356b4..949b2c7 100644
@@ -153,7 +153,8 @@ static int mt6370_of_parse_cb(struct device_node *np,
 	struct gpio_desc *enable_gpio;
 	int ret;
 
-	enable_gpio = gpiod_get_from_of_node(np, "enable", 0, GPIOD_OUT_HIGH |
+	enable_gpio = fwnode_gpiod_get_index(of_fwnode_handle(np), "enable", 0,
+					     GPIOD_OUT_HIGH |
 					     GPIOD_FLAGS_BIT_NONEXCLUSIVE,
 					     desc->name);
 	if (IS_ERR(enable_gpio)) {
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 2/2 regulator: mt6370: Use the correct header for platform_device_id

From: ChiYuan Huang <[email protected]>

'platform_device_id' struct is defined in 'mod_devicetable.h'. Even 'of.h' also includes this header usage. The 'of.h' cannot be removed due to 'of_match_ptr' function.

---
 drivers/regulator/mt6370-regulator.c | 1 +
 1 file changed, 1 insertion(+)
drivers/regulator/mt6370-regulator.c +1 -0
index 949b2c7..e73f5a4 100644
@@ -4,6 +4,7 @@
 #include <linux/gpio/consumer.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
Signature · 1 line
2.7.4
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] regulator: mt6370: Use the correct header for platform_device_id

Il 29/06/22 03:41, cy_huang ha scritto:

Quoted 7 lines

From: ChiYuan Huang <[email protected]>

'platform_device_id' struct is defined in 'mod_devicetable.h'. Even 'of.h' also includes this header usage. The 'of.h' cannot be removed due to 'of_match_ptr' function.

#3 lore raw
In reply to cy_huang

Il 29/06/22 03:41, cy_huang ha scritto:

Quoted 20 lines

From: ChiYuan Huang <[email protected]>

From the common binding, 'enable-gpio' or 'enable-gpios' are all well for external 'enable' gpio.

'gpiod_get_from_of_node' only parse the 'enable' property, it need to add the gpio suffix. It's more convenient to use fwnode_gpiod_get_index. Although fwnode parsing is not preferred, but 'of_parse_cb' already can guarantee the callback will only be used by regulator of_node parsing.

---
  drivers/regulator/mt6370-regulator.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/regulator/mt6370-regulator.c +0 -0
index bc356b4..949b2c7 100644

drivers/regulator/mt6370-regulator.c static int mt6370_of_parse_cb(struct device_node *np, · line 156

Quoted 5 lines
drivers/regulator/mt6370-regulator.c +1 -1
@@ -153,7 +153,8 @@ static int mt6370_of_parse_cb(struct device_node *np,
  	struct gpio_desc *enable_gpio;
  	int ret;
 
-	enable_gpio = gpiod_get_from_of_node(np, "enable", 0, GPIOD_OUT_HIGH |
+	enable_gpio = fwnode_gpiod_get_index(of_fwnode_handle(np), "enable", 0,

Since this driver is never calling gpiod_put(), you can even fix that in one shot.

Just use devm_fwnode_gpiod_get() here, as it's guaranteed that priv->dev is initialized at this time.

Cheers,
Angelo

#4 lore raw

AngeloGioacchino Del Regno <[email protected]> 於 2022年6月29日 週三 下午4:23寫道:

Quoted 25 lines

Il 29/06/22 03:41, cy_huang ha scritto:

Quoted 23 lines

From: ChiYuan Huang <[email protected]>

From the common binding, 'enable-gpio' or 'enable-gpios' are all well for external 'enable' gpio.

'gpiod_get_from_of_node' only parse the 'enable' property, it need to add the gpio suffix. It's more convenient to use fwnode_gpiod_get_index. Although fwnode parsing is not preferred, but 'of_parse_cb' already can guarantee the callback will only be used by regulator of_node parsing.

---
  drivers/regulator/mt6370-regulator.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/regulator/mt6370-regulator.c +0 -0
index bc356b4..949b2c7 100644
@@ -153,7 +153,8 @@ static int mt6370_of_parse_cb(struct device_node *np,
      struct gpio_desc *enable_gpio;
      int ret;
 
Quoted 8 lines

drivers/regulator/mt6370-regulator.c static int mt6370_of_parse_cb(struct device_node *np, · line 156

Quoted 2 lines
drivers/regulator/mt6370-regulator.c +1 -1
-     enable_gpio = gpiod_get_from_of_node(np, "enable", 0, GPIOD_OUT_HIGH |
+     enable_gpio = fwnode_gpiod_get_index(of_fwnode_handle(np), "enable", 0,

Since this driver is never calling gpiod_put(), you can even fix that in one shot.

Just use devm_fwnode_gpiod_get() here, as it's guaranteed that priv->dev is initialized at this time.

Refer to the regulator framework,it will take over the gpio_desc. You cannot use devm version for 'gpiod_get'.

Quoted 4 lines

Cheers,
Angelo

maintainer
#5 lore raw
In reply to cy_huang
Quoted 11 lines · cy_huang

From: ChiYuan Huang <[email protected]>

From the common binding, 'enable-gpio' or 'enable-gpios' are all well for external 'enable' gpio.

'gpiod_get_from_of_node' only parse the 'enable' property, it need to add the gpio suffix. It's more convenient to use fwnode_gpiod_get_index. Although fwnode parsing is not preferred, but 'of_parse_cb' already can guarantee the callback will only be used by regulator of_node parsing.

[...]

Applied to

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

Thanks!

[1/2] regulator: mt6370: Use 'fwnode_gpiod_get_index' to fix gpio parsing

      commit: 4806c991bf4ff959acf921ea72f931a945a968ae
[2/2] regulator: mt6370: Use the correct header for platform_device_id
      commit: 46ae6fb58fd49c4cb2d1ca34e87d603b7c96ba97

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