devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] hwmon: (pmbus) Add support for MPS multi-phase mp2869a/mp29612a controllers
@ 2025-06-24  7:41 tzuhao.wtmh
  2025-06-24  7:41 ` [PATCH 2/2] dt-bindings: trivial-devices: Add mp2869a/mp29612a device entry tzuhao.wtmh
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: tzuhao.wtmh @ 2025-06-24  7:41 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jean Delvare,
	Guenter Roeck, Jonathan Corbet, Jonathan Cameron, Naresh Solanki,
	Rodrigo Gobbi, Michal Simek, Fabio Estevam, Henry Wu,
	Grant Peltier, Laurent Pinchart, Cedric Encarnacion,
	Kim Seer Paller, Leo Yang, Ninad Palsule, Alex Vdovydchenko,
	John Erasmus Mari Geronimo, Nuno Sa, Jerome Brunet, Noah Wang,
	Mariel Tinaco, devicetree, linux-kernel, linux-hwmon, linux-doc

From: Henry Wu <Henry_Wu@quantatw.com>

Add support for the mp2869a and mp29612a controllers from Monolithic Power
Systems, Inc. (MPS). These are dual-loop, digital, multi-phase modulation
controllers.

Signed-off-by: Henry Wu <Henry_Wu@quantatw.com>
---
 Documentation/hwmon/index.rst   |   1 +
 Documentation/hwmon/mp2869a.rst |  86 +++++++++
 drivers/hwmon/pmbus/Kconfig     |  10 ++
 drivers/hwmon/pmbus/Makefile    |   1 +
 drivers/hwmon/pmbus/mp2869a.c   | 299 ++++++++++++++++++++++++++++++++
 5 files changed, 397 insertions(+)
 create mode 100644 Documentation/hwmon/mp2869a.rst
 create mode 100644 drivers/hwmon/pmbus/mp2869a.c

diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
index b45bfb4ebf30..10bf4bd77f7b 100644
--- a/Documentation/hwmon/index.rst
+++ b/Documentation/hwmon/index.rst
@@ -172,6 +172,7 @@ Hardware Monitoring Kernel Drivers
    menf21bmc
    mlxreg-fan
    mp2856
+   mp2869a
    mp2888
    mp2891
    mp2975
diff --git a/Documentation/hwmon/mp2869a.rst b/Documentation/hwmon/mp2869a.rst
new file mode 100644
index 000000000000..a98ccb3d630d
--- /dev/null
+++ b/Documentation/hwmon/mp2869a.rst
@@ -0,0 +1,86 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+Kernel driver mp2896a
+=====================
+
+Supported chips:
+
+  * MPS MP2896A
+
+    Prefix: 'mp2896a'
+
+  * MPS MP29612A
+
+    Prefix: 'mp29612a'
+
+Author:
+
+    Henry Wu <Henry_WU@quantatw.com>
+
+Description
+-----------
+
+This driver implements support for Monolithic Power Systems, Inc. (MPS)
+MP2896A, a digital, multi-phase voltage regulator controller with PMBus interface.
+
+This device:
+
+- Supports up to two power rails.
+- Supports multiple PMBus pages for telemetry and configuration.
+- Supports VOUT readout in **VID format only** (no support for direct format).
+- Supports AMD SVI3 VID protocol with 5-mV/LSB resolution (if applicable).
+- Uses vendor-specific registers for VOUT scaling and phase configuration.
+
+Device supports:
+
+- SVID interface.
+- AVSBus interface.
+
+Device compliant with:
+
+- PMBus rev 1.3 interface.
+
+Sysfs Interface
+---------------
+
+The driver provides the following sysfs attributes:
+
+**Current measurements:**
+
+- Index 1: "iin"
+- Indexes 2, 3: "iout"
+
+**curr[1-3]_alarm**
+**curr[1-3]_input**
+**curr[1-3]_label**
+
+**Voltage measurements:**
+
+- Index 1: "vin"
+- Indexes 2, 3: "vout"
+
+**in[1-3]_crit**
+**in[1-3]_crit_alarm**
+**in[1-3]_input**
+**in[1-3]_label**
+**in[1-3]_lcrit**
+**in[1-3]_lcrit_alarm**
+
+**Power measurements:**
+
+- Index 1: "pin"
+- Indexes 2, 3: "pout"
+
+**power[1-3]_alarm**
+**power[1-3]_input**
+**power[1-3]_label**
+
+**Temperature measurements:**
+
+**temp[1-2]_crit**
+**temp[1-2]_crit_alarm**
+**temp[1-2]_input**
+**temp[1-2]_max**
+**temp[1-2]_max_alarm**
+
+
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index 441f984a859d..93b558761cc6 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -364,6 +364,16 @@ config SENSORS_MP2856
 	  This driver can also be built as a module. If so, the module will
 	  be called mp2856.
 
+config SENSORS_MP2869A
+	tristate "MP2869A PMBus sensor"
+	depends on I2C && PMBUS
+	help
+	  If you say yes here you get support for the MPS MP2869A MP29612A
+	  voltage regulator via the PMBus interface.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called mp2869a.
+
 config SENSORS_MP2888
 	tristate "MPS MP2888"
 	help
diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
index 29cd8a3317d2..42087d0dedbc 100644
--- a/drivers/hwmon/pmbus/Makefile
+++ b/drivers/hwmon/pmbus/Makefile
@@ -37,6 +37,7 @@ obj-$(CONFIG_SENSORS_MAX31785)	+= max31785.o
 obj-$(CONFIG_SENSORS_MAX34440)	+= max34440.o
 obj-$(CONFIG_SENSORS_MAX8688)	+= max8688.o
 obj-$(CONFIG_SENSORS_MP2856)	+= mp2856.o
+obj-$(CONFIG_SENSORS_MP2869A)   += mp2869a.o
 obj-$(CONFIG_SENSORS_MP2888)	+= mp2888.o
 obj-$(CONFIG_SENSORS_MP2891)	+= mp2891.o
 obj-$(CONFIG_SENSORS_MP2975)	+= mp2975.o
diff --git a/drivers/hwmon/pmbus/mp2869a.c b/drivers/hwmon/pmbus/mp2869a.c
new file mode 100644
index 000000000000..7fa03cad1953
--- /dev/null
+++ b/drivers/hwmon/pmbus/mp2869a.c
@@ -0,0 +1,299 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Hardware monitoring driver for MP2856A/MP29612A
+ * Monolithic Power Systems VR Controller
+ *
+ * Copyright (C) 2023 Quanta Computer lnc.
+ */
+
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/pmbus.h>
+#include "pmbus.h"
+
+/* Vendor specific registers. */
+#define MP2869A_VOUT_MODE		     0x20
+#define MP2869A_VOUT_MODE_MASK       GENMASK(7, 5)
+#define MP2869A_VOUT_MODE_VID        (0 << 5)
+
+
+#define MP2869A_READ_VOUT			 0x8b
+
+#define MP2869A_MFR_VOUT_SCALE_LOOP  0x29
+#define MP2869A_VID_RES_MASK         GENMASK(12, 10)
+#define MP2869A_VOUT_SCALE_MASK      GENMASK(7, 0)
+
+#define MP2869A_MAX_PHASE_RAIL1		 16
+#define MP2869A_MAX_PHASE_RAIL2		 8
+#define MP29612A_MAX_PHASE_RAIL1	 12
+#define MP29612A_MAX_PHASE_RAIL2	 6
+
+#define MP2869A_PAGE_NUM			 2
+#define MP29612A_PAGE_NUM			 2
+
+enum chips { mp2869a = 1, mp29612a };
+
+static const int mp2869a_max_phases[][MP2869A_PAGE_NUM] = {
+	[mp2869a] = { MP2869A_MAX_PHASE_RAIL1, MP2869A_MAX_PHASE_RAIL2 },
+	[mp29612a] = { MP29612A_MAX_PHASE_RAIL1, MP29612A_MAX_PHASE_RAIL2},
+};
+
+static const struct i2c_device_id mp2869a_id[] = {
+	{ "mp2869a", mp2869a },
+	{ "mp29612a", mp29612a },
+	{}
+};
+
+MODULE_DEVICE_TABLE(i2c, mp2869a_id);
+
+struct MP2869A_data {
+	struct pmbus_driver_info info;
+	int vout_format[MP2869A_PAGE_NUM];
+	int curr_sense_gain[MP2869A_PAGE_NUM];
+	int max_phases[MP2869A_PAGE_NUM];
+	enum chips chip_id;
+};
+
+#define to_MP2869A_data(x)	container_of(x, struct MP2869A_data, info)
+
+static int
+MP2869A_read_word_helper(struct i2c_client *client, int page, int phase, u8 reg,
+	u16 mask)
+{
+	int ret = pmbus_read_word_data(client, page, phase, reg);
+
+	return (ret > 0) ? ret & mask : ret;
+}
+
+struct mp2869a_vout_info {
+	int vid_step_uv;
+	int vdiff_gain_ratio;
+};
+
+static int
+MP2869A_read_vid_and_scale(struct i2c_client *client, struct MP2869A_data *data,
+	int page, int phase,
+	struct mp2869a_vout_info *out)
+{
+	int ret;
+	u16 reg_val;
+	u8 vid_sel, vscale;
+
+	ret = pmbus_read_word_data(client, page, phase,
+		MP2869A_MFR_VOUT_SCALE_LOOP);
+	if (ret < 0)
+		return ret;
+
+	reg_val = (u16)ret;
+
+	/* Analyze VID Step Resolution(bits 12:10) */
+	vid_sel = (reg_val >> 10) & 0x7;
+	switch (vid_sel) {
+	case 0b000:
+		out->vid_step_uv = 6250;
+		break;
+	case 0b001:
+		out->vid_step_uv = 5000;
+		break;
+	case 0b010:
+		out->vid_step_uv = 2500;
+		break;
+	case 0b011:
+		out->vid_step_uv = 2000;
+		break;
+	case 0b100:
+		out->vid_step_uv = 1000;
+		break;
+	case 0b101:
+		out->vid_step_uv = 3906;
+		break; // 1000000 / 256
+	case 0b110:
+		out->vid_step_uv = 1953;
+		break; // 1000000 / 512
+	case 0b111:
+		out->vid_step_uv = 977;
+		break; // 1000000 / 1024
+	default:
+		return -EINVAL;
+	}
+
+	/* Analyze VOUT_SCALE_LOOP(bits 7:0) */
+	vscale = reg_val & 0xff;
+	if (vscale == 0)
+		return -EINVAL;
+	// Store as "magnification * 1000" to avoid floating point
+	out->vdiff_gain_ratio = 32 * 1000 / vscale;
+
+	return 0;
+}
+
+static int
+MP2869A_read_vout(struct i2c_client *client, struct MP2869A_data *data,
+	int page, int phase, u8 reg)
+{
+	int ret;
+	int raw;
+	struct mp2869a_vout_info vout_info;
+
+    raw = MP2869A_read_word_helper(client, page, phase, reg, GENMASK(11, 0));
+    if (raw < 0)
+		return raw;
+
+    ret = MP2869A_read_vid_and_scale(client, data, page, phase, &vout_info);
+    if (ret < 0)
+		return ret;
+
+	int m = 1;
+	int R = 0;
+	int step = vout_info.vid_step_uv;
+
+	// Let step = 10^R / m
+	while (step % 10 == 0 && R > -6) {
+		step /= 10;
+		R--;
+	}
+	m = 1000000 / vout_info.vid_step_uv;  // approximate if step ≠ 1mV, 5mV, etc
+
+	data->info.m[PSC_VOLTAGE_OUT] = m;
+	data->info.R[PSC_VOLTAGE_OUT] = R+3;
+	data->info.b[PSC_VOLTAGE_OUT] = 0;
+
+    return raw;
+}
+
+static int
+MP2869A_read_word_data(struct i2c_client *client, int page,
+	int phase, int reg)
+{
+	const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
+	struct MP2869A_data *data = to_MP2869A_data(info);
+	int ret;
+
+	switch (reg) {
+	case PMBUS_READ_VOUT:
+		ret = MP2869A_read_vout(client, data, page, phase, reg);
+		break;
+	default:
+		return -ENODATA;
+	}
+
+	return ret;
+}
+
+static int
+MP2869A_read_byte_data(struct i2c_client *client, int page, int reg)
+{
+	switch (reg) {
+	case PMBUS_VOUT_MODE:
+		/* Enforce VOUT direct format. */
+		return PB_VOUT_MODE_DIRECT;
+	default:
+		return -ENODATA;
+	}
+}
+
+static int
+MP2869A_identify_vout_format(struct i2c_client *client,
+			    struct MP2869A_data *data)
+{
+	int i, ret;
+
+	for (i = 0; i < data->info.pages; i++) {
+		ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, i);
+		if (ret < 0)
+			return ret;
+
+		ret = i2c_smbus_read_word_data(client, MP2869A_VOUT_MODE);
+		if (ret < 0)
+			return ret;
+
+		switch (ret & MP2869A_VOUT_MODE_MASK) {
+		case MP2869A_VOUT_MODE_VID:
+			data->vout_format[i] = vid;
+			break;
+		default:
+		return -EINVAL;
+		}
+		}
+	return 0;
+}
+
+static struct pmbus_driver_info MP2869A_info = {
+	.pages = MP2869A_PAGE_NUM,
+	.format[PSC_VOLTAGE_IN] = linear,
+	.format[PSC_VOLTAGE_OUT] = direct,
+	.format[PSC_TEMPERATURE] = linear,
+	.format[PSC_CURRENT_IN] = linear,
+	.format[PSC_CURRENT_OUT] = linear,
+	.format[PSC_POWER] = linear,
+	.m[PSC_VOLTAGE_OUT] = 1,
+	.b[PSC_VOLTAGE_OUT] = 0,
+	.R[PSC_VOLTAGE_OUT] = -3,
+	.func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
+		PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
+		PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_POUT |
+		PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT,
+	.func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_IOUT |
+		PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT | PMBUS_HAVE_TEMP,
+	.read_byte_data = MP2869A_read_byte_data,
+	.read_word_data = MP2869A_read_word_data,
+};
+
+static int mp2869a_probe(struct i2c_client *client)
+{
+	struct pmbus_driver_info *info;
+	struct MP2869A_data *data;
+	int ret;
+
+	data = devm_kzalloc(&client->dev, sizeof(struct MP2869A_data),
+		GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	data->chip_id = (enum chips)(uintptr_t)i2c_get_match_data(client);
+
+	memcpy(data->max_phases, mp2869a_max_phases[data->chip_id],
+		sizeof(data->max_phases));
+
+	memcpy(&data->info, &MP2869A_info, sizeof(*info));
+	info = &data->info;
+
+
+	/* Identify vout format. */
+	ret = MP2869A_identify_vout_format(client, data);
+	if (ret)
+		return ret;
+
+	/* set the device to page 0 */
+	i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0);
+
+	return pmbus_do_probe(client, info);
+}
+
+static const struct of_device_id __maybe_unused mp2869a_of_match[] = {
+	{ .compatible = "mps,mp2869a", .data = (void *)mp2869a },
+	{ .compatible = "mps,mp29612a", .data = (void *)mp29612a},
+	{}
+};
+
+MODULE_DEVICE_TABLE(of, mp2869a_of_match);
+
+static struct i2c_driver mp2869a_driver = {
+	.driver = {
+		.name = "mp2869a",
+		.of_match_table = mp2869a_of_match,
+	},
+	.probe = mp2869a_probe,
+	.id_table = mp2869a_id,
+};
+
+module_i2c_driver(mp2869a_driver);
+
+
+MODULE_AUTHOR("Henry Wu <Henry_WU@quantatw.com>");
+MODULE_DESCRIPTION("PMBus driver for MPS MP2869A/MP29612A device");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(PMBUS);
-- 
2.43.0


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

* [PATCH 2/2] dt-bindings: trivial-devices: Add mp2869a/mp29612a device entry
  2025-06-24  7:41 [PATCH 1/2] hwmon: (pmbus) Add support for MPS multi-phase mp2869a/mp29612a controllers tzuhao.wtmh
@ 2025-06-24  7:41 ` tzuhao.wtmh
  2025-06-24  7:44   ` Krzysztof Kozlowski
  2025-06-24  7:48 ` [PATCH 1/2] hwmon: (pmbus) Add support for MPS multi-phase mp2869a/mp29612a controllers Krzysztof Kozlowski
  2025-06-24 20:10 ` kernel test robot
  2 siblings, 1 reply; 8+ messages in thread
From: tzuhao.wtmh @ 2025-06-24  7:41 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jean Delvare,
	Guenter Roeck, Jonathan Corbet, Jonathan Cameron, Naresh Solanki,
	Fabio Estevam, Michal Simek, Rodrigo Gobbi, Henry Wu,
	Grant Peltier, Laurent Pinchart, Cedric Encarnacion,
	John Erasmus Mari Geronimo, Noah Wang, Ninad Palsule,
	Jerome Brunet, Leo Yang, Mariel Tinaco, Alex Vdovydchenko,
	Kim Seer Paller, Nuno Sa, Thomas Weißschuh, devicetree,
	linux-kernel, linux-hwmon, linux-doc

From: Henry Wu <Henry_Wu@quantatw.com>

Add trivial-devices binding for mp2869a/mp29612a to enable automatic matching
in device tree.

Signed-off-by: Henry Wu <Henry_Wu@quantatw.com>
---
 Documentation/devicetree/bindings/trivial-devices.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml
index 27930708ccd5..e9a3a6f2c59e 100644
--- a/Documentation/devicetree/bindings/trivial-devices.yaml
+++ b/Documentation/devicetree/bindings/trivial-devices.yaml
@@ -287,8 +287,12 @@ properties:
           - mps,mp2857
             # Monolithic Power Systems Inc. multi-phase controller mp2888
           - mps,mp2888
+            # Monolithic Power Systems Inc. multi-phase controller mp2869a
+          - mps,mp2869a
             # Monolithic Power Systems Inc. multi-phase controller mp2891
           - mps,mp2891
+            # Monolithic Power Systems Inc. multi-phase controller mp29612a
+          - mps,mp29612a
             # Monolithic Power Systems Inc. multi-phase controller mp2993
           - mps,mp2993
             # Monolithic Power Systems Inc. multi-phase hot-swap controller mp5920
-- 
2.43.0


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

* Re: [PATCH 2/2] dt-bindings: trivial-devices: Add mp2869a/mp29612a device entry
  2025-06-24  7:41 ` [PATCH 2/2] dt-bindings: trivial-devices: Add mp2869a/mp29612a device entry tzuhao.wtmh
