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>
This commit is contained in:
parent
0968deb4c8
commit
41936370f1
@ -106,40 +106,6 @@ static const u8 LM83_REG_W_HIGH[] = {
|
||||
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)
|
||||
*/
|
||||
@ -157,6 +123,36 @@ struct lm83_data {
|
||||
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
|
||||
*/
|
||||
@ -390,35 +386,28 @@ static int lm83_remove(struct i2c_client *client)
|
||||
return 0;
|
||||
}
|
||||
|
||||
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);
|
||||
/*
|
||||
* Driver data (common to all clients)
|
||||
*/
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
static const struct i2c_device_id lm83_id[] = {
|
||||
{ "lm83", lm83 },
|
||||
{ "lm82", lm82 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, lm83_id);
|
||||
|
||||
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;
|
||||
}
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user