aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2014-04-12 15:39:41 -0400
committerGuenter Roeck <linux@roeck-us.net>2014-05-21 19:02:26 -0400
commit41936370f13046b757e4f1051d11007e3b151e8e (patch)
tree42da1df4ee54820b6e01d142e72b25d16e3f0e70 /drivers/hwmon
parent0968deb4c88e3b3bc589ab11e7ac1bb0a9a38654 (diff)
hwmon: (lm83) Rearange code to avoid forward declarations
Avoid forward declarations by rearranging code. No functional change. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/lm83.c111
1 files changed, 50 insertions, 61 deletions
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c
index 90cba322e840..f9fcc91d02ca 100644
--- a/drivers/hwmon/lm83.c
+++ b/drivers/hwmon/lm83.c
@@ -107,40 +107,6 @@ static const u8 LM83_REG_W_HIGH[] = {
107}; 107};
108 108
109/* 109/*
110 * Functions declaration
111 */
112
113static int lm83_detect(struct i2c_client *new_client,
114 struct i2c_board_info *info);
115static int lm83_probe(struct i2c_client *client,
116 const struct i2c_device_id *id);
117static int lm83_remove(struct i2c_client *client);
118static struct lm83_data *lm83_update_device(struct device *dev);
119
120/*
121 * Driver data (common to all clients)
122 */
123
124static const struct i2c_device_id lm83_id[] = {
125 { "lm83", lm83 },
126 { "lm82", lm82 },
127 { }
128};
129MODULE_DEVICE_TABLE(i2c, lm83_id);
130
131static struct i2c_driver lm83_driver = {
132 .class = I2C_CLASS_HWMON,
133 .driver = {
134 .name = "lm83",
135 },
136 .probe = lm83_probe,
137 .remove = lm83_remove,
138 .id_table = lm83_id,
139 .detect = lm83_detect,
140 .address_list = normal_i2c,
141};
142
143/*
144 * Client data (each client gets its own) 110 * Client data (each client gets its own)
145 */ 111 */
146 112
@@ -157,6 +123,36 @@ struct lm83_data {
157 u16 alarms; /* bitvector, combined */ 123 u16 alarms; /* bitvector, combined */
158}; 124};
159 125
126static struct lm83_data *lm83_update_device(struct device *dev)
127{
128 struct i2c_client *client = to_i2c_client(dev);
129 struct lm83_data *data = i2c_get_clientdata(client);
130
131 mutex_lock(&data->update_lock);
132
133 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
134 int nr;
135
136 dev_dbg(&client->dev, "Updating lm83 data.\n");
137 for (nr = 0; nr < 9; nr++) {
138 data->temp[nr] =
139 i2c_smbus_read_byte_data(client,
140 LM83_REG_R_TEMP[nr]);
141 }
142 data->alarms =
143 i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS1)
144 + (i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS2)
145 << 8);
146
147 data->last_updated = jiffies;
148 data->valid = 1;
149 }
150
151 mutex_unlock(&data->update_lock);
152
153 return data;
154}
155
160/* 156/*
161 * Sysfs stuff 157 * Sysfs stuff
162 */ 158 */
@@ -390,35 +386,28 @@ static int lm83_remove(struct i2c_client *client)
390 return 0; 386 return 0;
391} 387}
392 388
393static struct lm83_data *lm83_update_device(struct device *dev) 389/*
394{ 390 * Driver data (common to all clients)
395 struct i2c_client *client = to_i2c_client(dev); 391 */
396 struct lm83_data *data = i2c_get_clientdata(client);
397
398 mutex_lock(&data->update_lock);
399
400 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
401 int nr;
402
403 dev_dbg(&client->dev, "Updating lm83 data.\n");
404 for (nr = 0; nr < 9; nr++) {
405 data->temp[nr] =
406 i2c_smbus_read_byte_data(client,
407 LM83_REG_R_TEMP[nr]);
408 }
409 data->alarms =
410 i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS1)
411 + (i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS2)
412 << 8);
413
414 data->last_updated = jiffies;
415 data->valid = 1;
416 }
417 392
418 mutex_unlock(&data->update_lock); 393static const struct i2c_device_id lm83_id[] = {
394 { "lm83", lm83 },
395 { "lm82", lm82 },
396 { }
397};
398MODULE_DEVICE_TABLE(i2c, lm83_id);
419 399
420 return data; 400static struct i2c_driver lm83_driver = {
421} 401 .class = I2C_CLASS_HWMON,
402 .driver = {
403 .name = "lm83",
404 },
405 .probe = lm83_probe,
406 .remove = lm83_remove,
407 .id_table = lm83_id,
408 .detect = lm83_detect,
409 .address_list = normal_i2c,
410};
422 411
423module_i2c_driver(lm83_driver); 412module_i2c_driver(lm83_driver);
424 413