@ 2025-06-24  7:44   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2025-06-24  7:44 UTC (permalink / raw)
  To: tzuhao.wtmh, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jean Delvare, Guenter Roeck, Jonathan Corbet, Jonathan Cameron,
	Naresh Solanki, Fabio Estevam, Michal Simek, Rodrigo Gobbi,
	Henry Wu, Grant Peltier, Laurent Pinchart, Cedric Encarnacion,
	John Erasmus Mari Geronimo, Noah Wang, Ninad Palsule,
	Jerome Brunet, Leo Yang, Mariel Tinaco, Alex Vdovydchenko,
	Kim Seer Paller, Nuno Sa, Thomas Weißschuh, devicetree,
	linux-kernel, linux-hwmon, linux-doc

On 24/06/2025 09:41, tzuhao.wtmh@gmail.com wrote:
> From: Henry Wu <Henry_Wu@quantatw.com>
> 
> Add trivial-devices binding for mp2869a/mp29612a to enable automatic matching
> in device tree.

Drop "enable automatic ...." - this is not what is being done here.
Instead describe the hardware.

Please organize the patch documenting compatible (DT bindings) before
their user.
See also:
https://elixir.bootlin.com/linux/v6.14-rc6/source/Documentation/devicetree/bindings/submitting-patches.rst#L46

