diff options
Diffstat (limited to 'drivers/hwmon/lm85.c')
-rw-r--r-- | drivers/hwmon/lm85.c | 61 |
1 files changed, 18 insertions, 43 deletions
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index c7e10af0173f..12d446f54f97 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c | |||
@@ -318,7 +318,6 @@ static int lm85_detach_client(struct i2c_client *client); | |||
318 | static int lm85_read_value(struct i2c_client *client, u8 reg); | 318 | static int lm85_read_value(struct i2c_client *client, u8 reg); |
319 | static void lm85_write_value(struct i2c_client *client, u8 reg, int value); | 319 | static void lm85_write_value(struct i2c_client *client, u8 reg, int value); |
320 | static struct lm85_data *lm85_update_device(struct device *dev); | 320 | static struct lm85_data *lm85_update_device(struct device *dev); |
321 | static void lm85_init_client(struct i2c_client *client); | ||
322 | 321 | ||
323 | 322 | ||
324 | static struct i2c_driver lm85_driver = { | 323 | static struct i2c_driver lm85_driver = { |
@@ -1086,6 +1085,24 @@ static const struct attribute_group lm85_group_in567 = { | |||
1086 | .attrs = lm85_attributes_in567, | 1085 | .attrs = lm85_attributes_in567, |
1087 | }; | 1086 | }; |
1088 | 1087 | ||
1088 | static void lm85_init_client(struct i2c_client *client) | ||
1089 | { | ||
1090 | int value; | ||
1091 | |||
1092 | /* Start monitoring if needed */ | ||
1093 | value = lm85_read_value(client, LM85_REG_CONFIG); | ||
1094 | if (!(value & 0x01)) { | ||
1095 | dev_info(&client->dev, "Starting monitoring\n"); | ||
1096 | lm85_write_value(client, LM85_REG_CONFIG, value | 0x01); | ||
1097 | } | ||
1098 | |||
1099 | /* Warn about unusual configuration bits */ | ||
1100 | if (value & 0x02) | ||
1101 | dev_warn(&client->dev, "Device configuration is locked\n"); | ||
1102 | if (!(value & 0x04)) | ||
1103 | dev_warn(&client->dev, "Device is not ready\n"); | ||
1104 | } | ||
1105 | |||
1089 | static int lm85_detect(struct i2c_adapter *adapter, int address, | 1106 | static int lm85_detect(struct i2c_adapter *adapter, int address, |
1090 | int kind) | 1107 | int kind) |
1091 | { | 1108 | { |
@@ -1330,48 +1347,6 @@ static void lm85_write_value(struct i2c_client *client, u8 reg, int value) | |||
1330 | } | 1347 | } |
1331 | } | 1348 | } |
1332 | 1349 | ||
1333 | static void lm85_init_client(struct i2c_client *client) | ||
1334 | { | ||
1335 | int value; | ||
1336 | struct lm85_data *data = i2c_get_clientdata(client); | ||
1337 | |||
1338 | dev_dbg(&client->dev, "Initializing device\n"); | ||
1339 | |||
1340 | /* Warn if part was not "READY" */ | ||
1341 | value = lm85_read_value(client, LM85_REG_CONFIG); | ||
1342 | dev_dbg(&client->dev, "LM85_REG_CONFIG is: 0x%02x\n", value); | ||
1343 | if (value & 0x02) { | ||
1344 | dev_err(&client->dev, "Client (%d,0x%02x) config is locked.\n", | ||
1345 | i2c_adapter_id(client->adapter), client->addr); | ||
1346 | } | ||
1347 | if (!(value & 0x04)) { | ||
1348 | dev_err(&client->dev, "Client (%d,0x%02x) is not ready.\n", | ||
1349 | i2c_adapter_id(client->adapter), client->addr); | ||
1350 | } | ||
1351 | if (value & 0x10 | ||
1352 | && (data->type == adm1027 | ||
1353 | || data->type == adt7463)) { | ||
1354 | dev_err(&client->dev, "Client (%d,0x%02x) VxI mode is set. " | ||
1355 | "Please report this to the lm85 maintainer.\n", | ||
1356 | i2c_adapter_id(client->adapter), client->addr); | ||
1357 | } | ||
1358 | |||
1359 | /* WE INTENTIONALLY make no changes to the limits, | ||
1360 | * offsets, pwms, fans and zones. If they were | ||
1361 | * configured, we don't want to mess with them. | ||
1362 | * If they weren't, the default is 100% PWM, no | ||
1363 | * control and will suffice until 'sensors -s' | ||
1364 | * can be run by the user. | ||
1365 | */ | ||
1366 | |||
1367 | /* Start monitoring */ | ||
1368 | value = lm85_read_value(client, LM85_REG_CONFIG); | ||
1369 | /* Try to clear LOCK, Set START, save everything else */ | ||
1370 | value = (value & ~0x02) | 0x01; | ||
1371 | dev_dbg(&client->dev, "Setting CONFIG to: 0x%02x\n", value); | ||
1372 | lm85_write_value(client, LM85_REG_CONFIG, value); | ||
1373 | } | ||
1374 | |||
1375 | static struct lm85_data *lm85_update_device(struct device *dev) | 1350 | static struct lm85_data *lm85_update_device(struct device *dev) |
1376 | { | 1351 | { |
1377 | struct i2c_client *client = to_i2c_client(dev); | 1352 | struct i2c_client *client = to_i2c_client(dev); |