[PATCH v2 1/7] pmbus: add PMBus 1.x framework, CLI, and binding
Peng Fan
peng.fan at oss.nxp.com
Mon Jul 6 05:37:02 CEST 2026
On Thu, Jul 02, 2026 at 09:56:03PM +0200, Vincent Jardin wrote:
>Add U-Boot's PMBus 1.x layer: the decoder/transport library, the
>pmbus CLI command and a generic DT binding.
>
>The subsequent commits provide the UCLASS_REGULATOR adapter and per-chip
>drivers.
>
...
>+ case PMBUS_MFR_REVISION: {
>+ char s[PMBUS_MFR_STRING_MAX];
>+
>+ if (pmbus_read_string(chip, reg, s, sizeof(s),
>+ act->info ? false : false) >= 0)
Should be true : false or false: true?
>+ printf(" %02xh %-15s s=\"%s\"\n",
>+ reg, pmbus_reg_syms[i].name, s);
>+
...
>+int pmbus_read_string(struct udevice *dev, u8 cmd, char *out, int outsz,
>+ bool reverse_bytes)
>+{
>+ u8 raw[PMBUS_MFR_STRING_MAX];
>+ int ret, len, i;
>+
>+ if (outsz < 2)
>+ return -EINVAL;
>+
>+ /* Stage 1: read the length byte. */
>+ ret = dm_i2c_read(dev, cmd, raw, 1);
>+ if (ret)
>+ return ret;
>+
>+ len = raw[0];
>+ if (len <= 0 || len > (int)sizeof(raw))
>+ return -EBADMSG;
>+ if (len > outsz - 1)
>+ len = outsz - 1;
>+
>+ /* Stage 2: reread length + payload (some controllers mandate this). */
>+ ret = dm_i2c_read(dev, cmd, raw, len + 1);
When len is 16, len + 1 bytes are read, so corrupt u8 raw[].
>+ if (ret)
>+ return ret;
>+
Regards
Peng
More information about the U-Boot
mailing list