hwmon: (pmbus) Add comments explaining
PATCH v2 1/4 hwmon: (pmbus) Add comments explaining
Return values for functions reading/writing manufacturer specific registers are poorly explained. Add comments to improve documentation.
--- drivers/hwmon/pmbus/pmbus.h | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-)
drivers/hwmon/pmbus/pmbus.h +16 -2
@@ -134,8 +134,16 @@* Semantics: * Virtual registers are all word size. * READ registers are read-only; writes are either ignored or return an error. -* RESET registers are read/write. Reading returns zero (used for detection), -* writing any value causes the associated history to be reset. +* RESET registers are read/write. Reading reset registers returns zero +* (used for detection), writing any value causes the associated history to be +* reset. +* Virtual registers have to be handled in device specific driver code. Chip +* driver code returns non-negative register values if a virtual register is +* supported, or a negative error code if not. The chip driver may return +* -ENODATA or any other error code in this case, though an error code other +* than -ENODATA is handled more efficiently and thus preferred. Either case, +* the calling PMBus core code will abort if the chip driver returns an error +* code when reading or writing virtual registers. */ #define PMBUS_VIRT_BASE 0x100#define PMBUS_VIRT_READ_TEMP_MIN (PMBUS_VIRT_BASE + 0)
@@ -320,6 +328,12 @@ struct pmbus_driver_info {* The following functions map manufacturing specific register values * to PMBus standard register values. Specify only if mapping is * necessary. +* Function return the register value (read) or zero (write) if +* successful. A return value of -ENODATA indicates that there is no +* manufacturer specific register, but that a standard PMBus register +* may exist. Any other negative return value indicates that the +* register does not exist, and that no attempt should be made to read +* the standard register. */ int (*read_byte_data)(struct i2c_client *client,int page,int reg);int (*read_word_data)(struct i2c_client *client,int page,int reg);
Signature · 7 lines
1.7.3.1 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH v2 1/4] hwmon: (pmbus) Add comments
Hi Guenter,
Quoted 18 lines · Guenter Roeck
Return values for functions reading/writing manufacturer specific registers are poorly explained. Add comments to improve documentation.
Signed-off-by Guenter Roeck <[email protected]>--- drivers/hwmon/pmbus/pmbus.h | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-)drivers/hwmon/pmbus/pmbus.h +0
-2@@ -134,8 +134,16 @@* Semantics: * Virtual registers are all word size. * READ registers are read-only; writes are either ignored or return an error. -* RESET registers are read/write. Reading returns zero (used for detection), -* writing any value causes the associated history to be reset.
drivers/hwmon/pmbus/pmbus.h line 146
Quoted 10 lines
drivers/hwmon/pmbus/pmbus.h +10
-0+* RESET registers are read/write. Reading reset registers returns zero +* (used for detection), writing any value causes the associated history to be +* reset. +* Virtual registers have to be handled in device specific driver code. Chip +* driver code returns non-negative register values if a virtual register is +* supported, or a negative error code if not. The chip driver may return +* -ENODATA or any other error code in this case, though an error code other +* than -ENODATA is handled more efficiently and thus preferred. Either case, +* the calling PMBus core code will abort if the chip driver returns an error +* code when reading or writing virtual registers.
The explanation below suggests that the code doesn't actually abort in the -ENODATA case, but instead falls back to an alternative register access?
drivers/hwmon/pmbus/pmbus.h struct pmbus_driver_info { · line 331
Quoted 8 lines
drivers/hwmon/pmbus/pmbus.h +1
-0*/ #define PMBUS_VIRT_BASE 0x100#define PMBUS_VIRT_READ_TEMP_MIN (PMBUS_VIRT_BASE + 0)@@ -320,6 +328,12 @@ struct pmbus_driver_info {* The following functions map manufacturing specific register values * to PMBus standard register values. Specify only if mapping is * necessary. +* Function return the register value (read) or zero (write) if
"Functions return" or "Function returns".
drivers/hwmon/pmbus/pmbus.h struct pmbus_driver_info { · line 339
Quoted 8 lines
drivers/hwmon/pmbus/pmbus.h +5
-0+* successful. A return value of -ENODATA indicates that there is no +* manufacturer specific register, but that a standard PMBus register +* may exist. Any other negative return value indicates that the +* register does not exist, and that no attempt should be made to read +* the standard register. */ int (*read_byte_data)(struct i2c_client *client,int page,int reg);int (*read_word_data)(struct i2c_client *client,int page,int reg);
Other than this, looks good, thanks for adding this piece of documentation.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH v2 1/4] hwmon: (pmbus) Add comments
In reply to Guenter RoeckHi Jean,
Quoted 27 lines · Jean Delvare
Hi Guenter,
Quoted 24 lines · Guenter Roeck
Return values for functions reading/writing manufacturer specific registers are poorly explained. Add comments to improve documentation.
Signed-off-by Guenter Roeck <[email protected]>--- drivers/hwmon/pmbus/pmbus.h | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-)drivers/hwmon/pmbus/pmbus.h +6
-2@@ -134,8 +134,16 @@* Semantics: * Virtual registers are all word size. * READ registers are read-only; writes are either ignored or return an error. -* RESET registers are read/write. Reading returns zero (used for detection), -* writing any value causes the associated history to be reset. +* RESET registers are read/write. Reading reset registers returns zero +* (used for detection), writing any value causes the associated history to be +* reset. +* Virtual registers have to be handled in device specific driver code. Chip +* driver code returns non-negative register values if a virtual register is +* supported, or a negative error code if not. The chip driver may return
Quoted 9 lines
drivers/hwmon/pmbus/pmbus.h line 146
Quoted 4 lines
drivers/hwmon/pmbus/pmbus.h +4
-0+* -ENODATA or any other error code in this case, though an error code other +* than -ENODATA is handled more efficiently and thus preferred. Either case, +* the calling PMBus core code will abort if the chip driver returns an error +* code when reading or writing virtual registers. The explanation below suggests that the code doesn't actually abort in the
-ENODATAcase, but instead falls back to an alternative register access?
Correct, except if -ENODATA is returned for virtual registers.
I'll add some more text to the documentation to describe how the access works in more detail.
Quoted 11 lines
drivers/hwmon/pmbus/pmbus.h struct pmbus_driver_info { · line 331
Quoted 8 lines
drivers/hwmon/pmbus/pmbus.h +1
-0*/ #define PMBUS_VIRT_BASE 0x100#define PMBUS_VIRT_READ_TEMP_MIN (PMBUS_VIRT_BASE + 0)@@ -320,6 +328,12 @@ struct pmbus_driver_info {* The following functions map manufacturing specific register values * to PMBus standard register values. Specify only if mapping is * necessary. +* Function return the register value (read) or zero (write) if "Functions return" or "Function returns".
Functions return
Quoted 12 lines
drivers/hwmon/pmbus/pmbus.h struct pmbus_driver_info { · line 339
Quoted 8 lines
drivers/hwmon/pmbus/pmbus.h +5
-0+* successful. A return value of -ENODATA indicates that there is no +* manufacturer specific register, but that a standard PMBus register +* may exist. Any other negative return value indicates that the +* register does not exist, and that no attempt should be made to read +* the standard register. */ int (*read_byte_data)(struct i2c_client *client,int page,int reg);int (*read_word_data)(struct i2c_client *client,int page,int reg);Other than this, looks good, thanks for adding this piece of documentation.
Quoted 2 lines
Acked-by Jean Delvare <[email protected]>
Thanks a lot for the review!
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors