Skip to contentSkip to conversation

mfd: max8907: Schema, pdata and poweroff

PATCH Superseded Svyatoslav Ryhel 5 participants 13 messages Oct 27 – Nov 6

Subsystems (3)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover mfd: max8907: Schema, pdata and poweroff

Convert existing txt documentation file to DF schema. Remove platform data use. Switch to device managed poweroff handler.

Schema includes reference to pending tegra-regulators-coupling
conversion. https://lore.kernel.org/lkml/[email protected]/

---
Changes in v2:
- fixed max8907_power_off return

Changes in v3:
- added idata check in max8907_regulator_probe() for BBAT/SDBY/VRTC
- added conversion to devm_ helpers commit
- switch to devm_register_power_off_handler() and of_device_is_system_power_controller()

Changes in v4:
- dropped in-supply type definitions in schema
---

Svyatoslav Ryhel (4):
regulator: dt-bindings: maxim,max8907: Convert to DT schema
mfd: max8907: Remove platform_data based probing
mfd: max8907: Switch to resource-managed versions of helpers
mfd: max8907: Convert to use device managed poweroff handler

 .../devicetree/bindings/regulator/max8907.txt |  69 -----
 .../bindings/regulator/maxim,max8907.yaml     | 283 ++++++++++++++++++
 drivers/mfd/max8907.c                         | 159 ++++------
 drivers/regulator/max8907-regulator.c         |  11 +-
 include/linux/mfd/max8907.h                   |   5 -
 5 files changed, 347 insertions(+), 180 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/regulator/max8907.txt
 create mode 100644 Documentation/devicetree/bindings/regulator/maxim,max8907.yaml
Signature · 1 line
2.53.0
#1 lore raw

PATCH v4 1/4 regulator: dt-bindings: maxim,max8907: Convert to DT schema

Convert Maxim MAX8907 regulator binding from text to DT schema. Reference to nvidia,tegra-regulators-coupling in child regulator nodes.

---
 .../devicetree/bindings/regulator/max8907.txt |  69 -----
 .../bindings/regulator/maxim,max8907.yaml     | 283 ++++++++++++++++++
 2 files changed, 283 insertions(+), 69 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/regulator/max8907.txt
 create mode 100644 Documentation/devicetree/bindings/regulator/maxim,max8907.yaml
Documentation/devicetree/bindings/regulator/max8907.txt deleted +0 -69
deleted file mode 100644
index 371eccd1cd689..0000000000000
@@ -1,69 +0,0 @@
-MAX8907 regulator
-
-Required properties:
-- compatible: "maxim,max8907"
-- reg: I2C slave address
-- interrupts: The interrupt output of the controller
-- mbatt-supply: The input supply for MBATT, BBAT, SDBY, VRTC.
-- in-v1-supply: The input supply for SD1.
-- in-v2-supply: The input supply for SD2.
-- in-v3-supply: The input supply for SD3.
-- in1-supply: The input supply for LDO1.
-...
-- in20-supply: The input supply for LDO20.
-- regulators: A node that houses a sub-node for each regulator within the
-  device. Each sub-node is identified using the node's name (or the deprecated
-  regulator-compatible property if present), with valid values listed below.
-  The content of each sub-node is defined by the standard binding for
-  regulators; see regulator.txt.
-
-Optional properties:
-- maxim,system-power-controller: Boolean property indicating that the PMIC
-  controls the overall system power.
-
-The valid names for regulators are:
-
-  sd1, sd2, sd3, ldo1, ldo2, ldo3, ldo4, ldo5, ldo6, ldo7, ldo8, ldo9, ldo10,
-  ldo11, ldo12, ldo13, ldo14, ldo15, ldo16, ldo17, ldo18, ldo19, ldo20, out5v,
-  out33v, bbat, sdby, vrtc.
-
-Example:
-
-		max8907@3c {
-			compatible = "maxim,max8907";
-			reg = <0x3c>;
-			interrupts = <0 86 0x4>;
-
-			maxim,system-power-controller;
-
-			mbatt-supply = <&some_reg>;
-			in-v1-supply = <&mbatt_reg>;
-			...
-			in1-supply = <&mbatt_reg>;
-			...
-
-			regulators {
-				mbatt_reg: mbatt {
-					regulator-name = "vbat_pmu";
-					regulator-min-microvolt = <5000000>;
-					regulator-max-microvolt = <5000000>;
-					regulator-always-on;
-				};
-
-				sd1 {
-					regulator-name = "nvvdd_sv1,vdd_cpu_pmu";
-					regulator-min-microvolt = <1000000>;
-					regulator-max-microvolt = <1000000>;
-					regulator-always-on;
-				};
-
-				sd2 {
-					regulator-name = "nvvdd_sv2,vdd_core";
-					regulator-min-microvolt = <1200000>;
-					regulator-max-microvolt = <1200000>;
-					regulator-always-on;
-				};
-...
-			};
-		};
-	};
Documentation/devicetree/bindings/regulator/maxim,max8907.yaml new file +283 -0

