[PATCH linux dev-4.10] hwmon: (occ): Add error thresholding back in

Eddie James eajames at linux.vnet.ibm.com
Thu Aug 10 12:45:30 AEST 2017


From: "Edward A. James" <eajames at us.ibm.com>

Threshold communication and message errors to the OCC, such that errors
are only valid after two have been observed in a row. This thresholding
is required by the OCC specification. An old P8 OCC spec is available
here:
https://github.com/open-power/docs/blob/master/occ/OCC_OpenPwr_FW_Interfaces.pdf

Signed-off-by: Edward A. James <eajames at us.ibm.com>
---
 drivers/hwmon/occ/common.c | 3 ++-
 drivers/hwmon/occ/common.h | 2 ++
 drivers/hwmon/occ/p8_i2c.c | 4 +++-
 drivers/hwmon/occ/p9_sbe.c | 2 ++
 4 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c
index a793834..3f63467 100644
--- a/drivers/hwmon/occ/common.c
+++ b/drivers/hwmon/occ/common.c
@@ -166,7 +166,8 @@ void occ_parse_poll_response(struct occ *occ)
 void occ_set_error(struct occ *occ, int error)
 {
 	occ->error_count++;
-	occ->error = error;
+	if (occ->error_count > OCC_ERROR_COUNT_THRESHOLD)
+		occ->error = error;
 }
 
 void occ_reset_error(struct occ *occ)
diff --git a/drivers/hwmon/occ/common.h b/drivers/hwmon/occ/common.h
index ca5969c..acb50bc 100644
--- a/drivers/hwmon/occ/common.h
+++ b/drivers/hwmon/occ/common.h
@@ -13,6 +13,8 @@
 #include <linux/hwmon-sysfs.h>
 #include <linux/sysfs.h>
 
+#define OCC_ERROR_COUNT_THRESHOLD	2
+
 #define OCC_UPDATE_FREQUENCY		msecs_to_jiffies(1000)
 #define OCC_RESP_DATA_BYTES		4089
 
diff --git a/drivers/hwmon/occ/p8_i2c.c b/drivers/hwmon/occ/p8_i2c.c
index 05af16b..269cb91 100644
--- a/drivers/hwmon/occ/p8_i2c.c
+++ b/drivers/hwmon/occ/p8_i2c.c
@@ -169,7 +169,7 @@ static int p8_i2c_occ_send_cmd(struct occ *occ, u8 *cmd)
 
 	data_length = get_unaligned_be16(&resp->data_length_be);
 	if (data_length > OCC_RESP_DATA_BYTES) {
-		rc = -EIO;
+		rc = -EMSGSIZE;
 		dev_warn(&client->dev, "occ bad data length:%d\n",
 			 data_length);
 		goto assign;
@@ -186,8 +186,10 @@ static int p8_i2c_occ_send_cmd(struct occ *occ, u8 *cmd)
 
 err:
 	dev_err(&client->dev, "i2c scom op failed rc:%d\n", rc);
+
 assign:
 	error = rc;
+
 done:
 	occ_set_error(occ, error);
 	return rc;
diff --git a/drivers/hwmon/occ/p9_sbe.c b/drivers/hwmon/occ/p9_sbe.c
index 2d50a94..db30a2d 100644
--- a/drivers/hwmon/occ/p9_sbe.c
+++ b/drivers/hwmon/occ/p9_sbe.c
@@ -86,8 +86,10 @@ static int p9_sbe_occ_send_cmd(struct occ *occ, u8 *cmd)
 err:
 	occ_drv_release(client);
 	dev_err(occ->bus_dev, "occ bus op failed rc:%d\n", rc);
+
 assign:
 	error = rc;
+
 done:
 	occ_set_error(occ, error);
 	return rc;
-- 
1.8.3.1



More information about the openbmc mailing list