Skip to content

Commit

Permalink
hwmon: VRM is not written to registers
Browse files Browse the repository at this point in the history
What was true of reading the VRM value is also true of writing it: not
being a register value, it doesn't need hardware access, so we don't
need a reference to the i2c client. This allows for a minor code
cleanup. As gcc appears to be smart enough to simplify the generated
code by itself, this cleanup only affects the source code, the
generated binaries are unchanged.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
  • Loading branch information
Jean Delvare authored and Mark M. Hoffman committed Feb 8, 2008
1 parent 345a222 commit 8f74efe
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 26 deletions.
3 changes: 1 addition & 2 deletions drivers/hwmon/adm1025.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,7 @@ show_vrm(struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t set_vrm(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct i2c_client *client = to_i2c_client(dev);
struct adm1025_data *data = i2c_get_clientdata(client);
struct adm1025_data *data = dev_get_drvdata(dev);
data->vrm = simple_strtoul(buf, NULL, 10);
return count;
}
Expand Down
6 changes: 2 additions & 4 deletions drivers/hwmon/asb100.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,10 +519,8 @@ static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char

static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct i2c_client *client = to_i2c_client(dev);
struct asb100_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
data->vrm = val;
struct asb100_data *data = dev_get_drvdata(dev);
data->vrm = simple_strtoul(buf, NULL, 10);
return count;
}

Expand Down
8 changes: 2 additions & 6 deletions drivers/hwmon/lm85.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,8 @@ static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, c

static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct i2c_client *client = to_i2c_client(dev);
struct lm85_data *data = i2c_get_clientdata(client);
u32 val;

val = simple_strtoul(buf, NULL, 10);
data->vrm = val;
struct lm85_data *data = dev_get_drvdata(dev);
data->vrm = simple_strtoul(buf, NULL, 10);
return count;
}

Expand Down
3 changes: 1 addition & 2 deletions drivers/hwmon/lm87.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,7 @@ static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char
}
static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct i2c_client *client = to_i2c_client(dev);
struct lm87_data *data = i2c_get_clientdata(client);
struct lm87_data *data = dev_get_drvdata(dev);
data->vrm = simple_strtoul(buf, NULL, 10);
return count;
}
Expand Down
3 changes: 1 addition & 2 deletions drivers/hwmon/smsc47m192.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,7 @@ static ssize_t show_vrm(struct device *dev, struct device_attribute *attr,
static ssize_t set_vrm(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct i2c_client *client = to_i2c_client(dev);
struct smsc47m192_data *data = i2c_get_clientdata(client);
struct smsc47m192_data *data = dev_get_drvdata(dev);
data->vrm = simple_strtoul(buf, NULL, 10);
return count;
}
Expand Down
6 changes: 2 additions & 4 deletions drivers/hwmon/w83791d.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,14 +840,12 @@ static ssize_t store_vrm_reg(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct i2c_client *client = to_i2c_client(dev);
struct w83791d_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
struct w83791d_data *data = dev_get_drvdata(dev);

/* No lock needed as vrm is internal to the driver
(not read from a chip register) and so is not
updated in w83791d_update_device() */
data->vrm = val;
data->vrm = simple_strtoul(buf, NULL, 10);

return count;
}
Expand Down
8 changes: 2 additions & 6 deletions drivers/hwmon/w83793.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ static struct i2c_driver w83793_driver = {
static ssize_t
show_vrm(struct device *dev, struct device_attribute *attr, char *buf)
{
struct i2c_client *client = to_i2c_client(dev);
struct w83793_data *data = i2c_get_clientdata(client);

struct w83793_data *data = dev_get_drvdata(dev);
return sprintf(buf, "%d\n", data->vrm);
}

Expand All @@ -264,9 +262,7 @@ static ssize_t
store_vrm(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct i2c_client *client = to_i2c_client(dev);
struct w83793_data *data = i2c_get_clientdata(client);

struct w83793_data *data = dev_get_drvdata(dev);
data->vrm = simple_strtoul(buf, NULL, 10);
return count;
}
Expand Down

0 comments on commit 8f74efe

Please sign in to comment.