283 lines not on this page · raw message

Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH v4 1/4] regulator: dt-bindings: maxim,max8907: Convert to DT schema

Sashiko has reviewed this patch and found no issues.
Quoted 4 lines

Convert Maxim MAX8907 regulator binding from text to DT schema. Reference to nvidia,tegra-regulators-coupling in child regulator nodes.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Acked-by on v4 1/4
#3 lore raw

Re: [PATCH v4 1/4] regulator: dt-bindings: maxim,max8907: Convert to DT schema

In reply to Svyatoslav Ryhel
Quoted 2 lines · Svyatoslav Ryhel

Convert Maxim MAX8907 regulator binding from text to DT schema. Reference to nvidia,tegra-regulators-coupling in child regulator nodes.

maintainer Reviewed-by on v4 1/4
#4 lore raw

Re: [PATCH v4 1/4] regulator: dt-bindings: maxim,max8907: Convert to DT schema

In reply to Svyatoslav Ryhel
Quoted 11 lines · Svyatoslav Ryhel

Convert Maxim MAX8907 regulator binding from text to DT schema. Reference to nvidia,tegra-regulators-coupling in child regulator nodes.

---
 .../devicetree/bindings/regulator/max8907.txt |  69 -----
 .../bindings/regulator/maxim,max8907.yaml     | 283 ++++++++++++++++++
 2 files changed, 283 insertions(+), 69 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/regulator/max8907.txt
 create mode 100644 Documentation/devicetree/bindings/regulator/maxim,max8907.yaml
#5 lore raw

PATCH v4 2/4 mfd: max8907: Remove platform_data based probing

In reply to Svyatoslav Ryhel

There are no in-tree users of this driver, but it supports devicetree based probing, which means external dtb files may exist that work with this.

Remove the unused legacy code and make this a DT-only driver.

---
 drivers/mfd/max8907.c                 |  8 +-------
 drivers/regulator/max8907-regulator.c | 11 +++++------
 include/linux/mfd/max8907.h           |  5 -----
 3 files changed, 6 insertions(+), 18 deletions(-)
drivers/mfd/max8907.c +1 -7
index 7bac1d6517717..363ac80c0593b 100644
@@ -184,13 +184,7 @@ static int max8907_i2c_probe(struct i2c_client *i2c)
 {
 	struct max8907 *max8907;
 	int ret;
-	struct max8907_platform_data *pdata = dev_get_platdata(&i2c->dev);
-	bool pm_off = false;
-
-	if (pdata)
-		pm_off = pdata->pm_off;
-	else if (i2c->dev.of_node)
-		pm_off = of_property_read_bool(i2c->dev.of_node,
+	bool pm_off = of_property_read_bool(i2c->dev.of_node,
 					"maxim,system-power-controller");
 
 	max8907 = devm_kzalloc(&i2c->dev, sizeof(struct max8907), GFP_KERNEL);
drivers/regulator/max8907-regulator.c +5 -6
index e59aa7a3ee546..521825c0adc07 100644
@@ -274,7 +274,6 @@ static inline struct device_node *match_of_node(int index)
 static int max8907_regulator_probe(struct platform_device *pdev)
 {
 	struct max8907 *max8907 = dev_get_drvdata(pdev->dev.parent);
-	struct max8907_platform_data *pdata = dev_get_platdata(max8907->dev);
 	int ret;
 	struct max8907_regulator *pmic;
 	unsigned int val;
@@ -312,10 +311,9 @@ static int max8907_regulator_probe(struct platform_device *pdev)
 		struct regulator_dev *rdev;
 
 		config.dev = pdev->dev.parent;
-		if (pdata)
-			idata = pdata->init_data[i];
-		else
-			idata = match_init_data(i);
+
+		idata = match_init_data(i);
+
 		config.init_data = idata;
 		config.driver_data = pmic;
 		config.regmap = max8907->regmap_gen;
@@ -331,7 +329,8 @@ static int max8907_regulator_probe(struct platform_device *pdev)
 		case MAX8907_BBAT:
 		case MAX8907_SDBY:
 		case MAX8907_VRTC:
-			idata->supply_regulator = mbatt_rail_name;
+			if (idata)
+				idata->supply_regulator = mbatt_rail_name;
 			break;
 		}
 
include/linux/mfd/max8907.h +0 -5
index 4be3c2370e2a4..e222250f0cc1e 100644
@@ -227,11 +227,6 @@ enum {
 	MAX8907_IRQ_RTC_ALARM0,
 };
 
-struct max8907_platform_data {
-	struct regulator_init_data *init_data[MAX8907_NUM_REGULATORS];
-	bool pm_off;
-};
-
 struct regmap_irq_chips_data;
 
 struct max8907 {
Signature · 1 line
2.53.0
#6 lore raw

Re: [PATCH v4 2/4] mfd: max8907: Remove platform_data based probing

Sashiko has reviewed this patch and found no issues.
Quoted 7 lines

There are no in-tree users of this driver, but it supports devicetree based probing, which means external dtb files may exist that work with this.

Remove the unused legacy code and make this a DT-only driver.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#7 lore raw

PATCH v4 3/4 mfd: max8907: Switch to resource-managed versions of helpers

In reply to Svyatoslav Ryhel

Switch to resource-managed versions of regmap_add_irq_chip() and i2c_new_dummy_device(). This involves probe refactoring in order to remove jumps and allows to drop the .remove callback.

---
 drivers/mfd/max8907.c | 127 ++++++++++++++----------------------------
 1 file changed, 43 insertions(+), 84 deletions(-)
drivers/mfd/max8907.c +43 -84
index 363ac80c0593b..2a38e00a10c3b 100644
@@ -182,73 +182,60 @@ static void max8907_power_off(void)
 
 static int max8907_i2c_probe(struct i2c_client *i2c)
 {
+	struct device *dev = &i2c->dev;
 	struct max8907 *max8907;
 	int ret;
-	bool pm_off = of_property_read_bool(i2c->dev.of_node,
+	bool pm_off = of_property_read_bool(dev->of_node,
 					"maxim,system-power-controller");
 
-	max8907 = devm_kzalloc(&i2c->dev, sizeof(struct max8907), GFP_KERNEL);
-	if (!max8907) {
-		ret = -ENOMEM;
-		goto err_alloc_drvdata;
-	}
+	max8907 = devm_kzalloc(dev, sizeof(*max8907), GFP_KERNEL);
+	if (!max8907)
+		return -ENOMEM;
 
-	max8907->dev = &i2c->dev;
+	max8907->dev = dev;
 	max8907->i2c_gen = i2c;
 	i2c_set_clientdata(i2c, max8907);
+
 	max8907->regmap_gen = devm_regmap_init_i2c(i2c,
-						&max8907_regmap_gen_config);
-	if (IS_ERR(max8907->regmap_gen)) {
-		ret = PTR_ERR(max8907->regmap_gen);
-		dev_err(&i2c->dev, "gen regmap init failed: %d\n", ret);
-		goto err_regmap_gen;
-	}
+						   &max8907_regmap_gen_config);
+	if (IS_ERR(max8907->regmap_gen))
+		return dev_err_probe(dev, PTR_ERR(max8907->regmap_gen),
+				     "GEN regmap init failed\n");
 
-	max8907->i2c_rtc = i2c_new_dummy_device(i2c->adapter, MAX8907_RTC_I2C_ADDR);
-	if (IS_ERR(max8907->i2c_rtc)) {
-		ret = PTR_ERR(max8907->i2c_rtc);
-		goto err_dummy_rtc;
-	}
-	i2c_set_clientdata(max8907->i2c_rtc, max8907);
-	max8907->regmap_rtc = devm_regmap_init_i2c(max8907->i2c_rtc,
-						&max8907_regmap_rtc_config);
-	if (IS_ERR(max8907->regmap_rtc)) {
-		ret = PTR_ERR(max8907->regmap_rtc);
-		dev_err(&i2c->dev, "rtc regmap init failed: %d\n", ret);
-		goto err_regmap_rtc;
-	}
+	max8907->i2c_rtc = devm_i2c_new_dummy_device(dev, i2c->adapter, MAX8907_RTC_I2C_ADDR);
+	if (IS_ERR(max8907->i2c_rtc))
+		return PTR_ERR(max8907->i2c_rtc);
 
-	ret = regmap_add_irq_chip(max8907->regmap_gen, max8907->i2c_gen->irq,
-				  IRQF_ONESHOT | IRQF_SHARED,
-				  -1, &max8907_chg_irq_chip,
-				  &max8907->irqc_chg);
-	if (ret != 0) {
-		dev_err(&i2c->dev, "failed to add chg irq chip: %d\n", ret);
-		goto err_irqc_chg;
-	}
-	ret = regmap_add_irq_chip(max8907->regmap_gen, max8907->i2c_gen->irq,
-				  IRQF_ONESHOT | IRQF_SHARED, -1,
-				  &max8907_on_off_irq_chip,
-				  &max8907->irqc_on_off);
-	if (ret != 0) {
-		dev_err(&i2c->dev, "failed to add on off irq chip: %d\n", ret);
-		goto err_irqc_on_off;
-	}
-	ret = regmap_add_irq_chip(max8907->regmap_rtc, max8907->i2c_gen->irq,
-				  IRQF_ONESHOT | IRQF_SHARED, -1,
-				  &max8907_rtc_irq_chip,
-				  &max8907->irqc_rtc);
-	if (ret != 0) {
-		dev_err(&i2c->dev, "failed to add rtc irq chip: %d\n", ret);
-		goto err_irqc_rtc;
-	}
+	i2c_set_clientdata(max8907->i2c_rtc, max8907);
 
-	ret = mfd_add_devices(max8907->dev, -1, max8907_cells,
-			      ARRAY_SIZE(max8907_cells), NULL, 0, NULL);
-	if (ret != 0) {
-		dev_err(&i2c->dev, "failed to add MFD devices %d\n", ret);
-		goto err_add_devices;
-	}
+	max8907->regmap_rtc = devm_regmap_init_i2c(max8907->i2c_rtc,
+						   &max8907_regmap_rtc_config);
+	if (IS_ERR(max8907->regmap_rtc))
+		return dev_err_probe(dev, PTR_ERR(max8907->regmap_rtc),
+				     "RTC regmap init failed\n");
+
+	ret = devm_regmap_add_irq_chip(dev, max8907->regmap_gen, max8907->i2c_gen->irq,
+				       IRQF_ONESHOT | IRQF_SHARED, -1, &max8907_chg_irq_chip,
+				       &max8907->irqc_chg);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to add chg irq chip\n");
+
+	ret = devm_regmap_add_irq_chip(dev, max8907->regmap_gen, max8907->i2c_gen->irq,
+				       IRQF_ONESHOT | IRQF_SHARED, -1, &max8907_on_off_irq_chip,
+				       &max8907->irqc_on_off);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to add on off irq chip\n");
+
+	ret = devm_regmap_add_irq_chip(dev, max8907->regmap_rtc, max8907->i2c_gen->irq,
+				       IRQF_ONESHOT | IRQF_SHARED, -1, &max8907_rtc_irq_chip,
+				       &max8907->irqc_rtc);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to add rtc irq chip\n");
+
+	ret = devm_mfd_add_devices(dev, -1, max8907_cells, ARRAY_SIZE(max8907_cells),
+				   NULL, 0, NULL);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to add MFD devices\n");
 
 	if (pm_off && !pm_power_off) {
 		max8907_pm_off = max8907;
@@ -256,33 +243,6 @@ static int max8907_i2c_probe(struct i2c_client *i2c)
 	}
 
 	return 0;
-
-err_add_devices:
-	regmap_del_irq_chip(max8907->i2c_gen->irq, max8907->irqc_rtc);
-err_irqc_rtc:
-	regmap_del_irq_chip(max8907->i2c_gen->irq, max8907->irqc_on_off);
-err_irqc_on_off:
-	regmap_del_irq_chip(max8907->i2c_gen->irq, max8907->irqc_chg);
-err_irqc_chg:
-err_regmap_rtc:
-	i2c_unregister_device(max8907->i2c_rtc);
-err_dummy_rtc:
-err_regmap_gen:
-err_alloc_drvdata:
-	return ret;
-}
-
-static void max8907_i2c_remove(struct i2c_client *i2c)
-{
-	struct max8907 *max8907 = i2c_get_clientdata(i2c);
-
-	mfd_remove_devices(max8907->dev);
-
-	regmap_del_irq_chip(max8907->i2c_gen->irq, max8907->irqc_rtc);
-	regmap_del_irq_chip(max8907->i2c_gen->irq, max8907->irqc_on_off);
-	regmap_del_irq_chip(max8907->i2c_gen->irq, max8907->irqc_chg);
-
-	i2c_unregister_device(max8907->i2c_rtc);
 }
 
 #ifdef CONFIG_OF
@@ -305,7 +265,6 @@ static struct i2c_driver max8907_i2c_driver = {
 		.of_match_table = of_match_ptr(max8907_of_match),
 	},
 	.probe = max8907_i2c_probe,
-	.remove = max8907_i2c_remove,
 	.id_table = max8907_i2c_id,
 };
 
Signature · 1 line
2.53.0
#8 lore raw

Re: [PATCH v4 3/4] mfd: max8907: Switch to resource-managed versions of helpers

Sashiko has reviewed this patch and found no issues.
Quoted 5 lines

Switch to resource-managed versions of regmap_add_irq_chip() and i2c_new_dummy_device(). This involves probe refactoring in order to remove jumps and allows to drop the .remove callback.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#9 lore raw

PATCH v4 4/4 mfd: max8907: Convert to use device managed poweroff handler

In reply to Svyatoslav Ryhel

Replace the legacy global 'pm_power_off' function pointer assignment with the devm_register_power_off_handler() helper.

---
 drivers/mfd/max8907.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)
drivers/mfd/max8907.c +15 -9
index 2a38e00a10c3b..e282dd82ece69 100644
@@ -15,6 +15,7 @@
 #include <linux/mfd/max8907.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/reboot.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
 
@@ -173,11 +174,17 @@ static const struct regmap_irq_chip max8907_rtc_irq_chip = {
 	.num_irqs = ARRAY_SIZE(max8907_rtc_irqs),
 };
 
-static struct max8907 *max8907_pm_off;
-static void max8907_power_off(void)
+static int max8907_power_off(struct sys_off_data *data)
 {
-	regmap_update_bits(max8907_pm_off->regmap_gen, MAX8907_REG_RESET_CNFG,
-			MAX8907_MASK_POWER_OFF, MAX8907_MASK_POWER_OFF);
+	struct max8907 *max8907 = data->cb_data;
+	int ret;
+
+	ret = regmap_update_bits(max8907->regmap_gen, MAX8907_REG_RESET_CNFG,
+				 MAX8907_MASK_POWER_OFF, MAX8907_MASK_POWER_OFF);
+	if (ret)
+		dev_err(max8907->dev, "failed to power off the device!\n");
+
+	return NOTIFY_DONE;
 }
 
 static int max8907_i2c_probe(struct i2c_client *i2c)
@@ -185,8 +192,6 @@ static int max8907_i2c_probe(struct i2c_client *i2c)
 	struct device *dev = &i2c->dev;
 	struct max8907 *max8907;
 	int ret;
-	bool pm_off = of_property_read_bool(dev->of_node,
-					"maxim,system-power-controller");
 
 	max8907 = devm_kzalloc(dev, sizeof(*max8907), GFP_KERNEL);
 	if (!max8907)
@@ -237,9 +242,10 @@ static int max8907_i2c_probe(struct i2c_client *i2c)
 	if (ret)
 		return dev_err_probe(dev, ret, "Failed to add MFD devices\n");
 
-	if (pm_off && !pm_power_off) {
-		max8907_pm_off = max8907;
-		pm_power_off = max8907_power_off;
+	if (of_device_is_system_power_controller(dev->of_node)) {
+		ret = devm_register_power_off_handler(dev, max8907_power_off, max8907);
+		if (ret)
+			return dev_err_probe(dev, ret, "failed to register power-off handler\n");
 	}
 
 	return 0;
Signature · 1 line
2.53.0
#10 lore raw

Re: [PATCH v4 4/4] mfd: max8907: Convert to use device managed poweroff handler

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] mfd: max8907: max8907_i2c_probe() drops maxim,system-power-controller check --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] mfd: max8907: max8907_i2c_probe() drops maxim,system-power-controller check --

