hwmon: (ltc4261) Use permission specific SENSOR[_DEVICE]_ATTR variants
Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readability, and to reduce the chance of inconsistencies. Also replace any remaining S_<PERMS> in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
Родитель
8241f88575
Коммит
decb23dc60
|
@ -132,7 +132,7 @@ static int ltc4261_get_value(struct ltc4261_data *data, u8 reg)
|
|||
return val;
|
||||
}
|
||||
|
||||
static ssize_t ltc4261_show_value(struct device *dev,
|
||||
static ssize_t ltc4261_value_show(struct device *dev,
|
||||
struct device_attribute *da, char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
|
@ -146,7 +146,7 @@ static ssize_t ltc4261_show_value(struct device *dev,
|
|||
return snprintf(buf, PAGE_SIZE, "%d\n", value);
|
||||
}
|
||||
|
||||
static ssize_t ltc4261_show_bool(struct device *dev,
|
||||
static ssize_t ltc4261_bool_show(struct device *dev,
|
||||
struct device_attribute *da, char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
|
@ -166,10 +166,8 @@ static ssize_t ltc4261_show_bool(struct device *dev,
|
|||
/*
|
||||
* Input voltages.
|
||||
*/
|
||||
static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ltc4261_show_value, NULL,
|
||||
LTC4261_ADIN_H);
|
||||
static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ltc4261_show_value, NULL,
|
||||
LTC4261_ADIN2_H);
|
||||
static SENSOR_DEVICE_ATTR_RO(in1_input, ltc4261_value, LTC4261_ADIN_H);
|
||||
static SENSOR_DEVICE_ATTR_RO(in2_input, ltc4261_value, LTC4261_ADIN2_H);
|
||||
|
||||
/*
|
||||
* Voltage alarms. The chip has only one set of voltage alarm status bits,
|
||||
|
@ -179,22 +177,16 @@ static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ltc4261_show_value, NULL,
|
|||
* To ensure that the alarm condition is reported to the user, report it
|
||||
* with both voltage sensors.
|
||||
*/
|
||||
static SENSOR_DEVICE_ATTR(in1_min_alarm, S_IRUGO, ltc4261_show_bool, NULL,
|
||||
FAULT_UV);
|
||||
static SENSOR_DEVICE_ATTR(in1_max_alarm, S_IRUGO, ltc4261_show_bool, NULL,
|
||||
FAULT_OV);
|
||||
static SENSOR_DEVICE_ATTR(in2_min_alarm, S_IRUGO, ltc4261_show_bool, NULL,
|
||||
FAULT_UV);
|
||||
static SENSOR_DEVICE_ATTR(in2_max_alarm, S_IRUGO, ltc4261_show_bool, NULL,
|
||||
FAULT_OV);
|
||||
static SENSOR_DEVICE_ATTR_RO(in1_min_alarm, ltc4261_bool, FAULT_UV);
|
||||
static SENSOR_DEVICE_ATTR_RO(in1_max_alarm, ltc4261_bool, FAULT_OV);
|
||||
static SENSOR_DEVICE_ATTR_RO(in2_min_alarm, ltc4261_bool, FAULT_UV);
|
||||
static SENSOR_DEVICE_ATTR_RO(in2_max_alarm, ltc4261_bool, FAULT_OV);
|
||||
|
||||
/* Currents (via sense resistor) */
|
||||
static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, ltc4261_show_value, NULL,
|
||||
LTC4261_SENSE_H);
|
||||
static SENSOR_DEVICE_ATTR_RO(curr1_input, ltc4261_value, LTC4261_SENSE_H);
|
||||
|
||||
/* Overcurrent alarm */
|
||||
static SENSOR_DEVICE_ATTR(curr1_max_alarm, S_IRUGO, ltc4261_show_bool, NULL,
|
||||
FAULT_OC);
|
||||
static SENSOR_DEVICE_ATTR_RO(curr1_max_alarm, ltc4261_bool, FAULT_OC);
|
||||
|
||||
static struct attribute *ltc4261_attrs[] = {
|
||||
&sensor_dev_attr_in1_input.dev_attr.attr,
|
||||
|
|
Загрузка…
Ссылка в новой задаче