aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adt7470.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2014-07-16 11:12:05 -0400
committerGuenter Roeck <linux@roeck-us.net>2014-08-04 10:01:39 -0400
commit9027d933a91e1430ebcd9b9fb8da538cb40284ef (patch)
tree560a87f66b457601e4e5cb8771c70d25a379ae5b /drivers/hwmon/adt7470.c
parent573bfe67ca1057febc6a0ccd8caff9a9fdb01994 (diff)
hwmon: (adt7470) Avoid forward declaration
Reorder functions to avoid forward declaration. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/adt7470.c')
-rw-r--r--drivers/hwmon/adt7470.c66
1 files changed, 30 insertions, 36 deletions
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
index 9ee3913850d6..7dfb1864c6e4 100644
--- a/drivers/hwmon/adt7470.c
+++ b/drivers/hwmon/adt7470.c
@@ -175,30 +175,6 @@ struct adt7470_data {
175 unsigned int auto_update_interval; 175 unsigned int auto_update_interval;
176}; 176};
177 177
178static int adt7470_probe(struct i2c_client *client,
179 const struct i2c_device_id *id);
180static int adt7470_detect(struct i2c_client *client,
181 struct i2c_board_info *info);
182static int adt7470_remove(struct i2c_client *client);
183
184static const struct i2c_device_id adt7470_id[] = {
185 { "adt7470", 0 },
186 { }
187};
188MODULE_DEVICE_TABLE(i2c, adt7470_id);
189
190static struct i2c_driver adt7470_driver = {
191 .class = I2C_CLASS_HWMON,
192 .driver = {
193 .name = "adt7470",
194 },
195 .probe = adt7470_probe,
196 .remove = adt7470_remove,
197 .id_table = adt7470_id,
198 .detect = adt7470_detect,
199 .address_list = normal_i2c,
200};
201
202/* 178/*
203 * 16-bit registers on the ADT7470 are low-byte first. The data sheet says 179 * 16-bit registers on the ADT7470 are low-byte first. The data sheet says
204 * that the low byte must be read before the high byte. 180 * that the low byte must be read before the high byte.
@@ -218,18 +194,6 @@ static inline int adt7470_write_word_data(struct i2c_client *client, u8 reg,
218 || i2c_smbus_write_byte_data(client, reg + 1, value >> 8); 194 || i2c_smbus_write_byte_data(client, reg + 1, value >> 8);
219} 195}
220 196
221static void adt7470_init_client(struct i2c_client *client)
222{
223 int reg = i2c_smbus_read_byte_data(client, ADT7470_REG_CFG);
224
225 if (reg < 0) {
226 dev_err(&client->dev, "cannot read configuration register\n");
227 } else {
228 /* start monitoring (and do a self-test) */
229 i2c_smbus_write_byte_data(client, ADT7470_REG_CFG, reg | 3);
230 }
231}
232
233/* Probe for temperature sensors. Assumes lock is held */ 197/* Probe for temperature sensors. Assumes lock is held */
234static int adt7470_read_temperatures(struct i2c_client *client, 198static int adt7470_read_temperatures(struct i2c_client *client,
235 struct adt7470_data *data) 199 struct adt7470_data *data)
@@ -1250,6 +1214,18 @@ static int adt7470_detect(struct i2c_client *client,
1250 return 0; 1214 return 0;
1251} 1215}
1252 1216
1217static void adt7470_init_client(struct i2c_client *client)
1218{
1219 int reg = i2c_smbus_read_byte_data(client, ADT7470_REG_CFG);
1220
1221 if (reg < 0) {
1222 dev_err(&client->dev, "cannot read configuration register\n");
1223 } else {
1224 /* start monitoring (and do a self-test) */
1225 i2c_smbus_write_byte_data(client, ADT7470_REG_CFG, reg | 3);
1226 }
1227}
1228
1253static int adt7470_probe(struct i2c_client *client, 1229static int adt7470_probe(struct i2c_client *client,
1254 const struct i2c_device_id *id) 1230 const struct i2c_device_id *id)
1255{ 1231{
@@ -1312,6 +1288,24 @@ static int adt7470_remove(struct i2c_client *client)
1312 return 0; 1288 return 0;
1313} 1289}
1314 1290
1291static const struct i2c_device_id adt7470_id[] = {
1292 { "adt7470", 0 },
1293 { }
1294};
1295MODULE_DEVICE_TABLE(i2c, adt7470_id);
1296
1297static struct i2c_driver adt7470_driver = {
1298 .class = I2C_CLASS_HWMON,
1299 .driver = {
1300 .name = "adt7470",
1301 },
1302 .probe = adt7470_probe,
1303 .remove = adt7470_remove,
1304 .id_table = adt7470_id,
1305 .detect = adt7470_detect,
1306 .address_list = normal_i2c,
1307};
1308
1315module_i2c_driver(adt7470_driver); 1309module_i2c_driver(adt7470_driver);
1316 1310
1317MODULE_AUTHOR("Darrick J. Wong <darrick.wong@oracle.com>"); 1311MODULE_AUTHOR("Darrick J. Wong <darrick.wong@oracle.com>");