> 
> Signed-off-by: Henry Wu <Henry_Wu@quantatw.com>


> ---
>  Documentation/devicetree/bindings/trivial-devices.yaml | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml
> index 27930708ccd5..e9a3a6f2c59e 100644
> --- a/Documentation/devicetree/bindings/trivial-devices.yaml
> +++ b/Documentation/devicetree/bindings/trivial-devices.yaml
> @@ -287,8 +287,12 @@ properties:
>            - mps,mp2857
>              # Monolithic Power Systems Inc. multi-phase controller mp2888
>            - mps,mp2888
> +            # Monolithic Power Systems Inc. multi-phase controller mp2869a
> +          - mps,mp2869a

69 < 88


Best regards,
Krzysztof

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

* Re: [PATCH 1/2] hwmon: (pmbus) Add support for MPS multi-phase mp2869a/mp29612a controllers
  2025-06-24  7:41 [PATCH 1/2] hwmon: (pmbus) Add support for MPS multi-phase mp2869a/mp29612a controllers tzuhao.wtmh
  2025-06-24  7:41 ` [PATCH 2/2] dt-bindings: trivial-devices: Add mp2869a/mp29612a device entry tzuhao.wtmh
@ 2025-06-24  7:48 ` Krzysztof Kozlowski
  2025-06-25  6:31   ` 吳梓豪
  2025-06-24 20:10 ` kernel test robot
  2 siblings, 1 reply; 8+ messages in thread
