mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-15 09:34:17 +00:00
hwmon: (lm87) Fix: do not use assignment in if condition
Fix checkpatch issue: ERROR: do not use assignment in if condition Replace repeated calls to device_create_file() with calls to sysfs_create_group. Cc: Jean Delvare <khali@linux-fr.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Jean Delvare <khali@linux-fr.org>
This commit is contained in:
parent
c6370dbe45
commit
073f1e6c89
@ -700,34 +700,69 @@ static const struct attribute_group lm87_group = {
|
|||||||
.attrs = lm87_attributes,
|
.attrs = lm87_attributes,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct attribute *lm87_attributes_opt[] = {
|
static struct attribute *lm87_attributes_in6[] = {
|
||||||
&dev_attr_in6_input.attr,
|
&dev_attr_in6_input.attr,
|
||||||
&dev_attr_in6_min.attr,
|
&dev_attr_in6_min.attr,
|
||||||
&dev_attr_in6_max.attr,
|
&dev_attr_in6_max.attr,
|
||||||
&sensor_dev_attr_in6_alarm.dev_attr.attr,
|
&sensor_dev_attr_in6_alarm.dev_attr.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct attribute_group lm87_group_in6 = {
|
||||||
|
.attrs = lm87_attributes_in6,
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct attribute *lm87_attributes_fan1[] = {
|
||||||
&dev_attr_fan1_input.attr,
|
&dev_attr_fan1_input.attr,
|
||||||
&dev_attr_fan1_min.attr,
|
&dev_attr_fan1_min.attr,
|
||||||
&dev_attr_fan1_div.attr,
|
&dev_attr_fan1_div.attr,
|
||||||
&sensor_dev_attr_fan1_alarm.dev_attr.attr,
|
&sensor_dev_attr_fan1_alarm.dev_attr.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct attribute_group lm87_group_fan1 = {
|
||||||
|
.attrs = lm87_attributes_fan1,
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct attribute *lm87_attributes_in7[] = {
|
||||||
&dev_attr_in7_input.attr,
|
&dev_attr_in7_input.attr,
|
||||||
&dev_attr_in7_min.attr,
|
&dev_attr_in7_min.attr,
|
||||||
&dev_attr_in7_max.attr,
|
&dev_attr_in7_max.attr,
|
||||||
&sensor_dev_attr_in7_alarm.dev_attr.attr,
|
&sensor_dev_attr_in7_alarm.dev_attr.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct attribute_group lm87_group_in7 = {
|
||||||
|
.attrs = lm87_attributes_in7,
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct attribute *lm87_attributes_fan2[] = {
|
||||||
&dev_attr_fan2_input.attr,
|
&dev_attr_fan2_input.attr,
|
||||||
&dev_attr_fan2_min.attr,
|
&dev_attr_fan2_min.attr,
|
||||||
&dev_attr_fan2_div.attr,
|
&dev_attr_fan2_div.attr,
|
||||||
&sensor_dev_attr_fan2_alarm.dev_attr.attr,
|
&sensor_dev_attr_fan2_alarm.dev_attr.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct attribute_group lm87_group_fan2 = {
|
||||||
|
.attrs = lm87_attributes_fan2,
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct attribute *lm87_attributes_temp3[] = {
|
||||||
&dev_attr_temp3_input.attr,
|
&dev_attr_temp3_input.attr,
|
||||||
&dev_attr_temp3_max.attr,
|
&dev_attr_temp3_max.attr,
|
||||||
&dev_attr_temp3_min.attr,
|
&dev_attr_temp3_min.attr,
|
||||||
&dev_attr_temp3_crit.attr,
|
&dev_attr_temp3_crit.attr,
|
||||||
&sensor_dev_attr_temp3_alarm.dev_attr.attr,
|
&sensor_dev_attr_temp3_alarm.dev_attr.attr,
|
||||||
&sensor_dev_attr_temp3_fault.dev_attr.attr,
|
&sensor_dev_attr_temp3_fault.dev_attr.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct attribute_group lm87_group_temp3 = {
|
||||||
|
.attrs = lm87_attributes_temp3,
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct attribute *lm87_attributes_in0_5[] = {
|
||||||
&dev_attr_in0_input.attr,
|
&dev_attr_in0_input.attr,
|
||||||
&dev_attr_in0_min.attr,
|
&dev_attr_in0_min.attr,
|
||||||
&dev_attr_in0_max.attr,
|
&dev_attr_in0_max.attr,
|
||||||
@ -736,15 +771,21 @@ static struct attribute *lm87_attributes_opt[] = {
|
|||||||
&dev_attr_in5_min.attr,
|
&dev_attr_in5_min.attr,
|
||||||
&dev_attr_in5_max.attr,
|
&dev_attr_in5_max.attr,
|
||||||
&sensor_dev_attr_in5_alarm.dev_attr.attr,
|
&sensor_dev_attr_in5_alarm.dev_attr.attr,
|
||||||
|
|
||||||
&dev_attr_cpu0_vid.attr,
|
|
||||||
&dev_attr_vrm.attr,
|
|
||||||
|
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct attribute_group lm87_group_opt = {
|
static const struct attribute_group lm87_group_in0_5 = {
|
||||||
.attrs = lm87_attributes_opt,
|
.attrs = lm87_attributes_in0_5,
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct attribute *lm87_attributes_vid[] = {
|
||||||
|
&dev_attr_cpu0_vid.attr,
|
||||||
|
&dev_attr_vrm.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct attribute_group lm87_group_vid = {
|
||||||
|
.attrs = lm87_attributes_vid,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Return 0 if detection is successful, -ENODEV otherwise */
|
/* Return 0 if detection is successful, -ENODEV otherwise */
|
||||||
@ -782,6 +823,20 @@ static int lm87_detect(struct i2c_client *new_client,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void lm87_remove_files(struct i2c_client *client)
|
||||||
|
{
|
||||||
|
struct device *dev = &client->dev;
|
||||||
|
|
||||||
|
sysfs_remove_group(&dev->kobj, &lm87_group);
|
||||||
|
sysfs_remove_group(&dev->kobj, &lm87_group_in6);
|
||||||
|
sysfs_remove_group(&dev->kobj, &lm87_group_fan1);
|
||||||
|
sysfs_remove_group(&dev->kobj, &lm87_group_in7);
|
||||||
|
sysfs_remove_group(&dev->kobj, &lm87_group_fan2);
|
||||||
|
sysfs_remove_group(&dev->kobj, &lm87_group_temp3);
|
||||||
|
sysfs_remove_group(&dev->kobj, &lm87_group_in0_5);
|
||||||
|
sysfs_remove_group(&dev->kobj, &lm87_group_vid);
|
||||||
|
}
|
||||||
|
|
||||||
static int lm87_probe(struct i2c_client *new_client,
|
static int lm87_probe(struct i2c_client *new_client,
|
||||||
const struct i2c_device_id *id)
|
const struct i2c_device_id *id)
|
||||||
{
|
{
|
||||||
@ -816,89 +871,46 @@ static int lm87_probe(struct i2c_client *new_client,
|
|||||||
goto exit_free;
|
goto exit_free;
|
||||||
|
|
||||||
if (data->channel & CHAN_NO_FAN(0)) {
|
if (data->channel & CHAN_NO_FAN(0)) {
|
||||||
if ((err = device_create_file(&new_client->dev,
|
err = sysfs_create_group(&new_client->dev.kobj,
|
||||||
&dev_attr_in6_input))
|
&lm87_group_in6);
|
||||||
|| (err = device_create_file(&new_client->dev,
|
if (err)
|
||||||
&dev_attr_in6_min))
|
|
||||||
|| (err = device_create_file(&new_client->dev,
|
|
||||||
&dev_attr_in6_max))
|
|
||||||
|| (err = device_create_file(&new_client->dev,
|
|
||||||
&sensor_dev_attr_in6_alarm.dev_attr)))
|
|
||||||
goto exit_remove;
|
goto exit_remove;
|
||||||
} else {
|
} else {
|
||||||
if ((err = device_create_file(&new_client->dev,
|
err = sysfs_create_group(&new_client->dev.kobj,
|
||||||
&dev_attr_fan1_input))
|
&lm87_group_fan1);
|
||||||
|| (err = device_create_file(&new_client->dev,
|
if (err)
|
||||||
&dev_attr_fan1_min))
|
|
||||||
|| (err = device_create_file(&new_client->dev,
|
|
||||||
&dev_attr_fan1_div))
|
|
||||||
|| (err = device_create_file(&new_client->dev,
|
|
||||||
&sensor_dev_attr_fan1_alarm.dev_attr)))
|
|
||||||
goto exit_remove;
|
goto exit_remove;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->channel & CHAN_NO_FAN(1)) {
|
if (data->channel & CHAN_NO_FAN(1)) {
|
||||||
if ((err = device_create_file(&new_client->dev,
|
err = sysfs_create_group(&new_client->dev.kobj,
|
||||||
&dev_attr_in7_input))
|
&lm87_group_in7);
|
||||||
|| (err = device_create_file(&new_client->dev,
|
if (err)
|
||||||
&dev_attr_in7_min))
|
|
||||||
|| (err = device_create_file(&new_client->dev,
|
|
||||||
&dev_attr_in7_max))
|
|
||||||
|| (err = device_create_file(&new_client->dev,
|
|
||||||
&sensor_dev_attr_in7_alarm.dev_attr)))
|
|
||||||
goto exit_remove;
|
goto exit_remove;
|
||||||
} else {
|
} else {
|
||||||
if ((err = device_create_file(&new_client->dev,
|
err = sysfs_create_group(&new_client->dev.kobj,
|
||||||
&dev_attr_fan2_input))
|
&lm87_group_fan2);
|
||||||
|| (err = device_create_file(&new_client->dev,
|
if (err)
|
||||||
&dev_attr_fan2_min))
|
|
||||||
|| (err = device_create_file(&new_client->dev,
|
|
||||||
&dev_attr_fan2_div))
|
|
||||||
|| (err = device_create_file(&new_client->dev,
|
|
||||||
&sensor_dev_attr_fan2_alarm.dev_attr)))
|
|
||||||
goto exit_remove;
|
goto exit_remove;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->channel & CHAN_TEMP3) {
|
if (data->channel & CHAN_TEMP3) {
|
||||||
if ((err = device_create_file(&new_client->dev,
|
err = sysfs_create_group(&new_client->dev.kobj,
|
||||||
&dev_attr_temp3_input))
|
&lm87_group_temp3);
|
||||||
|| (err = device_create_file(&new_client->dev,
|
if (err)
|
||||||
&dev_attr_temp3_max))
|
|
||||||
|| (err = device_create_file(&new_client->dev,
|
|
||||||
&dev_attr_temp3_min))
|
|
||||||
|| (err = device_create_file(&new_client->dev,
|
|
||||||
&dev_attr_temp3_crit))
|
|
||||||
|| (err = device_create_file(&new_client->dev,
|
|
||||||
&sensor_dev_attr_temp3_alarm.dev_attr))
|
|
||||||
|| (err = device_create_file(&new_client->dev,
|
|
||||||
&sensor_dev_attr_temp3_fault.dev_attr)))
|
|
||||||
goto exit_remove;
|
goto exit_remove;
|
||||||
} else {
|
} else {
|
||||||
if ((err = device_create_file(&new_client->dev,
|
err = sysfs_create_group(&new_client->dev.kobj,
|
||||||
&dev_attr_in0_input))
|
&lm87_group_in0_5);
|
||||||
|| (err = device_create_file(&new_client->dev,
|
if (err)
|
||||||
&dev_attr_in0_min))
|
|
||||||
|| (err = device_create_file(&new_client->dev,
|
|
||||||
&dev_attr_in0_max))
|
|
||||||
|| (err = device_create_file(&new_client->dev,
|
|
||||||
&sensor_dev_attr_in0_alarm.dev_attr))
|
|
||||||
|| (err = device_create_file(&new_client->dev,
|
|
||||||
&dev_attr_in5_input))
|
|
||||||
|| (err = device_create_file(&new_client->dev,
|
|
||||||
&dev_attr_in5_min))
|
|
||||||
|| (err = device_create_file(&new_client->dev,
|
|
||||||
&dev_attr_in5_max))
|
|
||||||
|| (err = device_create_file(&new_client->dev,
|
|
||||||
&sensor_dev_attr_in5_alarm.dev_attr)))
|
|
||||||
goto exit_remove;
|
goto exit_remove;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(data->channel & CHAN_NO_VID)) {
|
if (!(data->channel & CHAN_NO_VID)) {
|
||||||
data->vrm = vid_which_vrm();
|
data->vrm = vid_which_vrm();
|
||||||
if ((err = device_create_file(&new_client->dev,
|
err = sysfs_create_group(&new_client->dev.kobj,
|
||||||
&dev_attr_cpu0_vid))
|
&lm87_group_vid);
|
||||||
|| (err = device_create_file(&new_client->dev,
|
if (err)
|
||||||
&dev_attr_vrm)))
|
|
||||||
goto exit_remove;
|
goto exit_remove;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -911,8 +923,7 @@ static int lm87_probe(struct i2c_client *new_client,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
exit_remove:
|
exit_remove:
|
||||||
sysfs_remove_group(&new_client->dev.kobj, &lm87_group);
|
lm87_remove_files(new_client);
|
||||||
sysfs_remove_group(&new_client->dev.kobj, &lm87_group_opt);
|
|
||||||
exit_free:
|
exit_free:
|
||||||
lm87_write_value(new_client, LM87_REG_CONFIG, data->config);
|
lm87_write_value(new_client, LM87_REG_CONFIG, data->config);
|
||||||
kfree(data);
|
kfree(data);
|
||||||
@ -967,8 +978,7 @@ static int lm87_remove(struct i2c_client *client)
|
|||||||
struct lm87_data *data = i2c_get_clientdata(client);
|
struct lm87_data *data = i2c_get_clientdata(client);
|
||||||
|
|
||||||
hwmon_device_unregister(data->hwmon_dev);
|
hwmon_device_unregister(data->hwmon_dev);
|
||||||
sysfs_remove_group(&client->dev.kobj, &lm87_group);
|
lm87_remove_files(client);
|
||||||
sysfs_remove_group(&client->dev.kobj, &lm87_group_opt);
|
|
||||||
|
|
||||||
lm87_write_value(client, LM87_REG_CONFIG, data->config);
|
lm87_write_value(client, LM87_REG_CONFIG, data->config);
|
||||||
kfree(data);
|
kfree(data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user