commit 5deb6448298f2829c11e1c8af86067bd08a79d7f
Author: Svyatoslav Ryhel <[email protected]>

mfd: max8907: Convert to use device managed poweroff handler

This commit replaces the global pm_power_off assignment in the max8907 MFD driver with devm_register_power_off_handler().

Quoted 4 lines
drivers/mfd/max8907.c +0 -0
index 2a38e00a10c3b..e282dd82ece69 100644

[ ... ]

Quoted 11 lines
drivers/mfd/max8907.c +0 -2
@@ -185,8 +192,6 @@ static int max8907_i2c_probe(struct i2c_client *i2c)
 	struct device *dev = &i2c->dev;
 	struct max8907 *max8907;
 	int ret;
-	bool pm_off = of_property_read_bool(dev->of_node,
-					"maxim,system-power-controller");
 
 	max8907 = devm_kzalloc(dev, sizeof(*max8907), GFP_KERNEL);
 	if (!max8907)
@@ -237,9 +242,10 @@ static int max8907_i2c_probe(struct i2c_client *i2c)
 	if (ret)

drivers/mfd/max8907.c static int max8907_i2c_probe(struct i2c_client *i2c) · line 249

Quoted 10 lines
drivers/mfd/max8907.c +4 -3
 		return dev_err_probe(dev, ret, "Failed to add MFD devices\n");
 
