Commit 41936370 authored by Guenter Roeck's avatar Guenter Roeck

hwmon: (lm83) Rearange code to avoid forward declarations

Avoid forward declarations by rearranging code.
No functional change.
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 0968deb4
...@@ -106,40 +106,6 @@ static const u8 LM83_REG_W_HIGH[] = { ...@@ -106,40 +106,6 @@ static const u8 LM83_REG_W_HIGH[] = {
LM83_REG_W_TCRIT, LM83_REG_W_TCRIT,
}; };
/*
* Functions declaration
*/
static int lm83_detect(struct i2c_client *new_client,
struct i2c_board_info *info);
static int lm83_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int lm83_remove(struct i2c_client *client);
static struct lm83_data *lm83_update_device(struct device *dev);
/*
* Driver data (common to all clients)
*/
static const struct i2c_device_id lm83_id[] = {
{ "lm83", lm83 },
{ "lm82", lm82 },
{ }
};
MODULE_DEVICE_TABLE(i2c, lm83_id);
static struct i2c_driver lm83_driver = {
.class = I2C_CLASS_HWMON,
.driver = {
.name = "lm83",
},
.probe = lm83_probe,
.remove = lm83_remove,
.id_table = lm83_id,
.detect = lm83_detect,
.address_list = normal_i2c,
};
/* /*
* Client data (each client gets its own) * Client data (each client gets its own)
*/ */
...@@ -157,6 +123,36 @@ struct lm83_data { ...@@ -157,6 +123,36 @@ struct lm83_data {
u16 alarms; /* bitvector, combined */ u16 alarms; /* bitvector, combined */
}; };
static struct lm83_data *lm83_update_device(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct lm83_data *data = i2c_get_clientdata(client);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
int nr;
dev_dbg(&client->dev, "Updating lm83 data.\n");
for (nr = 0; nr < 9; nr++) {
data->temp[nr] =
i2c_smbus_read_byte_data(client,
LM83_REG_R_TEMP[nr]);
}
data->alarms =
i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS1)
+ (i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS2)
<< 8);
data->last_updated = jiffies;
data->valid = 1;
}
mutex_unlock(&data->update_lock);
return data;
}
/* /*
* Sysfs stuff * Sysfs stuff
*/ */
...@@ -390,35 +386,28 @@ static int lm83_remove(struct i2c_client *client) ...@@ -390,35 +386,28 @@ static int lm83_remove(struct i2c_client *client)
return 0; return 0;
} }
static struct lm83_data *lm83_update_device(struct device *dev) /*
{ * Driver data (common to all clients)
struct i2c_client *client = to_i2c_client(dev); */
struct lm83_data *data = i2c_get_clientdata(client);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
int nr;
dev_dbg(&client->dev, "Updating lm83 data.\n");
for (nr = 0; nr < 9; nr++) {
data->temp[nr] =
i2c_smbus_read_byte_data(client,
LM83_REG_R_TEMP[nr]);
}
data->alarms =
i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS1)
+ (i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS2)
<< 8);
data->last_updated = jiffies;
data->valid = 1;
}
mutex_unlock(&data->update_lock); static const struct i2c_device_id lm83_id[] = {
{ "lm83", lm83 },
{ "lm82", lm82 },
{ }
};
MODULE_DEVICE_TABLE(i2c, lm83_id);
return data; static struct i2c_driver lm83_driver = {
} .class = I2C_CLASS_HWMON,
.driver = {
.name = "lm83",
},
.probe = lm83_probe,
.remove = lm83_remove,
.id_table = lm83_id,
.detect = lm83_detect,
.address_list = normal_i2c,
};
module_i2c_driver(lm83_driver); module_i2c_driver(lm83_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment