diff mbox

[linux,dev-4.10,v2,3/4] hwmon: (pmbus): Add generic alarm bit for iin and pin

Message ID 1502474608-2674-4-git-send-email-eajames@linux.vnet.ibm.com
State Accepted, archived
Headers show

Commit Message

Eddie James Aug. 11, 2017, 6:03 p.m. UTC
From: "Edward A. James" <eajames@us.ibm.com>

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.

Signed-off-by: Edward A. James <eajames@us.ibm.com>
---
 drivers/hwmon/pmbus/pmbus_core.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Joel Stanley Aug. 14, 2017, 4:33 a.m. UTC | #1
On Sat, Aug 12, 2017 at 3:33 AM, Eddie James <eajames@linux.vnet.ibm.com> wrote:
> From: "Edward A. James" <eajames@us.ibm.com>
>
> 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.
>
> Signed-off-by: Edward A. James <eajames@us.ibm.com>

I have merged the upstream commit
(cbcdec6202c934bd72fca4fe9db255d84f907dbe) into dev-4.10.

Cheers,

Joel
Joel Stanley Aug. 14, 2017, 5:06 a.m. UTC | #2
On Mon, Aug 14, 2017 at 2:03 PM, Joel Stanley <joel@jms.id.au> wrote:
> On Sat, Aug 12, 2017 at 3:33 AM, Eddie James <eajames@linux.vnet.ibm.com> wrote:
>> From: "Edward A. James" <eajames@us.ibm.com>
>>
>> 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.
>>
>> Signed-off-by: Edward A. James <eajames@us.ibm.com>
>
> I have merged the upstream commit
> (cbcdec6202c934bd72fca4fe9db255d84f907dbe) into dev-4.10.

That should say c159be9e902a59a117e67d466c872ecc46240ba5.
Andrew Jeffery Aug. 14, 2017, 6:19 a.m. UTC | #3
On Mon, 2017-08-14 at 14:36 +0930, Joel Stanley wrote:
> > On Mon, Aug 14, 2017 at 2:03 PM, Joel Stanley <joel@jms.id.au> wrote:
> > On Sat, Aug 12, 2017 at 3:33 AM, Eddie James <eajames@linux.vnet.ibm.com> wrote:
> > > > > > From: "Edward A. James" <eajames@us.ibm.com>
> > > 
> > > 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.
> > > 
> > > Signed-off-by: Edward A. James <eajames@us.ibm.com>
> > 
> > I have merged the upstream commit
> > (cbcdec6202c934bd72fca4fe9db255d84f907dbe) into dev-4.10.

> That should say c159be9e902a59a117e67d466c872ecc46240ba5.

It was in the ballpark - it started with a 'c' at least.
diff mbox

Patch

diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 306abdc..40ceb5a 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -115,6 +115,7 @@  struct pmbus_data {
 	 */
 	u16 status[PB_NUM_STATUS_REG];
 
+	bool has_status_word;		/* device uses STATUS_WORD register */
 	int (*read_status)(struct i2c_client *client, int page);
 
 	u8 currpage;
@@ -1193,6 +1194,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) {
@@ -1213,9 +1215,11 @@  static int pmbus_add_sensor_attrs_one(struct i2c_client *client,
 		/*
 		 * Add generic alarm attribute only if there are no individual
 		 * 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 &&
+		    (!upper || (upper && data->has_status_word)) &&
 		    pmbus_check_status_register(client, page)) {
 			ret = pmbus_add_boolean(data, name, "alarm", index,
 						NULL, NULL,
@@ -1472,6 +1476,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),
 	}, {
@@ -1556,6 +1561,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),
 	}, {
@@ -1967,6 +1973,8 @@  static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
 			dev_err(dev, "PMBus status register not found\n");
 			return -ENODEV;
 		}
+	} else {
+		data->has_status_word = true;
 	}
 
 	/* Enable PEC if the controller supports it */