From: Krzysztof Kozlowski @ 2025-06-24  7:48 UTC (permalink / raw)
  To: tzuhao.wtmh, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jean Delvare, Guenter Roeck, Jonathan Corbet, Jonathan Cameron,
	Naresh Solanki, Rodrigo Gobbi, Michal Simek, Fabio Estevam,
	Henry Wu, Grant Peltier, Laurent Pinchart, Cedric Encarnacion,
	Kim Seer Paller, Leo Yang, Ninad Palsule, Alex Vdovydchenko,
	John Erasmus Mari Geronimo, Nuno Sa, Jerome Brunet, Noah Wang,
	Mariel Tinaco, devicetree, linux-kernel, linux-hwmon, linux-doc

On 24/06/2025 09:41, tzuhao.wtmh@gmail.com wrote:
> +static int
> +MP2869A_read_byte_data(struct i2c_client *client, int page, int reg)
> +{
> +	switch (reg) {
> +	case PMBUS_VOUT_MODE:
> +		/* Enforce VOUT direct format. */
> +		return PB_VOUT_MODE_DIRECT;
> +	default:
> +		return -ENODATA;
> +	}
> +}
> +
> +static int
> +MP2869A_identify_vout_format(struct i2c_client *client,

Use Linux coding style, so lowercase for variables, types and functions.
Everywhere (except when coding style tells you different, so please read
it).

> +			    struct MP2869A_data *data)
> +{
> +	int i, ret;
> +
> +	for (i = 0; i < data->info.pages; i++) {
> +		ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, i);
> +		if (ret < 0)
> +			return ret;
> +
> +		ret = i2c_smbus_read_word_data(client, MP2869A_VOUT_MODE);
> +		if (ret < 0)
> +			return ret;
> +
> +		switch (ret & MP2869A_VOUT_MODE_MASK) {
> +		case MP2869A_VOUT_MODE_VID:
> +			data->vout_format[i] = vid;
> +			break;
> +		default:
> +		return -EINVAL;
> +		}
> +		}

