[PATCH 3/3] pmbus: max31785: Add handler for set_page() and PMBUS_CLEAR_FAULTS virt pages

Andrew Jeffery andrew at aj.id.au
Tue Sep 5 17:28:28 AEST 2017


The max31785 uses the concept of 'virtual pages' to manage dual tach
fan inputs. These pages don't exist in hardware by definition, so don't
send spurious PAGE or CLEAR_FAULTS commands to the device for these
pages.

Signed-off-by: Andrew Jeffery <andrew at aj.id.au>
---
 drivers/hwmon/pmbus/max31785.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/hwmon/pmbus/max31785.c b/drivers/hwmon/pmbus/max31785.c
index 6a0d289ad346..a1e5f24c9744 100644
--- a/drivers/hwmon/pmbus/max31785.c
+++ b/drivers/hwmon/pmbus/max31785.c
@@ -117,11 +117,23 @@ static int max31785_read_byte_data(struct i2c_client *client, int page,
 	return -ENODATA;
 }
 
+static int max31785_set_page(struct i2c_client *client, int page)
+{
+	return (page < MAX31785_NR_PAGES) ? -ENODATA : 0;
+}
+
 static int max31785_write_byte(struct i2c_client *client, int page, u8 value)
 {
 	if (page < MAX31785_NR_PAGES)
 		return -ENODATA;
 
+	switch (value) {
+	case PMBUS_CLEAR_FAULTS:
+		return 0;
+	default:
+		break;
+	}
+
 	return -ENOTSUPP;
 }
 
@@ -604,6 +616,7 @@ static int max31785_of_tmp_config(struct i2c_client *client,
 static const struct pmbus_driver_info max31785_info = {
 	.pages = MAX31785_NR_PAGES,
 
+	.set_page = max31785_set_page,
 	.write_word_data = max31785_write_word_data,
 	.read_byte_data = max31785_read_byte_data,
 	.read_word_data = max31785_read_word_data,
-- 
2.11.0



More information about the openbmc mailing list