Commit f28dc2f7 authored by Jean Delvare's avatar Jean Delvare Committed by Mark M. Hoffman

hwmon: (gl520sm) Various cleanups

* Drop trailing spaces
* Drop unused driver ID
* Drop stray backslashes in macros
* Rename new_client to client
* Drop redundant initializations to 0
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarMark M. Hoffman <mhoffman@lightlink.com>
parent e0ae87a4
...@@ -114,7 +114,6 @@ static struct i2c_driver gl520_driver = { ...@@ -114,7 +114,6 @@ static struct i2c_driver gl520_driver = {
.driver = { .driver = {
.name = "gl520sm", .name = "gl520sm",
}, },
.id = I2C_DRIVERID_GL520,
.attach_adapter = gl520_attach_adapter, .attach_adapter = gl520_attach_adapter,
.detach_client = gl520_detach_client, .detach_client = gl520_detach_client,
}; };
...@@ -194,7 +193,7 @@ sysfs_ro_n(cpu, n, _vid, GL520_REG_VID_INPUT) ...@@ -194,7 +193,7 @@ sysfs_ro_n(cpu, n, _vid, GL520_REG_VID_INPUT)
#define sysfs_in(n) \ #define sysfs_in(n) \
sysfs_ro_n(in, n, _input, GL520_REG_IN##n##INPUT) \ sysfs_ro_n(in, n, _input, GL520_REG_IN##n##INPUT) \
sysfs_rw_n(in, n, _min, GL520_REG_IN##n##_MIN) \ sysfs_rw_n(in, n, _min, GL520_REG_IN##n##_MIN) \
sysfs_rw_n(in, n, _max, GL520_REG_IN##n##_MAX) \ sysfs_rw_n(in, n, _max, GL520_REG_IN##n##_MAX)
#define sysfs_fan(n) \ #define sysfs_fan(n) \
sysfs_ro_n(fan, n, _input, GL520_REG_FAN_INPUT) \ sysfs_ro_n(fan, n, _input, GL520_REG_FAN_INPUT) \
...@@ -202,7 +201,7 @@ sysfs_rw_n(fan, n, _min, GL520_REG_FAN_MIN) \ ...@@ -202,7 +201,7 @@ sysfs_rw_n(fan, n, _min, GL520_REG_FAN_MIN) \
sysfs_rw_n(fan, n, _div, GL520_REG_FAN_DIV) sysfs_rw_n(fan, n, _div, GL520_REG_FAN_DIV)
#define sysfs_fan_off(n) \ #define sysfs_fan_off(n) \
sysfs_rw_n(fan, n, _off, GL520_REG_FAN_OFF) \ sysfs_rw_n(fan, n, _off, GL520_REG_FAN_OFF)
#define sysfs_temp(n) \ #define sysfs_temp(n) \
sysfs_ro_n(temp, n, _input, GL520_REG_TEMP##n##_INPUT) \ sysfs_ro_n(temp, n, _input, GL520_REG_TEMP##n##_INPUT) \
...@@ -553,7 +552,7 @@ static int gl520_attach_adapter(struct i2c_adapter *adapter) ...@@ -553,7 +552,7 @@ static int gl520_attach_adapter(struct i2c_adapter *adapter)
static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) static int gl520_detect(struct i2c_adapter *adapter, int address, int kind)
{ {
struct i2c_client *new_client; struct i2c_client *client;
struct gl520_data *data; struct gl520_data *data;
int err = 0; int err = 0;
...@@ -570,59 +569,57 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -570,59 +569,57 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind)
goto exit; goto exit;
} }
new_client = &data->client; client = &data->client;
i2c_set_clientdata(new_client, data); i2c_set_clientdata(client, data);
new_client->addr = address; client->addr = address;
new_client->adapter = adapter; client->adapter = adapter;
new_client->driver = &gl520_driver; client->driver = &gl520_driver;
new_client->flags = 0;
/* Determine the chip type. */ /* Determine the chip type. */
if (kind < 0) { if (kind < 0) {
if ((gl520_read_value(new_client, GL520_REG_CHIP_ID) != 0x20) || if ((gl520_read_value(client, GL520_REG_CHIP_ID) != 0x20) ||
((gl520_read_value(new_client, GL520_REG_REVISION) & 0x7f) != 0x00) || ((gl520_read_value(client, GL520_REG_REVISION) & 0x7f) != 0x00) ||
((gl520_read_value(new_client, GL520_REG_CONF) & 0x80) != 0x00)) { ((gl520_read_value(client, GL520_REG_CONF) & 0x80) != 0x00)) {
dev_dbg(&new_client->dev, "Unknown chip type, skipping\n"); dev_dbg(&client->dev, "Unknown chip type, skipping\n");
goto exit_free; goto exit_free;
} }
} }
/* Fill in the remaining client fields */ /* Fill in the remaining client fields */
strlcpy(new_client->name, "gl520sm", I2C_NAME_SIZE); strlcpy(client->name, "gl520sm", I2C_NAME_SIZE);
data->valid = 0;
mutex_init(&data->update_lock); mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */ /* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client))) if ((err = i2c_attach_client(client)))
goto exit_free; goto exit_free;
/* Initialize the GL520SM chip */ /* Initialize the GL520SM chip */
gl520_init_client(new_client); gl520_init_client(client);
/* Register sysfs hooks */ /* Register sysfs hooks */
if ((err = sysfs_create_group(&new_client->dev.kobj, &gl520_group))) if ((err = sysfs_create_group(&client->dev.kobj, &gl520_group)))
goto exit_detach; goto exit_detach;
if (data->two_temps) { if (data->two_temps) {
if ((err = device_create_file(&new_client->dev, if ((err = device_create_file(&client->dev,
&dev_attr_temp2_input)) &dev_attr_temp2_input))
|| (err = device_create_file(&new_client->dev, || (err = device_create_file(&client->dev,
&dev_attr_temp2_max)) &dev_attr_temp2_max))
|| (err = device_create_file(&new_client->dev, || (err = device_create_file(&client->dev,
&dev_attr_temp2_max_hyst))) &dev_attr_temp2_max_hyst)))
goto exit_remove_files; goto exit_remove_files;
} else { } else {
if ((err = device_create_file(&new_client->dev, if ((err = device_create_file(&client->dev,
&dev_attr_in4_input)) &dev_attr_in4_input))
|| (err = device_create_file(&new_client->dev, || (err = device_create_file(&client->dev,
&dev_attr_in4_min)) &dev_attr_in4_min))
|| (err = device_create_file(&new_client->dev, || (err = device_create_file(&client->dev,
&dev_attr_in4_max))) &dev_attr_in4_max)))
goto exit_remove_files; goto exit_remove_files;
} }
data->hwmon_dev = hwmon_device_register(&new_client->dev); data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) { if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev); err = PTR_ERR(data->hwmon_dev);
goto exit_remove_files; goto exit_remove_files;
...@@ -631,10 +628,10 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -631,10 +628,10 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind)
return 0; return 0;
exit_remove_files: exit_remove_files:
sysfs_remove_group(&new_client->dev.kobj, &gl520_group); sysfs_remove_group(&client->dev.kobj, &gl520_group);
sysfs_remove_group(&new_client->dev.kobj, &gl520_group_opt); sysfs_remove_group(&client->dev.kobj, &gl520_group_opt);
exit_detach: exit_detach:
i2c_detach_client(new_client); i2c_detach_client(client);
exit_free: exit_free:
kfree(data); kfree(data);
exit: exit:
......
...@@ -109,7 +109,6 @@ ...@@ -109,7 +109,6 @@
#define I2C_DRIVERID_BT869 1013 #define I2C_DRIVERID_BT869 1013
#define I2C_DRIVERID_MAXILIFE 1014 #define I2C_DRIVERID_MAXILIFE 1014
#define I2C_DRIVERID_MATORB 1015 #define I2C_DRIVERID_MATORB 1015
#define I2C_DRIVERID_GL520 1016
#define I2C_DRIVERID_THMC50 1017 #define I2C_DRIVERID_THMC50 1017
#define I2C_DRIVERID_ADM1025 1020 #define I2C_DRIVERID_ADM1025 1020
#define I2C_DRIVERID_LM87 1021 #define I2C_DRIVERID_LM87 1021
......
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