-	if (pm_off && !pm_power_off) {
-		max8907_pm_off = max8907;
-		pm_power_off = max8907_power_off;
+	if (of_device_is_system_power_controller(dev->of_node)) {
+		ret = devm_register_power_off_handler(dev, max8907_power_off, max8907);
+		if (ret)
+			return dev_err_probe(dev, ret, "failed to register power-off handler\n");
 	}

[Severity: High]
Does replacing the maxim,system-power-controller property check with only of_device_is_system_power_controller() break system power-off on existing DTBs?

In include/linux/of.h, of_device_is_system_power_controller() only checks for the unprefixed property:

static inline bool of_device_is_system_power_controller(const struct device_node *np)

{
	return of_property_read_bool(np, "system-power-controller");
}

In Documentation/devicetree/bindings/regulator/maxim,max8907.yaml (added in commit c254fcc966ae), maxim,system-power-controller is still documented as a deprecated property for backward compatibility alongside system-power-controller:

maxim,system-power-controller:
type: boolean
deprecated: true
description:
Telling whether or not this PMIC is controlling the system power.

system-power-controller: true

Should max8907_i2c_probe() check both of_device_is_system_power_controller(dev->of_node) and of_property_read_bool(dev->of_node, "maxim,system-power-controller") so existing DTBs using the vendor-prefixed property continue to register the power-off handler?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
maintainer
#11 lore raw

Re: [PATCH v4 4/4] mfd: max8907: Convert to use device managed poweroff handler

Quoted 2 lines · On Tue, 27 Oct 2026, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] mfd: max8907: max8907_i2c_probe() drops maxim,system-power-controller check