Messed indentation in multiple places.

> +	return 0;
> +}
> +
> +static struct pmbus_driver_info MP2869A_info = {

This is const.

> +	.pages = MP2869A_PAGE_NUM,
> +	.format[PSC_VOLTAGE_IN] = linear,
> +	.format[PSC_VOLTAGE_OUT] = direct,
> +	.format[PSC_TEMPERATURE] = linear,
> +	.format[PSC_CURRENT_IN] = linear,
> +	.format[PSC_CURRENT_OUT] = linear,
> +	.format[PSC_POWER] = linear,
> +	.m[PSC_VOLTAGE_OUT] = 1,
> +	.b[PSC_VOLTAGE_OUT] = 0,
> +	.R[PSC_VOLTAGE_OUT] = -3,
> +	.func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
> +		PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
> +		PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_POUT |
> +		PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT,
> +	.func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_IOUT |
> +		PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT | PMBUS_HAVE_TEMP,
> +	.read_byte_data = MP2869A_read_byte_data,
> +	.read_word_data = MP2869A_read_word_data,
> +};
> +
> +static int mp2869a_probe(struct i2c_client *client)
> +{
> +	struct pmbus_driver_info *info;
> +	struct MP2869A_data *data;
> +	int ret;
> +
> +	data = devm_kzalloc(&client->dev, sizeof(struct MP2869A_data),

sizeof(*)

> +		GFP_KERNEL);

Misaligned. Run checkpatch --srtict

> +	if (!data)
> +		return -ENOMEM;
> +
> +	data->chip_id = (enum chips)(uintptr_t)i2c_get_match_data(client);

These are just wrong or redundant casts. You need only one cast -
kernel_ulong_t

> +
> +	memcpy(data->max_phases, mp2869a_max_phases[data->chip_id],
> +		sizeof(data->max_phases));

Why you cannot just store the pointer?

> +
> +	memcpy(&data->info, &MP2869A_info, sizeof(*info));

Why you cannot just store the pointer?

> +	info = &data->info;
> +
> +

One blank line, not two

> +	/* Identify vout format. */
> +	ret = MP2869A_identify_vout_format(client, data);
> +	if (ret)
> +		return ret;
> +
> +	/* set the device to page 0 */
> +	i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0);
> +
> +	return pmbus_do_probe(client, info);
> +}
> +
> +static const struct of_device_id __maybe_unused mp2869a_of_match[] = {
> +	{ .compatible = "mps,mp2869a", .data = (void *)mp2869a },
> +	{ .compatible = "mps,mp29612a", .data = (void *)mp29612a},
> +	{}
> +};
> +
> +MODULE_DEVICE_TABLE(of, mp2869a_of_match);
> +
> +static struct i2c_driver mp2869a_driver = {
> +	.driver = {
> +		.name = "mp2869a",
> +		.of_match_table = mp2869a_of_match,
> +	},
> +	.probe = mp2869a_probe,
> +	.id_table = mp2869a_id,
> +};
> +
> +module_i2c_driver(mp2869a_driver);
> +
> +

One blank line, not two. This applies everywhere.

> +MODULE_AUTHOR("Henry Wu <Henry_WU@quantatw.com>");
> +MODULE_DESCRIPTION("PMBus driver for MPS MP2869A/MP29612A device");
> +MODULE_LICENSE("GPL");
> +MODULE_IMPORT_NS(PMBUS);


Best regards,
Krzysztof

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

* Re: [PATCH 1/2] hwmon: (pmbus) Add support for MPS multi-phase mp2869a/mp29612a controllers
  2025-06-24  7:41 [PATCH 1/2] hwmon: (pmbus) Add support for MPS multi-phase mp2869a/mp29612a controllers tzuhao.wtmh
  2025-06-24  7:41 ` [PATCH 2/2] dt-bindings: trivial-devices: Add mp2869a/mp29612a device entry tzuhao.wtmh
  2025-06-24  7:48 ` [PATCH 1/2] hwmon: (pmbus) Add support for MPS multi-phase mp2869a/mp29612a controllers Krzysztof Kozlowski
