hwmon: (sis5595) use permission-specific DEVICE_ATTR variants
Use DEVICE_ATTR_RO for read only attributes and DEVICE_ATTR_RW for read/write attributes. This simplifies the source code, improves readbility, and reduces the chance of inconsistencies. The conversion was done automatically using coccinelle. It was validated by compiling both the old and the new source code and comparing its text, data, and bss size. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> [groeck: Updated description] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
af3d387f49
commit
feaf8bd49c
|
@ -304,22 +304,23 @@ show_in_offset(3);
|
||||||
show_in_offset(4);
|
show_in_offset(4);
|
||||||
|
|
||||||
/* Temperature */
|
/* Temperature */
|
||||||
static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
|
static ssize_t temp1_input_show(struct device *dev,
|
||||||
char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
struct sis5595_data *data = sis5595_update_device(dev);
|
struct sis5595_data *data = sis5595_update_device(dev);
|
||||||
return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp));
|
return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp));
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t show_temp_over(struct device *dev, struct device_attribute *attr,
|
static ssize_t temp1_max_show(struct device *dev, struct device_attribute *attr,
|
||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
struct sis5595_data *data = sis5595_update_device(dev);
|
struct sis5595_data *data = sis5595_update_device(dev);
|
||||||
return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over));
|
return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over));
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr,
|
static ssize_t temp1_max_store(struct device *dev,
|
||||||
const char *buf, size_t count)
|
struct device_attribute *attr, const char *buf,
|
||||||
|
size_t count)
|
||||||
{
|
{
|
||||||
struct sis5595_data *data = dev_get_drvdata(dev);
|
struct sis5595_data *data = dev_get_drvdata(dev);
|
||||||
long val;
|
long val;
|
||||||
|
@ -336,15 +337,16 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr,
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t show_temp_hyst(struct device *dev, struct device_attribute *attr,
|
static ssize_t temp1_max_hyst_show(struct device *dev,
|
||||||
char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
struct sis5595_data *data = sis5595_update_device(dev);
|
struct sis5595_data *data = sis5595_update_device(dev);
|
||||||
return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_hyst));
|
return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_hyst));
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr,
|
static ssize_t temp1_max_hyst_store(struct device *dev,
|
||||||
const char *buf, size_t count)
|
struct device_attribute *attr,
|
||||||
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
struct sis5595_data *data = dev_get_drvdata(dev);
|
struct sis5595_data *data = dev_get_drvdata(dev);
|
||||||
long val;
|
long val;
|
||||||
|
@ -361,11 +363,9 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr,
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL);
|
static DEVICE_ATTR_RO(temp1_input);
|
||||||
static DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR,
|
static DEVICE_ATTR_RW(temp1_max);
|
||||||
show_temp_over, set_temp_over);
|
static DEVICE_ATTR_RW(temp1_max_hyst);
|
||||||
static DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR,
|
|
||||||
show_temp_hyst, set_temp_hyst);
|
|
||||||
|
|
||||||
/* 2 Fans */
|
/* 2 Fans */
|
||||||
static ssize_t show_fan(struct device *dev, struct device_attribute *da,
|
static ssize_t show_fan(struct device *dev, struct device_attribute *da,
|
||||||
|
@ -492,13 +492,13 @@ show_fan_offset(1);
|
||||||
show_fan_offset(2);
|
show_fan_offset(2);
|
||||||
|
|
||||||
/* Alarms */
|
/* Alarms */
|
||||||
static ssize_t show_alarms(struct device *dev, struct device_attribute *attr,
|
static ssize_t alarms_show(struct device *dev, struct device_attribute *attr,
|
||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
struct sis5595_data *data = sis5595_update_device(dev);
|
struct sis5595_data *data = sis5595_update_device(dev);
|
||||||
return sprintf(buf, "%d\n", data->alarms);
|
return sprintf(buf, "%d\n", data->alarms);
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
|
static DEVICE_ATTR_RO(alarms);
|
||||||
|
|
||||||
static ssize_t show_alarm(struct device *dev, struct device_attribute *da,
|
static ssize_t show_alarm(struct device *dev, struct device_attribute *da,
|
||||||
char *buf)
|
char *buf)
|
||||||
|
@ -516,13 +516,13 @@ static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6);
|
||||||
static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7);
|
static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7);
|
||||||
static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 15);
|
static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 15);
|
||||||
|
|
||||||
static ssize_t show_name(struct device *dev, struct device_attribute *attr,
|
static ssize_t name_show(struct device *dev, struct device_attribute *attr,
|
||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
struct sis5595_data *data = dev_get_drvdata(dev);
|
struct sis5595_data *data = dev_get_drvdata(dev);
|
||||||
return sprintf(buf, "%s\n", data->name);
|
return sprintf(buf, "%s\n", data->name);
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
|
static DEVICE_ATTR_RO(name);
|
||||||
|
|
||||||
static struct attribute *sis5595_attributes[] = {
|
static struct attribute *sis5595_attributes[] = {
|
||||||
&sensor_dev_attr_in0_input.dev_attr.attr,
|
&sensor_dev_attr_in0_input.dev_attr.attr,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user