Skip to contentSkip to conversation

drivers/hwmon/pmbus: Add generic alarm bit for iin and pin

PATCH Guenter Roeck 1 participant 1 message Aug 9, 2017 Hardware monitoring

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw
Quoted 8 lines · Eddie James

From: "Edward A. James" <[email protected]>

Add PB_STATUS_INPUT as the generic alarm bit for iin and pin. We also need to redo the status register checking before setting up the boolean attribute, since it won't necessarily check STATUS_WORD if the device doesn't support it, which we need for this bit.

For the entire series: subject should start with "hwmon: (pmbus)".

Quoted 19 lines
---
 drivers/hwmon/pmbus/pmbus_core.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +1 -0
index 277d170..1a51f8f 100644
@@ -1045,6 +1045,7 @@ static int pmbus_add_sensor_attrs_one(struct i2c_client *client,
 				      const struct pmbus_sensor_attr *attr)
 {
 	struct pmbus_sensor *base;
+	bool upper = !!(attr->gbit & 0xff00);	/* need to check STATUS_WORD */
 	int ret;
 
 	if (attr->label) {
@@ -1065,10 +1066,13 @@ static int pmbus_add_sensor_attrs_one(struct i2c_client *client,
 		/*
 		 * Add generic alarm attribute only if there are no individual

drivers/hwmon/pmbus/pmbus_core.c static int pmbus_add_sensor_attrs_one(struct i2c_client *client, · line 1075

Quoted 10 lines
drivers/hwmon/pmbus/pmbus_core.c +5 -2
 		 * alarm attributes, if there is a global alarm bit, and if
-		 * the generic status register for this page is accessible.
+		 * the generic status register (word or byte, depending on
+		 * which global bit is set) for this page is accessible.
 		 */
 		if (!ret && attr->gbit &&
-		    pmbus_check_status_register(client, page)) {
+		    ((upper && pmbus_check_word_register(client, page,
+							 PMBUS_STATUS_WORD)) ||
+		     (!upper && pmbus_check_status_register(client, page)))) {

We already know if PMBUS_STATUS_WORD is supported or not, since pmbus_check_status_register() will use it. Just store that knowledge in a flag when discovered and make this something like

		if (!ret && attr->gbit &&
		    (!upper || (upper && data->has_word_status)) &&
		    pmbus_check_status_register(client, page)) {
Quoted 26 lines
drivers/hwmon/pmbus/pmbus_core.c +2 -0
 			ret = pmbus_add_boolean(data, name, "alarm", index,
 						NULL, NULL,
 						PB_STATUS_BASE + page,
@@ -1324,6 +1328,7 @@ static int pmbus_add_sensor_attrs(struct i2c_client *client,
 		.func = PMBUS_HAVE_IIN,
 		.sfunc = PMBUS_HAVE_STATUS_INPUT,
 		.sbase = PB_STATUS_INPUT_BASE,
+		.gbit = PB_STATUS_INPUT,
 		.limit = iin_limit_attrs,
 		.nlimit = ARRAY_SIZE(iin_limit_attrs),
 	}, {
@@ -1408,6 +1413,7 @@ static int pmbus_add_sensor_attrs(struct i2c_client *client,
 		.func = PMBUS_HAVE_PIN,
 		.sfunc = PMBUS_HAVE_STATUS_INPUT,
 		.sbase = PB_STATUS_INPUT_BASE,
+		.gbit = PB_STATUS_INPUT,
 		.limit = pin_limit_attrs,
 		.nlimit = ARRAY_SIZE(pin_limit_attrs),
 	}, {
Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html