Skip to contentSkip to conversation

hwmon: (pmbus/zl6100) Only instantiate

PATCH In review Guenter Roeck 2 participants 2 messages Nov 23, 2011 – Nov 28, 2011 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 4/4 hwmon: (pmbus/zl6100) Only instantiate

BMR4xx devices don't have an external temperature sensor, and instantiating it does not provide value anyway if it is disabled. Only instantiate it if it is enabled.

Also optimize wait time between I2C chip accesses in the probe function, and replace unnecessary check for support for I2C_FUNC_SMBUS_READ_BYTE_DATA with now required support for I2C_FUNC_SMBUS_READ_WORD_DATA.

---
 drivers/hwmon/pmbus/zl6100.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
drivers/hwmon/pmbus/zl6100.c +14 -5
index 7a72b6e..48c7b4a 100644
@@ -38,8 +38,11 @@ struct zl6100_data {
 
 #define to_zl6100_data(x)  container_of(x, struct zl6100_data, info)
 
+#define ZL6100_MFR_CONFIG		0xd0
 #define ZL6100_DEVICE_ID		0xe4
 
+#define ZL6100_MFR_XTEMP_ENABLE		(1 << 7)
+
 #define ZL6100_WAIT_TIME		1000	/* uS	*/
 
 static ushort delay = ZL6100_WAIT_TIME;
@@ -162,7 +165,7 @@ static int zl6100_probe(struct i2c_client *client,
 	const struct i2c_device_id *mid;
 
 	if (!i2c_check_functionality(client->adapter,
-				     I2C_FUNC_SMBUS_READ_BYTE_DATA
+				     I2C_FUNC_SMBUS_READ_WORD_DATA
 				     | I2C_FUNC_SMBUS_READ_BLOCK_DATA))
 		return -ENODEV;
 
@@ -210,12 +213,9 @@ static int zl6100_probe(struct i2c_client *client,
 	/*
 	 * Since there was a direct I2C device access above, wait before
 	 * accessing the chip again.
-	 * Set the timestamp, wait, then set it again. This should provide
-	 * enough buffer time to be safe.
 	 */
 	data->access = ktime_get();
 	zl6100_wait(data);
-	data->access = ktime_get();
 
 	info = &data->info;
 
@@ -223,7 +223,16 @@ static int zl6100_probe(struct i2c_client *client,
 	info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
 	  | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
 	  | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
-	  | PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_STATUS_TEMP;
+	  | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP;
+
+	ret = i2c_smbus_read_word_data(client, ZL6100_MFR_CONFIG);
+	if (ret < 0)
+		goto err_mem;
+	if (ret & ZL6100_MFR_XTEMP_ENABLE)
+		info->func[0] |= PMBUS_HAVE_TEMP2;
+
+	data->access = ktime_get();
+	zl6100_wait(data);
 
 	info->read_word_data = zl6100_read_word_data;
 	info->read_byte_data = zl6100_read_byte_data;
Signature · 7 lines
1.7.3.1


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Reviewed-by on v1 4/4
#1 lore raw
Quoted 13 lines

-----Original Message-----
From: Guenter Roeck
Sent: Wednesday, November 23, 2011 11:31 AM
To: Jean Delvare
Cc: Robert Coulson; [email protected]; Guenter Roeck
Subject: [PATCH 4/4] hwmon: (pmbus/zl6100) Only instantiate external temperature sensor if enabled

BMR4xx devices don't have an external temperature sensor, and instantiating it does not provide value anyway if it is disabled. Only instantiate it if it is enabled.

Quoted 6 lines

Also optimize wait time between I2C chip accesses in the probe function, and replace unnecessary check for support for I2C_FUNC_SMBUS_READ_BYTE_DATA with now required support for I2C_FUNC_SMBUS_READ_WORD_DATA.

Quoted 62 lines
---
 drivers/hwmon/pmbus/zl6100.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/drivers/hwmon/pmbus/zl6100.c index 7a72b6e..48c7b4a 100644

drivers/hwmon/pmbus/zl6100.c +3 -0
@@ -38,8 +38,11 @@ struct zl6100_data {
 
 #define to_zl6100_data(x)  container_of(x, struct zl6100_data, info)
 
+#define ZL6100_MFR_CONFIG		0xd0
 #define ZL6100_DEVICE_ID		0xe4
 
+#define ZL6100_MFR_XTEMP_ENABLE		(1 << 7)
+
 #define ZL6100_WAIT_TIME		1000	/* uS	*/
 
 static ushort delay = ZL6100_WAIT_TIME; @@ -162,7 +165,7 @@ 

static int zl6100_probe(struct i2c_client *client,

drivers/hwmon/pmbus/zl6100.c +1 -2
 	const struct i2c_device_id *mid;
 
 	if (!i2c_check_functionality(client->adapter,
-				     I2C_FUNC_SMBUS_READ_BYTE_DATA
+				     I2C_FUNC_SMBUS_READ_WORD_DATA
 				     | I2C_FUNC_SMBUS_READ_BLOCK_DATA))
 		return -ENODEV;
@@ -210,12 +213,9 @@ static int zl6100_probe(struct 
 i2c_client *client,
 	/*
 	 * Since there was a direct I2C device access above, wait before
 	 * accessing the chip again.
-	 * Set the timestamp, wait, then set it again. This 

should provide

drivers/hwmon/pmbus/zl6100.c +10 -3
-	 * enough buffer time to be safe.
 	 */
 	data->access = ktime_get();
 	zl6100_wait(data);
-	data->access = ktime_get();
 
 	info = &data->info;
@@ -223,7 +223,16 @@ static int zl6100_probe(struct 
 i2c_client *client,
 	info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
 	  | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
 	  | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
-	  | PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_STATUS_TEMP;
+	  | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP;
+
+	ret = i2c_smbus_read_word_data(client, ZL6100_MFR_CONFIG);
+	if (ret < 0)
+		goto err_mem;
+	if (ret & ZL6100_MFR_XTEMP_ENABLE)
+		info->func[0] |= PMBUS_HAVE_TEMP2;
+
+	data->access = ktime_get();
+	zl6100_wait(data);
 
 	info->read_word_data = zl6100_read_word_data;
Quoted 5 lines

info->read_byte_data = zl6100_read_byte_data;
--
1.7.3.1

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors