Source
129
129
/* Vx, 305.18uV/LSB */
130
130
*result = sign_extend32(val, 14) * 30518 / (100 * 1000);
131
131
break;
132
132
default:
133
133
return -EINVAL; /* won't happen, keep compiler happy */
134
134
}
135
135
136
136
return 0;
137
137
}
138
138
139
-
static ssize_t ltc2990_show_value(struct device *dev,
139
+
static ssize_t ltc2990_value_show(struct device *dev,
140
140
struct device_attribute *da, char *buf)
141
141
{
142
142
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
143
143
struct ltc2990_data *data = dev_get_drvdata(dev);
144
144
int value;
145
145
int ret;
146
146
147
147
ret = ltc2990_get_value(data->i2c, attr->index, &value);
148
148
if (unlikely(ret < 0))
149
149
return ret;
163
163
int attrs_mask = LTC2990_IN0 | LTC2990_TEMP1 |
164
164
(ltc2990_attrs_ena_0[data->mode[0]] &
165
165
ltc2990_attrs_ena_1[data->mode[1]]);
166
166
167
167
if (attr->index & attrs_mask)
168
168
return a->mode;
169
169
170
170
return 0;
171
171
}
172
172
173
-
static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, ltc2990_show_value, NULL,
174
-
LTC2990_TEMP1);
175
-
static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, ltc2990_show_value, NULL,
176
-
LTC2990_TEMP2);
177
-
static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, ltc2990_show_value, NULL,
178
-
LTC2990_TEMP3);
179
-
static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, ltc2990_show_value, NULL,
180
-
LTC2990_CURR1);
181
-
static SENSOR_DEVICE_ATTR(curr2_input, S_IRUGO, ltc2990_show_value, NULL,
182
-
LTC2990_CURR2);
183
-
static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, ltc2990_show_value, NULL,
184
-
LTC2990_IN0);
185
-
static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ltc2990_show_value, NULL,
186
-
LTC2990_IN1);
187
-
static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ltc2990_show_value, NULL,
188
-
LTC2990_IN2);
189
-
static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, ltc2990_show_value, NULL,
190
-
LTC2990_IN3);
191
-
static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, ltc2990_show_value, NULL,
192
-
LTC2990_IN4);
173
+
static SENSOR_DEVICE_ATTR_RO(temp1_input, ltc2990_value, LTC2990_TEMP1);
174
+
static SENSOR_DEVICE_ATTR_RO(temp2_input, ltc2990_value, LTC2990_TEMP2);
175
+
static SENSOR_DEVICE_ATTR_RO(temp3_input, ltc2990_value, LTC2990_TEMP3);
176
+
static SENSOR_DEVICE_ATTR_RO(curr1_input, ltc2990_value, LTC2990_CURR1);
177
+
static SENSOR_DEVICE_ATTR_RO(curr2_input, ltc2990_value, LTC2990_CURR2);
178
+
static SENSOR_DEVICE_ATTR_RO(in0_input, ltc2990_value, LTC2990_IN0);
179
+
static SENSOR_DEVICE_ATTR_RO(in1_input, ltc2990_value, LTC2990_IN1);
180
+
static SENSOR_DEVICE_ATTR_RO(in2_input, ltc2990_value, LTC2990_IN2);
181
+
static SENSOR_DEVICE_ATTR_RO(in3_input, ltc2990_value, LTC2990_IN3);
182
+
static SENSOR_DEVICE_ATTR_RO(in4_input, ltc2990_value, LTC2990_IN4);
193
183
194
184
static struct attribute *ltc2990_attrs[] = {
195
185
&sensor_dev_attr_temp1_input.dev_attr.attr,
196
186
&sensor_dev_attr_temp2_input.dev_attr.attr,
197
187
&sensor_dev_attr_temp3_input.dev_attr.attr,
198
188
&sensor_dev_attr_curr1_input.dev_attr.attr,
199
189
&sensor_dev_attr_curr2_input.dev_attr.attr,
200
190
&sensor_dev_attr_in0_input.dev_attr.attr,
201
191
&sensor_dev_attr_in1_input.dev_attr.attr,
202
192
&sensor_dev_attr_in2_input.dev_attr.attr,