Skip to content

Commit

Permalink
hwmon: (lm83) Rearange code to avoid forward declarations
Browse files Browse the repository at this point in the history
Avoid forward declarations by rearranging code.
No functional change.

Signed-off-by: Guenter Roeck <[email protected]>
  • Loading branch information
groeck committed May 21, 2014
1 parent 0968deb commit 4193637
Showing 1 changed file with 50 additions and 61 deletions.
111 changes: 50 additions & 61 deletions drivers/hwmon/lm83.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
*/
Expand All @@ -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
*/
Expand Down Expand Up @@ -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);

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;
}
/*
* Driver data (common to all clients)
*/

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);

Expand Down

0 comments on commit 4193637

Please sign in to comment.