@ 2025-06-24 20:10 ` kernel test robot
  2 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2025-06-24 20:10 UTC (permalink / raw)
  To: tzuhao.wtmh, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jean Delvare, Guenter Roeck, Jonathan Corbet, Jonathan Cameron,
	Naresh Solanki, Rodrigo Gobbi, Michal Simek, Fabio Estevam,
	Henry Wu, Grant Peltier, Laurent Pinchart, Cedric Encarnacion,
	Kim Seer Paller, Leo Yang, Ninad Palsule, Alex Vdovydchenko,
	John Erasmus Mari Geronimo, Nuno Sa, Jerome Brunet, Noah Wang,
	Mariel Tinaco, devicetree, linux-kernel, linux-hwmon, linux-doc
  Cc: oe-kbuild-all

Hi,

kernel test robot noticed the following build errors:

[auto build test ERROR on groeck-staging/hwmon-next]
[also build test ERROR on robh/for-next krzk-dt/for-next linus/master v6.16-rc3 next-20250624]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/tzuhao-wtmh-gmail-com/dt-bindings-trivial-devices-Add-mp2869a-mp29612a-device-entry/20250624-154444
base:   https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
patch link:    https://lore.kernel.org/r/20250624074156.291176-1-Henry_Wu%40quantatw.tw
patch subject: [PATCH 1/2] hwmon: (pmbus) Add support for MPS multi-phase mp2869a/mp29612a controllers
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20250625/202506250448.jwRL4o9n-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250625/202506250448.jwRL4o9n-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202506250448.jwRL4o9n-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from include/linux/module.h:22,
                    from include/linux/device/driver.h:21,
                    from include/linux/device.h:32,
                    from include/linux/acpi.h:14,
                    from include/linux/i2c.h:13,
                    from drivers/hwmon/pmbus/mp2869a.c:10:
>> drivers/hwmon/pmbus/mp2869a.c:299:18: error: expected ',' or ';' before 'PMBUS'
     299 | MODULE_IMPORT_NS(PMBUS);
         |                  ^~~~~
   include/linux/moduleparam.h:26:61: note: in definition of macro '__MODULE_INFO'
      26 |                 = __MODULE_INFO_PREFIX __stringify(tag) "=" info
         |                                                             ^~~~
   include/linux/module.h:301:33: note: in expansion of macro 'MODULE_INFO'
     301 | #define MODULE_IMPORT_NS(ns)    MODULE_INFO(import_ns, ns)
         |                                 ^~~~~~~~~~~
   drivers/hwmon/pmbus/mp2869a.c:299:1: note: in expansion of macro 'MODULE_IMPORT_NS'
     299 | MODULE_IMPORT_NS(PMBUS);
         | ^~~~~~~~~~~~~~~~


vim +299 drivers/hwmon/pmbus/mp2869a.c

   294	
   295	
   296	MODULE_AUTHOR("Henry Wu <Henry_WU@quantatw.com>");
   297	MODULE_DESCRIPTION("PMBus driver for MPS MP2869A/MP29612A device");
   298	MODULE_LICENSE("GPL");
 > 299	MODULE_IMPORT_NS(PMBUS);

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

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

* Re: [PATCH 1/2] hwmon: (pmbus) Add support for MPS multi-phase mp2869a/mp29612a controllers
  2025-06-24  7:48 ` [PATCH 1/2] hwmon: (pmbus) Add support for MPS multi-phase mp2869a/mp29612a controllers Krzysztof Kozlowski
@ 2025-06-25  6:31   ` 吳梓豪
  2025-06-25  8:08     ` Krzysztof Kozlowski
  2025-06-25 13:11     ` Guenter Roeck
  0 siblings, 2 replies; 8+ messages in thread
From: 吳梓豪 @ 2025-06-25  6:31 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jean Delvare,
	Guenter Roeck, Jonathan Corbet, Jonathan Cameron, Naresh Solanki,
	Rodrigo Gobbi, Michal Simek, Fabio Estevam, Henry Wu,
	Grant Peltier, Laurent Pinchart, Cedric Encarnacion,
	Kim Seer Paller, Leo Yang, Ninad Palsule, Alex Vdovydchenko,
	John Erasmus Mari Geronimo, Nuno Sa, Jerome Brunet, Noah Wang,
	Mariel Tinaco, devicetree, linux-kernel, linux-hwmon, linux-doc

Krzysztof Kozlowski <krzk@kernel.org> 於 2025年6月24日 週二 下午3:48寫道:
>
> On 24/06/2025 09:41, tzuhao.wtmh@gmail.com wrote:
> > +static int
> > +MP2869A_read_byte_data(struct i2c_client *client, int page, int reg)
> > +{
> > +     switch (reg) {
> > +     case PMBUS_VOUT_MODE:
> > +             /* Enforce VOUT direct format. */
> > +             return PB_VOUT_MODE_DIRECT;
> > +     default:
> > +             return -ENODATA;
> > +     }
> > +}
> > +
> > +static int
> > +MP2869A_identify_vout_format(struct i2c_client *client,
>
> Use Linux coding style, so lowercase for variables, types and functions.
> Everywhere (except when coding style tells you different, so please read
> it).
>
> > +                         struct MP2869A_data *data)
> > +{
> > +     int i, ret;
> > +
> > +     for (i = 0; i < data->info.pages; i++) {
> > +             ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, i);
> > +             if (ret < 0)
> > +                     return ret;
> > +
> > +             ret = i2c_smbus_read_word_data(client, MP2869A_VOUT_MODE);
> > +             if (ret < 0)
> > +                     return ret;
> > +
> > +             switch (ret & MP2869A_VOUT_MODE_MASK) {
> > +             case MP2869A_VOUT_MODE_VID:
> > +                     data->vout_format[i] = vid;
> > +                     break;
> > +             default:
> > +             return -EINVAL;
> > +             }
> > +             }
>
> Messed indentation in multiple places.
>
> > +     return 0;
> > +}
> > +
> > +static struct pmbus_driver_info MP2869A_info = {
>
> This is const.
Since info will be modified by mp2869a_read_vout at runtime, I chose
not to make it constant
>
> > +     .pages = MP2869A_PAGE_NUM,
> > +     .format[PSC_VOLTAGE_IN] = linear,
> > +     .format[PSC_VOLTAGE_OUT] = direct,
> > +     .format[PSC_TEMPERATURE] = linear,
> > +     .format[PSC_CURRENT_IN] = linear,
> > +     .format[PSC_CURRENT_OUT] = linear,
> > +     .format[PSC_POWER] = linear,
> > +     .m[PSC_VOLTAGE_OUT] = 1,
> > +     .b[PSC_VOLTAGE_OUT] = 0,
> > +     .R[PSC_VOLTAGE_OUT] = -3,
> > +     .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
> > +             PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
> > +             PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_POUT |
> > +             PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT,
> > +     .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_IOUT |
> > +             PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT | PMBUS_HAVE_TEMP,
> > +     .read_byte_data = MP2869A_read_byte_data,
> > +     .read_word_data = MP2869A_read_word_data,
> > +};
> > +
> > +static int mp2869a_probe(struct i2c_client *client)
> > +{
> > +     struct pmbus_driver_info *info;
> > +     struct MP2869A_data *data;
> > +     int ret;
> > +
> > +     data = devm_kzalloc(&client->dev, sizeof(struct MP2869A_data),
>
> sizeof(*)
>
> > +             GFP_KERNEL);
>
> Misaligned. Run checkpatch --srtict
>
> > +     if (!data)
> > +             return -ENOMEM;
> > +
> > +     data->chip_id = (enum chips)(uintptr_t)i2c_get_match_data(client);
>
> These are just wrong or redundant casts. You need only one cast -
> kernel_ulong_t
>
> > +
> > +     memcpy(data->max_phases, mp2869a_max_phases[data->chip_id],
> > +             sizeof(data->max_phases));
>
> Why you cannot just store the pointer?
As chip_id and max_phase will be constant, it should be acceptable to
handle them via pointers in this case.
>
> > +
> > +     memcpy(&data->info, &MP2869A_info, sizeof(*info));
>
> Why you cannot just store the pointer?
Considering that the info can change at runtime, using memcpy is a
safer approach
>
> > +     info = &data->info;
> > +
> > +
>
> One blank line, not two
>
> > +     /* Identify vout format. */
> > +     ret = MP2869A_identify_vout_format(client, data);
> > +     if (ret)
> > +             return ret;
> > +
> > +     /* set the device to page 0 */
> > +     i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0);
> > +
> > +     return pmbus_do_probe(client, info);
> > +}
> > +
> > +static const struct of_device_id __maybe_unused mp2869a_of_match[] = {
> > +     { .compatible = "mps,mp2869a", .data = (void *)mp2869a },
> > +     { .compatible = "mps,mp29612a", .data = (void *)mp29612a},
> > +     {}
> > +};
> > +
> > +MODULE_DEVICE_TABLE(of, mp2869a_of_match);
> > +
> > +static struct i2c_driver mp2869a_driver = {
> > +     .driver = {
> > +             .name = "mp2869a",
> > +             .of_match_table = mp2869a_of_match,
> > +     },
> > +     .probe = mp2869a_probe,
> > +     .id_table = mp2869a_id,
> > +};
> > +
> > +module_i2c_driver(mp2869a_driver);
> > +
> > +
>
> One blank line, not two. This applies everywhere.
>
> > +MODULE_AUTHOR("Henry Wu <Henry_WU@quantatw.com>");
> > +MODULE_DESCRIPTION("PMBus driver for MPS MP2869A/MP29612A device");
> > +MODULE_LICENSE("GPL");
> > +MODULE_IMPORT_NS(PMBUS);
>
>
> Best regards,
> Krzysztof

Thank you for your advice. I still have a few questions and would
appreciate your help in resolving them.

Best regards,
Henry Wu

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

* Re: [PATCH 1/2] hwmon: (pmbus) Add support for MPS multi-phase mp2869a/mp29612a controllers
  2025-06-25  6:31   ` 吳梓豪
@ 2025-06-25  8:08     ` Krzysztof Kozlowski
  2025-06-25 13:11     ` Guenter Roeck
  1 sibling, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2025-06-25  8:08 UTC (permalink / raw)
  To: 吳梓豪
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jean Delvare,
	Guenter Roeck, Jonathan Corbet, Jonathan Cameron, Naresh Solanki,
	Rodrigo Gobbi, Michal Simek, Fabio Estevam, Henry Wu,
	Grant Peltier, Laurent Pinchart, Cedric Encarnacion,
	Kim Seer Paller, Leo Yang, Ninad Palsule, Alex Vdovydchenko,
	John Erasmus Mari Geronimo, Nuno Sa, Jerome Brunet, Noah Wang,
	Mariel Tinaco, devicetree, linux-kernel, linux-hwmon, linux-doc

On 25/06/2025 08:31, 吳梓豪 wrote:
>>
>>> +     return 0;
>>> +}
>>> +
>>> +static struct pmbus_driver_info MP2869A_info = {
>>
>> This is const.
> Since info will be modified by mp2869a_read_vout at runtime, I chose
> not to make it constant

No, this makes it a singleton. I don't see the code in current driver,
so I don't get whether you meant current code or future. If current:
where is it modified?

mp2869a_read_vout() has terrible style btw, really not looking like
Linux coding style. Be sure you carefully follow the style.

>>
>>> +     .pages = MP2869A_PAGE_NUM,
>>> +     .format[PSC_VOLTAGE_IN] = linear,
>>> +     .format[PSC_VOLTAGE_OUT] = direct,
>>> +     .format[PSC_TEMPERATURE] = linear,
>>> +     .format[PSC_CURRENT_IN] = linear,
>>> +     .format[PSC_CURRENT_OUT] = linear,
>>> +     .format[PSC_POWER] = linear,
>>> +     .m[PSC_VOLTAGE_OUT] = 1,
>>> +     .b[PSC_VOLTAGE_OUT] = 0,
>>> +     .R[PSC_VOLTAGE_OUT] = -3,
>>> +     .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
>>> +             PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
>>> +             PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_POUT |
>>> +             PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT,
>>> +     .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_IOUT |
>>> +             PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT | PMBUS_HAVE_TEMP,
>>> +     .read_byte_data = MP2869A_read_byte_data,
>>> +     .read_word_data = MP2869A_read_word_data,
>>> +};
>>> +
>>> +static int mp2869a_probe(struct i2c_client *client)
>>> +{
>>> +     struct pmbus_driver_info *info;
>>> +     struct MP2869A_data *data;
>>> +     int ret;
>>> +
>>> +     data = devm_kzalloc(&client->dev, sizeof(struct MP2869A_data),
>>
>> sizeof(*)
>>
>>> +             GFP_KERNEL);
>>
>> Misaligned. Run checkpatch --srtict
>>
>>> +     if (!data)
>>> +             return -ENOMEM;
>>> +
>>> +     data->chip_id = (enum chips)(uintptr_t)i2c_get_match_data(client);
>>
>> These are just wrong or redundant casts. You need only one cast -
>> kernel_ulong_t
>>
>>> +
>>> +     memcpy(data->max_phases, mp2869a_max_phases[data->chip_id],
>>> +             sizeof(data->max_phases));
>>
>> Why you cannot just store the pointer?
> As chip_id and max_phase will be constant, it should be acceptable to
> handle them via pointers in this case.
>>
>>> +
>>> +     memcpy(&data->info, &MP2869A_info, sizeof(*info));
>>
>> Why you cannot just store the pointer?
> Considering that the info can change at runtime, using memcpy is a
> safer approach

Where do you modify the contents?


Best regards,
Krzysztof

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

* Re: [PATCH 1/2] hwmon: (pmbus) Add support for MPS multi-phase mp2869a/mp29612a controllers
  2025-06-25  6:31   ` 吳梓豪
  2025-06-25  8:08     ` Krzysztof Kozlowski
@ 2025-06-25 13:11     ` Guenter Roeck
  1 sibling, 0 replies; 8+ messages in thread
From: Guenter Roeck @ 2025-06-25 13:11 UTC (permalink / raw)
  To: 吳梓豪
  Cc: Krzysztof Kozlowski, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Jean Delvare, Jonathan Corbet, Jonathan Cameron,
	Naresh Solanki, Rodrigo Gobbi, Michal Simek, Fabio Estevam,
	Henry Wu, Grant Peltier, Laurent Pinchart, Cedric Encarnacion,
	Kim Seer Paller, Leo Yang, Ninad Palsule, Alex Vdovydchenko,
	John Erasmus Mari Geronimo, Nuno Sa, Jerome Brunet, Noah Wang,
	Mariel Tinaco, devicetree, linux-kernel, linux-hwmon, linux-doc

On Wed, Jun 25, 2025 at 02:31:02PM +0800, 吳梓豪 wrote:
> Krzysztof Kozlowski <krzk@kernel.org> 於 2025年6月24日 週二 下午3:48寫道:
> >
> > On 24/06/2025 09:41, tzuhao.wtmh@gmail.com wrote:
> > > +static int
> > > +MP2869A_read_byte_data(struct i2c_client *client, int page, int reg)
> > > +{
> > > +     switch (reg) {
> > > +     case PMBUS_VOUT_MODE:
> > > +             /* Enforce VOUT direct format. */
> > > +             return PB_VOUT_MODE_DIRECT;
> > > +     default:
> > > +             return -ENODATA;
> > > +     }
> > > +}
> > > +
> > > +static int
> > > +MP2869A_identify_vout_format(struct i2c_client *client,
> >
> > Use Linux coding style, so lowercase for variables, types and functions.
> > Everywhere (except when coding style tells you different, so please read
> > it).
> >
> > > +                         struct MP2869A_data *data)
> > > +{
> > > +     int i, ret;
> > > +
> > > +     for (i = 0; i < data->info.pages; i++) {
> > > +             ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, i);
> > > +             if (ret < 0)
> > > +                     return ret;
> > > +
> > > +             ret = i2c_smbus_read_word_data(client, MP2869A_VOUT_MODE);
> > > +             if (ret < 0)
> > > +                     return ret;
> > > +
> > > +             switch (ret & MP2869A_VOUT_MODE_MASK) {
> > > +             case MP2869A_VOUT_MODE_VID:
> > > +                     data->vout_format[i] = vid;
> > > +                     break;
> > > +             default:
> > > +             return -EINVAL;
> > > +             }
> > > +             }
> >
> > Messed indentation in multiple places.
> >
> > > +     return 0;
> > > +}
> > > +
> > > +static struct pmbus_driver_info MP2869A_info = {
> >
> > This is const.
> Since info will be modified by mp2869a_read_vout at runtime, I chose
> not to make it constant

That is a no-go. There can be multiple instances of the chip in a system,
each requiring its own info data structure. If the structure is modified
at runtime it needs to be copied first.

Guenter

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

end of thread, other threads:[~2025-06-25 13:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-24  7:41 [PATCH 1/2] hwmon: (pmbus) Add support for MPS multi-phase mp2869a/mp29612a controllers tzuhao.wtmh
2025-06-24  7:41 ` [PATCH 2/2] dt-bindings: trivial-devices: Add mp2869a/mp29612a device entry tzuhao.wtmh
2025-06-24  7:44   ` Krzysztof Kozlowski
2025-06-24  7:48 ` [PATCH 1/2] hwmon: (pmbus) Add support for MPS multi-phase mp2869a/mp29612a controllers Krzysztof Kozlowski
2025-06-25  6:31   ` 吳梓豪
2025-06-25  8:08     ` Krzysztof Kozlowski
2025-06-25 13:11     ` Guenter Roeck
2025-06-24 20:10 ` kernel test robot

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).