Commit d7f2a8f5 authored by Guenter Roeck's avatar Guenter Roeck

hwmon: (ltc4215) Auto-convert to use SENSOR_DEVICE_ATTR_{RO, RW, WO}

Conversion was done done using the coccinelle script at
https://github.com/groeck/coccinelle-patches/raw/master/hwmon/sensor-devattr-w6.cocciSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 6a0f234f
...@@ -136,9 +136,8 @@ static unsigned int ltc4215_get_current(struct device *dev) ...@@ -136,9 +136,8 @@ static unsigned int ltc4215_get_current(struct device *dev)
return curr; return curr;
} }
static ssize_t ltc4215_show_voltage(struct device *dev, static ssize_t ltc4215_voltage_show(struct device *dev,
struct device_attribute *da, struct device_attribute *da, char *buf)
char *buf)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
const int voltage = ltc4215_get_voltage(dev, attr->index); const int voltage = ltc4215_get_voltage(dev, attr->index);
...@@ -146,18 +145,16 @@ static ssize_t ltc4215_show_voltage(struct device *dev, ...@@ -146,18 +145,16 @@ static ssize_t ltc4215_show_voltage(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", voltage); return snprintf(buf, PAGE_SIZE, "%d\n", voltage);
} }
static ssize_t ltc4215_show_current(struct device *dev, static ssize_t ltc4215_current_show(struct device *dev,
struct device_attribute *da, struct device_attribute *da, char *buf)
char *buf)
{ {
const unsigned int curr = ltc4215_get_current(dev); const unsigned int curr = ltc4215_get_current(dev);
return snprintf(buf, PAGE_SIZE, "%u\n", curr); return snprintf(buf, PAGE_SIZE, "%u\n", curr);
} }
static ssize_t ltc4215_show_power(struct device *dev, static ssize_t ltc4215_power_show(struct device *dev,
struct device_attribute *da, struct device_attribute *da, char *buf)
char *buf)
{ {
const unsigned int curr = ltc4215_get_current(dev); const unsigned int curr = ltc4215_get_current(dev);
const int output_voltage = ltc4215_get_voltage(dev, LTC4215_ADIN); const int output_voltage = ltc4215_get_voltage(dev, LTC4215_ADIN);
...@@ -168,9 +165,8 @@ static ssize_t ltc4215_show_power(struct device *dev, ...@@ -168,9 +165,8 @@ static ssize_t ltc4215_show_power(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%u\n", power); return snprintf(buf, PAGE_SIZE, "%u\n", power);
} }
static ssize_t ltc4215_show_alarm(struct device *dev, static ssize_t ltc4215_alarm_show(struct device *dev,
struct device_attribute *da, struct device_attribute *da, char *buf)
char *buf)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct ltc4215_data *data = ltc4215_update_device(dev); struct ltc4215_data *data = ltc4215_update_device(dev);
...@@ -189,26 +185,20 @@ static ssize_t ltc4215_show_alarm(struct device *dev, ...@@ -189,26 +185,20 @@ static ssize_t ltc4215_show_alarm(struct device *dev,
/* Construct a sensor_device_attribute structure for each register */ /* Construct a sensor_device_attribute structure for each register */
/* Current */ /* Current */
static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, ltc4215_show_current, NULL, 0); static SENSOR_DEVICE_ATTR_RO(curr1_input, ltc4215_current, 0);
static SENSOR_DEVICE_ATTR(curr1_max_alarm, S_IRUGO, ltc4215_show_alarm, NULL, static SENSOR_DEVICE_ATTR_RO(curr1_max_alarm, ltc4215_alarm, 1 << 2);
1 << 2);
/* Power (virtual) */ /* Power (virtual) */
static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, ltc4215_show_power, NULL, 0); static SENSOR_DEVICE_ATTR_RO(power1_input, ltc4215_power, 0);
/* Input Voltage */ /* Input Voltage */
static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ltc4215_show_voltage, NULL, static SENSOR_DEVICE_ATTR_RO(in1_input, ltc4215_voltage, LTC4215_ADIN);
LTC4215_ADIN); static SENSOR_DEVICE_ATTR_RO(in1_max_alarm, ltc4215_alarm, 1 << 0);
static SENSOR_DEVICE_ATTR(in1_max_alarm, S_IRUGO, ltc4215_show_alarm, NULL, static SENSOR_DEVICE_ATTR_RO(in1_min_alarm, ltc4215_alarm, 1 << 1);
1 << 0);
static SENSOR_DEVICE_ATTR(in1_min_alarm, S_IRUGO, ltc4215_show_alarm, NULL,
1 << 1);
/* Output Voltage */ /* Output Voltage */
static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ltc4215_show_voltage, NULL, static SENSOR_DEVICE_ATTR_RO(in2_input, ltc4215_voltage, LTC4215_SOURCE);
LTC4215_SOURCE); static SENSOR_DEVICE_ATTR_RO(in2_min_alarm, ltc4215_alarm, 1 << 3);
static SENSOR_DEVICE_ATTR(in2_min_alarm, S_IRUGO, ltc4215_show_alarm, NULL,
1 << 3);
/* /*
* Finally, construct an array of pointers to members of the above objects, * Finally, construct an array of pointers to members of the above objects,
......
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