Did this get an answer?

Quoted 71 lines

commit 5deb6448298f2829c11e1c8af86067bd08a79d7f
Author: Svyatoslav Ryhel <[email protected]>

mfd: max8907: Convert to use device managed poweroff handler

This commit replaces the global pm_power_off assignment in the max8907 MFD driver with devm_register_power_off_handler().

Quoted 4 lines
drivers/mfd/max8907.c +0 -0
index 2a38e00a10c3b..e282dd82ece69 100644

[ ... ]

Quoted 11 lines
drivers/mfd/max8907.c +0 -2
@@ -185,8 +192,6 @@ static int max8907_i2c_probe(struct i2c_client *i2c)
 	struct device *dev = &i2c->dev;
 	struct max8907 *max8907;
 	int ret;
-	bool pm_off = of_property_read_bool(dev->of_node,
-					"maxim,system-power-controller");
 
 	max8907 = devm_kzalloc(dev, sizeof(*max8907), GFP_KERNEL);
 	if (!max8907)
@@ -237,9 +242,10 @@ static int max8907_i2c_probe(struct i2c_client *i2c)
 	if (ret)

drivers/mfd/max8907.c static int max8907_i2c_probe(struct i2c_client *i2c) · line 249

Quoted 10 lines
drivers/mfd/max8907.c +4 -3
 		return dev_err_probe(dev, ret, "Failed to add MFD devices\n");
 
