diff options
author | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-10-04 20:26:04 -0400 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2012-01-05 11:19:28 -0500 |
commit | 56badacb922ac6117c8231716265301118b22b17 (patch) | |
tree | abcc42e210c3e9d44a03afc7bf046058166bd29b /drivers/hwmon | |
parent | 443830f6fd986b894da2ea7403163a64c0925f54 (diff) |
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.
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.
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Reviewed-by: Robert Coulson <robert.coulson@ericsson.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/pmbus/zl6100.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/hwmon/pmbus/zl6100.c b/drivers/hwmon/pmbus/zl6100.c index 7a72b6e4ff1d..48c7b4a716ae 100644 --- a/drivers/hwmon/pmbus/zl6100.c +++ b/drivers/hwmon/pmbus/zl6100.c | |||
@@ -38,8 +38,11 @@ struct zl6100_data { | |||
38 | 38 | ||
39 | #define to_zl6100_data(x) container_of(x, struct zl6100_data, info) | 39 | #define to_zl6100_data(x) container_of(x, struct zl6100_data, info) |
40 | 40 | ||
41 | #define ZL6100_MFR_CONFIG 0xd0 | ||
41 | #define ZL6100_DEVICE_ID 0xe4 | 42 | #define ZL6100_DEVICE_ID 0xe4 |
42 | 43 | ||
44 | #define ZL6100_MFR_XTEMP_ENABLE (1 << 7) | ||
45 | |||
43 | #define ZL6100_WAIT_TIME 1000 /* uS */ | 46 | #define ZL6100_WAIT_TIME 1000 /* uS */ |
44 | 47 | ||
45 | static ushort delay = ZL6100_WAIT_TIME; | 48 | static ushort delay = ZL6100_WAIT_TIME; |
@@ -162,7 +165,7 @@ static int zl6100_probe(struct i2c_client *client, | |||
162 | const struct i2c_device_id *mid; | 165 | const struct i2c_device_id *mid; |
163 | 166 | ||
164 | if (!i2c_check_functionality(client->adapter, | 167 | if (!i2c_check_functionality(client->adapter, |
165 | I2C_FUNC_SMBUS_READ_BYTE_DATA | 168 | I2C_FUNC_SMBUS_READ_WORD_DATA |
166 | | I2C_FUNC_SMBUS_READ_BLOCK_DATA)) | 169 | | I2C_FUNC_SMBUS_READ_BLOCK_DATA)) |
167 | return -ENODEV; | 170 | return -ENODEV; |
168 | 171 | ||
@@ -210,12 +213,9 @@ static int zl6100_probe(struct i2c_client *client, | |||
210 | /* | 213 | /* |
211 | * Since there was a direct I2C device access above, wait before | 214 | * Since there was a direct I2C device access above, wait before |
212 | * accessing the chip again. | 215 | * accessing the chip again. |
213 | * Set the timestamp, wait, then set it again. This should provide | ||
214 | * enough buffer time to be safe. | ||
215 | */ | 216 | */ |
216 | data->access = ktime_get(); | 217 | data->access = ktime_get(); |
217 | zl6100_wait(data); | 218 | zl6100_wait(data); |
218 | data->access = ktime_get(); | ||
219 | 219 | ||
220 | info = &data->info; | 220 | info = &data->info; |
221 | 221 | ||
@@ -223,7 +223,16 @@ static int zl6100_probe(struct i2c_client *client, | |||
223 | info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT | 223 | info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT |
224 | | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | 224 | | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
225 | | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | 225 | | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
226 | | PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_STATUS_TEMP; | 226 | | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP; |
227 | |||
228 | ret = i2c_smbus_read_word_data(client, ZL6100_MFR_CONFIG); | ||
229 | if (ret < 0) | ||
230 | goto err_mem; | ||
231 | if (ret & ZL6100_MFR_XTEMP_ENABLE) | ||
232 | info->func[0] |= PMBUS_HAVE_TEMP2; | ||
233 | |||
234 | data->access = ktime_get(); | ||
235 | zl6100_wait(data); | ||
227 | 236 | ||
228 | info->read_word_data = zl6100_read_word_data; | 237 | info->read_word_data = zl6100_read_word_data; |
229 | info->read_byte_data = zl6100_read_byte_data; | 238 | info->read_byte_data = zl6100_read_byte_data; |