Commit 71ba0f31 authored by Guenter Roeck's avatar Guenter Roeck

hwmon: (max6650) Introduce local 'dev' variable

This makes the code a bit easier to read.
Reviewed-by: default avatarJean Delvare <jdelvare@suse.de>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 0b5e33b6
...@@ -563,13 +563,14 @@ static const struct attribute_group max6651_group = { ...@@ -563,13 +563,14 @@ static const struct attribute_group max6651_group = {
static int max6650_init_client(struct max6650_data *data, static int max6650_init_client(struct max6650_data *data,
struct i2c_client *client) struct i2c_client *client)
{ {
struct device *dev = &client->dev;
int config; int config;
int err = -EIO; int err = -EIO;
config = i2c_smbus_read_byte_data(client, MAX6650_REG_CONFIG); config = i2c_smbus_read_byte_data(client, MAX6650_REG_CONFIG);
if (config < 0) { if (config < 0) {
dev_err(&client->dev, "Error reading config, aborting.\n"); dev_err(dev, "Error reading config, aborting.\n");
return err; return err;
} }
...@@ -583,11 +584,11 @@ static int max6650_init_client(struct max6650_data *data, ...@@ -583,11 +584,11 @@ static int max6650_init_client(struct max6650_data *data,
config |= MAX6650_CFG_V12; config |= MAX6650_CFG_V12;
break; break;
default: default:
dev_err(&client->dev, "illegal value for fan_voltage (%d)\n", dev_err(dev, "illegal value for fan_voltage (%d)\n",
fan_voltage); fan_voltage);
} }
dev_info(&client->dev, "Fan voltage is set to %dV.\n", dev_info(dev, "Fan voltage is set to %dV.\n",
(config & MAX6650_CFG_V12) ? 12 : 5); (config & MAX6650_CFG_V12) ? 12 : 5);
switch (prescaler) { switch (prescaler) {
...@@ -613,11 +614,10 @@ static int max6650_init_client(struct max6650_data *data, ...@@ -613,11 +614,10 @@ static int max6650_init_client(struct max6650_data *data,
| MAX6650_CFG_PRESCALER_16; | MAX6650_CFG_PRESCALER_16;
break; break;
default: default:
dev_err(&client->dev, "illegal value for prescaler (%d)\n", dev_err(dev, "illegal value for prescaler (%d)\n", prescaler);
prescaler);
} }
dev_info(&client->dev, "Prescaler is set to %d.\n", dev_info(dev, "Prescaler is set to %d.\n",
1 << (config & MAX6650_CFG_PRESCALER_MASK)); 1 << (config & MAX6650_CFG_PRESCALER_MASK));
/* /*
...@@ -627,17 +627,17 @@ static int max6650_init_client(struct max6650_data *data, ...@@ -627,17 +627,17 @@ static int max6650_init_client(struct max6650_data *data,
*/ */
if ((config & MAX6650_CFG_MODE_MASK) == MAX6650_CFG_MODE_OFF) { if ((config & MAX6650_CFG_MODE_MASK) == MAX6650_CFG_MODE_OFF) {
dev_dbg(&client->dev, "Change mode to open loop, full off.\n"); dev_dbg(dev, "Change mode to open loop, full off.\n");
config = (config & ~MAX6650_CFG_MODE_MASK) config = (config & ~MAX6650_CFG_MODE_MASK)
| MAX6650_CFG_MODE_OPEN_LOOP; | MAX6650_CFG_MODE_OPEN_LOOP;
if (i2c_smbus_write_byte_data(client, MAX6650_REG_DAC, 255)) { if (i2c_smbus_write_byte_data(client, MAX6650_REG_DAC, 255)) {
dev_err(&client->dev, "DAC write error, aborting.\n"); dev_err(dev, "DAC write error, aborting.\n");
return err; return err;
} }
} }
if (i2c_smbus_write_byte_data(client, MAX6650_REG_CONFIG, config)) { if (i2c_smbus_write_byte_data(client, MAX6650_REG_CONFIG, config)) {
dev_err(&client->dev, "Config write error, aborting.\n"); dev_err(dev, "Config write error, aborting.\n");
return err; return err;
} }
...@@ -650,12 +650,12 @@ static int max6650_init_client(struct max6650_data *data, ...@@ -650,12 +650,12 @@ static int max6650_init_client(struct max6650_data *data,
static int max6650_probe(struct i2c_client *client, static int max6650_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct device *dev = &client->dev;
struct max6650_data *data; struct max6650_data *data;
struct device *hwmon_dev; struct device *hwmon_dev;
int err; int err;
data = devm_kzalloc(&client->dev, sizeof(struct max6650_data), data = devm_kzalloc(dev, sizeof(struct max6650_data), GFP_KERNEL);
GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
...@@ -675,7 +675,7 @@ static int max6650_probe(struct i2c_client *client, ...@@ -675,7 +675,7 @@ static int max6650_probe(struct i2c_client *client,
if (data->nr_fans == 4) if (data->nr_fans == 4)
data->groups[1] = &max6651_group; data->groups[1] = &max6651_group;
hwmon_dev = devm_hwmon_device_register_with_groups(&client->dev, hwmon_dev = devm_hwmon_device_register_with_groups(dev,
client->name, data, client->name, data,
data->groups); data->groups);
return PTR_ERR_OR_ZERO(hwmon_dev); return PTR_ERR_OR_ZERO(hwmon_dev);
......
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