-	if (pm_off && !pm_power_off) {
-		max8907_pm_off = max8907;
-		pm_power_off = max8907_power_off;
+	if (of_device_is_system_power_controller(dev->of_node)) {
+		ret = devm_register_power_off_handler(dev, max8907_power_off, max8907);
+		if (ret)
+			return dev_err_probe(dev, ret, "failed to register power-off handler\n");
 	}

[Severity: High]
Does replacing the maxim,system-power-controller property check with only of_device_is_system_power_controller() break system power-off on existing DTBs?

In include/linux/of.h, of_device_is_system_power_controller() only checks for the unprefixed property:

static inline bool of_device_is_system_power_controller(const struct device_node *np)

{
	return of_property_read_bool(np, "system-power-controller");
}

In Documentation/devicetree/bindings/regulator/maxim,max8907.yaml (added in commit c254fcc966ae), maxim,system-power-controller is still documented as a deprecated property for backward compatibility alongside system-power-controller:

maxim,system-power-controller:
type: boolean
deprecated: true
description:
Telling whether or not this PMIC is controlling the system power.

system-power-controller: true

Should max8907_i2c_probe() check both of_device_is_system_power_controller(dev->of_node) and of_property_read_bool(dev->of_node, "maxim,system-power-controller") so existing DTBs using the vendor-prefixed property continue to register the power-off handler?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Signature · 1 line
Lee Jones
#12 lore raw

Re: [PATCH v4 4/4] mfd: max8907: Convert to use device managed poweroff handler

ср, 4 лист. 2026 р. о 19:55 Lee Jones <[email protected]> пише:

Quoted 8 lines · On Tue, 27 Oct 2026, [email protected] wrote:
Quoted 3 lines

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] mfd: max8907: max8907_i2c_probe() drops maxim,system-power-controller check

