aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2008-06-25 09:10:30 -0400
committerMark M. Hoffman <mhoffman@lightlink.com>2008-07-31 23:44:03 -0400
commit5f44759470f7248f74947a39cba339009d62052c (patch)
treed599a349467fee830b7009fb604ef2b8bcd48855 /drivers
parente89e22b23bceb3fbbcfb931ad17a564b7c1eaa55 (diff)
hwmon: (lm85) Simplify device initialization function
Clean up and simplify the device initialization function: * Degrade error messages to warnings - what they really are. * Stop warning about VxI mode, we don't really care. * Drop comment about lack of limit initialization - that's the standard way, all hardware monitoring drivers do that. * Only read the configuration register once. * Only write back to the configuration register if needed. * Don't attempt to clear the lock bit, it locks itself to 1. * Move the function to before it's called, so that we no longer need to forware declare it. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hwmon/lm85.c61
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);
318static int lm85_read_value(struct i2c_client *client, u8 reg); 318static int lm85_read_value(struct i2c_client *client, u8 reg);
319static void lm85_write_value(struct i2c_client *client, u8 reg, int value); 319static void lm85_write_value(struct i2c_client *client, u8 reg, int value);
320static struct lm85_data *lm85_update_device(struct device *dev); 320static struct lm85_data *lm85_update_device(struct device *dev);
321static void lm85_init_client(struct i2c_client *client);
322 321
323 322
324static struct i2c_driver lm85_driver = { 323static 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
1088static 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
1089static int lm85_detect(struct i2c_adapter *adapter, int address, 1106static 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
1333static 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
1375static struct lm85_data *lm85_update_device(struct device *dev) 1350static 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);