]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
hwmon: (pmbus) Initialise page count in pmbus_identify()
authorTitus Rwantare <titusr@google.com>
Thu, 27 Feb 2025 22:24:55 +0000 (22:24 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Mar 2025 11:51:04 +0000 (12:51 +0100)
commit13de3056e38c8229a38535d0e115b082785cdb4c
tree53976a66943ffdcbe5a06278cb9c11992a4e0aa1
parent8e4e08ca4cc634b337bb74bc9a70758fdeda0bcb
hwmon: (pmbus) Initialise page count in pmbus_identify()

[ Upstream commit 6b6e2e8fd0de3fa7c6f4f8fe6841b01770b2e7bc ]

The `pmbus_identify()` function fails to correctly determine the number
of supported pages on PMBus devices. This occurs because `info->pages`
is implicitly zero-initialised, and `pmbus_set_page()` does not perform
writes to the page register if `info->pages` is not yet initialised.
Without this patch, `info->pages` is always set to the maximum after
scanning.

This patch initialises `info->pages` to `PMBUS_PAGES` before the probing
loop, enabling `pmbus_set_page()` writes to make it out onto the bus
correctly identifying the number of pages. `PMBUS_PAGES` seemed like a
reasonable non-zero number because that's the current result of the
identification process.

Testing was done with a PMBus device in QEMU.

Signed-off-by: Titus Rwantare <titusr@google.com>
Fixes: 442aba78728e7 ("hwmon: PMBus device driver")
Link: https://lore.kernel.org/r/20250227222455.2583468-1-titusr@google.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hwmon/pmbus/pmbus.c