Did this get an answer?

There are no in kernel users of this property and pmic in general, and iirc never were. Pmic was designed for Nvidia Tegra devices. I have a few devices with this pmic and I am planning to upstarem them so driver is not abandoned. Obviously system-power-controller will be used in those new trees. The maxim,system-power-controller check can be dropped I suppose.

Quoted 74 lines
Quoted 63 lines

commit 5deb6448298f2829c11e1c8af86067bd08a79d7f
Author: Svyatoslav Ryhel <[email protected]>

mfd: max8907: Convert to use device managed poweroff handler

This commit replaces the global pm_power_off assignment in the max8907 MFD driver with devm_register_power_off_handler().

Quoted 4 lines
drivers/mfd/max8907.c +0 -0
index 2a38e00a10c3b..e282dd82ece69 100644

[ ... ]

Quoted 11 lines
drivers/mfd/max8907.c +0 -2
@@ -185,8 +192,6 @@ static int max8907_i2c_probe(struct i2c_client *i2c)
    struct device *dev = &i2c->dev;
    struct max8907 *max8907;
    int ret;
-   bool pm_off = of_property_read_bool(dev->of_node,
-                                   "maxim,system-power-controller");
 
    max8907 = devm_kzalloc(dev, sizeof(*max8907), GFP_KERNEL);
    if (!max8907)
@@ -237,9 +242,10 @@ static int max8907_i2c_probe(struct i2c_client *i2c)
    if (ret)

drivers/mfd/max8907.c static int max8907_i2c_probe(struct i2c_client *i2c) · line 249

Quoted 10 lines
drivers/mfd/max8907.c +4 -3
            return dev_err_probe(dev, ret, "Failed to add MFD devices\n");
 
-   if (pm_off && !pm_power_off) {
-           max8907_pm_off = max8907;
-           pm_power_off = max8907_power_off;
+   if (of_device_is_system_power_controller(dev->of_node)) {
+           ret = devm_register_power_off_handler(dev, max8907_power_off, max8907);
+           if (ret)
+                   return dev_err_probe(dev, ret, "failed to register power-off handler\n");
    }

[Severity: High]
Does replacing the maxim,system-power-controller property check with only of_device_is_system_power_controller() break system power-off on existing DTBs?

In include/linux/of.h, of_device_is_system_power_controller() only checks for the unprefixed property:

static inline bool of_device_is_system_power_controller(const struct device_node *np)

{
      return of_property_read_bool(np, "system-power-controller");
}

In Documentation/devicetree/bindings/regulator/maxim,max8907.yaml (added in commit c254fcc966ae), maxim,system-power-controller is still documented as a deprecated property for backward compatibility alongside system-power-controller:

maxim,system-power-controller:
type: boolean
deprecated: true
description:
Telling whether or not this PMIC is controlling the system power.

system-power-controller: true

Quoted 8 lines

Should max8907_i2c_probe() check both of_device_is_system_power_controller(dev->of_node) and of_property_read_bool(dev->of_node, "maxim,system-power-controller") so existing DTBs using the vendor-prefixed property continue to register the power-off handler?

--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4

--
Lee Jones