Re: [PATCH] [v1 1/1]hwmon:(pmbus) Validate the data for chip supporting vout_mode (PMBUS_HAVE_VOUT) in the linear config.

From: Guenter Roeck
Date: Thu Oct 13 2022 - 00:36:04 EST


On 10/12/22 20:42, karthik gengan wrote:
Hi Guenter,

Thanks for your response but I need some more valuable suggestions...

In the pmbus_data structure, we are updating the vout_out mode
value based on the config ( linear, vid .direct) and this structure is declared
in pmbus_core.c .so the low-level driver could not able to access this
structure.

Guidance required,
1. Move the pumbus_data structure declaration to pmbus.h, so that low-level
the driver can check and update the vout_mode if the value
is not proper. (or)
2. if the vout_mode attribute value is exposed in the sysfs, the
user-level application
can modify the value. ( if the value is not proper).
(or)
3. if an ioctl call is exposed for the vout_mode then the
user-level application can
able to update the value. ( if the value is not proper).

(or) guide me to a better approach to handle this issue.


Have a look at drivers/hwmon/pmbus/stpddc60.c. That chip reports a wrong
value for PMBUS_VOUT_MODE, and the driver provides the expected value
to the PMBus core. Taking that as example, the simple solution is to have
the chip driver report the expected value. There is no need to get
userspace involved. Actually, involving userspace would be completely wrong.

For reference,
UCD90xx vendor claims that vout_mode value should be present
if the chip
supports PMBUS_VOUT_MODE command. Hence the patch validated the vout_mode
value for PMBUS_VOUT_MODE supported chip.


Not sure if I understand, but if any of the chips supported by the ucd9009
driver does not support the VOUT_MODE command or reports a wrong value,
just extend ucd9000_read_byte_data() to report whatever value the command
should return.

That would need some confirmation, though - I don't recall any such problem,
and UCD90xxx Sequencer and System Health Controller PMBUS Command Reference
(SLVU352) clearly states that the command is supported.

Guenter