.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * max6639.c - Support for Maxim MAX6639 |
---|
3 | 4 | * |
---|
.. | .. |
---|
7 | 8 | * |
---|
8 | 9 | * based on the initial MAX6639 support from semptian.net |
---|
9 | 10 | * by He Changqing <hechangqing@semptian.com> |
---|
10 | | - * |
---|
11 | | - * This program is free software; you can redistribute it and/or modify |
---|
12 | | - * it under the terms of the GNU General Public License as published by |
---|
13 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
14 | | - * (at your option) any later version. |
---|
15 | | - * |
---|
16 | | - * This program is distributed in the hope that it will be useful, |
---|
17 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
19 | | - * GNU General Public License for more details. |
---|
20 | | - * |
---|
21 | | - * You should have received a copy of the GNU General Public License |
---|
22 | | - * along with this program; if not, write to the Free Software |
---|
23 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
24 | 11 | */ |
---|
25 | 12 | |
---|
26 | 13 | #include <linux/module.h> |
---|
.. | .. |
---|
162 | 149 | return ret; |
---|
163 | 150 | } |
---|
164 | 151 | |
---|
165 | | -static ssize_t show_temp_input(struct device *dev, |
---|
| 152 | +static ssize_t temp_input_show(struct device *dev, |
---|
166 | 153 | struct device_attribute *dev_attr, char *buf) |
---|
167 | 154 | { |
---|
168 | 155 | long temp; |
---|
.. | .. |
---|
176 | 163 | return sprintf(buf, "%ld\n", temp); |
---|
177 | 164 | } |
---|
178 | 165 | |
---|
179 | | -static ssize_t show_temp_fault(struct device *dev, |
---|
| 166 | +static ssize_t temp_fault_show(struct device *dev, |
---|
180 | 167 | struct device_attribute *dev_attr, char *buf) |
---|
181 | 168 | { |
---|
182 | 169 | struct max6639_data *data = max6639_update_device(dev); |
---|
.. | .. |
---|
188 | 175 | return sprintf(buf, "%d\n", data->temp_fault[attr->index]); |
---|
189 | 176 | } |
---|
190 | 177 | |
---|
191 | | -static ssize_t show_temp_max(struct device *dev, |
---|
| 178 | +static ssize_t temp_max_show(struct device *dev, |
---|
192 | 179 | struct device_attribute *dev_attr, char *buf) |
---|
193 | 180 | { |
---|
194 | 181 | struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); |
---|
.. | .. |
---|
197 | 184 | return sprintf(buf, "%d\n", (data->temp_therm[attr->index] * 1000)); |
---|
198 | 185 | } |
---|
199 | 186 | |
---|
200 | | -static ssize_t set_temp_max(struct device *dev, |
---|
201 | | - struct device_attribute *dev_attr, |
---|
202 | | - const char *buf, size_t count) |
---|
| 187 | +static ssize_t temp_max_store(struct device *dev, |
---|
| 188 | + struct device_attribute *dev_attr, |
---|
| 189 | + const char *buf, size_t count) |
---|
203 | 190 | { |
---|
204 | 191 | struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); |
---|
205 | 192 | struct max6639_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
220 | 207 | return count; |
---|
221 | 208 | } |
---|
222 | 209 | |
---|
223 | | -static ssize_t show_temp_crit(struct device *dev, |
---|
| 210 | +static ssize_t temp_crit_show(struct device *dev, |
---|
224 | 211 | struct device_attribute *dev_attr, char *buf) |
---|
225 | 212 | { |
---|
226 | 213 | struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); |
---|
.. | .. |
---|
229 | 216 | return sprintf(buf, "%d\n", (data->temp_alert[attr->index] * 1000)); |
---|
230 | 217 | } |
---|
231 | 218 | |
---|
232 | | -static ssize_t set_temp_crit(struct device *dev, |
---|
233 | | - struct device_attribute *dev_attr, |
---|
234 | | - const char *buf, size_t count) |
---|
| 219 | +static ssize_t temp_crit_store(struct device *dev, |
---|
| 220 | + struct device_attribute *dev_attr, |
---|
| 221 | + const char *buf, size_t count) |
---|
235 | 222 | { |
---|
236 | 223 | struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); |
---|
237 | 224 | struct max6639_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
252 | 239 | return count; |
---|
253 | 240 | } |
---|
254 | 241 | |
---|
255 | | -static ssize_t show_temp_emergency(struct device *dev, |
---|
| 242 | +static ssize_t temp_emergency_show(struct device *dev, |
---|
256 | 243 | struct device_attribute *dev_attr, |
---|
257 | 244 | char *buf) |
---|
258 | 245 | { |
---|
.. | .. |
---|
262 | 249 | return sprintf(buf, "%d\n", (data->temp_ot[attr->index] * 1000)); |
---|
263 | 250 | } |
---|
264 | 251 | |
---|
265 | | -static ssize_t set_temp_emergency(struct device *dev, |
---|
266 | | - struct device_attribute *dev_attr, |
---|
267 | | - const char *buf, size_t count) |
---|
| 252 | +static ssize_t temp_emergency_store(struct device *dev, |
---|
| 253 | + struct device_attribute *dev_attr, |
---|
| 254 | + const char *buf, size_t count) |
---|
268 | 255 | { |
---|
269 | 256 | struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); |
---|
270 | 257 | struct max6639_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
285 | 272 | return count; |
---|
286 | 273 | } |
---|
287 | 274 | |
---|
288 | | -static ssize_t show_pwm(struct device *dev, |
---|
289 | | - struct device_attribute *dev_attr, char *buf) |
---|
| 275 | +static ssize_t pwm_show(struct device *dev, struct device_attribute *dev_attr, |
---|
| 276 | + char *buf) |
---|
290 | 277 | { |
---|
291 | 278 | struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); |
---|
292 | 279 | struct max6639_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
294 | 281 | return sprintf(buf, "%d\n", data->pwm[attr->index] * 255 / 120); |
---|
295 | 282 | } |
---|
296 | 283 | |
---|
297 | | -static ssize_t set_pwm(struct device *dev, |
---|
298 | | - struct device_attribute *dev_attr, |
---|
299 | | - const char *buf, size_t count) |
---|
| 284 | +static ssize_t pwm_store(struct device *dev, |
---|
| 285 | + struct device_attribute *dev_attr, const char *buf, |
---|
| 286 | + size_t count) |
---|
300 | 287 | { |
---|
301 | 288 | struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); |
---|
302 | 289 | struct max6639_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
319 | 306 | return count; |
---|
320 | 307 | } |
---|
321 | 308 | |
---|
322 | | -static ssize_t show_fan_input(struct device *dev, |
---|
| 309 | +static ssize_t fan_input_show(struct device *dev, |
---|
323 | 310 | struct device_attribute *dev_attr, char *buf) |
---|
324 | 311 | { |
---|
325 | 312 | struct max6639_data *data = max6639_update_device(dev); |
---|
.. | .. |
---|
332 | 319 | data->rpm_range)); |
---|
333 | 320 | } |
---|
334 | 321 | |
---|
335 | | -static ssize_t show_alarm(struct device *dev, |
---|
| 322 | +static ssize_t alarm_show(struct device *dev, |
---|
336 | 323 | struct device_attribute *dev_attr, char *buf) |
---|
337 | 324 | { |
---|
338 | 325 | struct max6639_data *data = max6639_update_device(dev); |
---|
.. | .. |
---|
344 | 331 | return sprintf(buf, "%d\n", !!(data->status & (1 << attr->index))); |
---|
345 | 332 | } |
---|
346 | 333 | |
---|
347 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL, 0); |
---|
348 | | -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input, NULL, 1); |
---|
349 | | -static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0); |
---|
350 | | -static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_temp_fault, NULL, 1); |
---|
351 | | -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, |
---|
352 | | - set_temp_max, 0); |
---|
353 | | -static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_max, |
---|
354 | | - set_temp_max, 1); |
---|
355 | | -static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp_crit, |
---|
356 | | - set_temp_crit, 0); |
---|
357 | | -static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp_crit, |
---|
358 | | - set_temp_crit, 1); |
---|
359 | | -static SENSOR_DEVICE_ATTR(temp1_emergency, S_IWUSR | S_IRUGO, |
---|
360 | | - show_temp_emergency, set_temp_emergency, 0); |
---|
361 | | -static SENSOR_DEVICE_ATTR(temp2_emergency, S_IWUSR | S_IRUGO, |
---|
362 | | - show_temp_emergency, set_temp_emergency, 1); |
---|
363 | | -static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0); |
---|
364 | | -static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1); |
---|
365 | | -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan_input, NULL, 0); |
---|
366 | | -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan_input, NULL, 1); |
---|
367 | | -static SENSOR_DEVICE_ATTR(fan1_fault, S_IRUGO, show_alarm, NULL, 1); |
---|
368 | | -static SENSOR_DEVICE_ATTR(fan2_fault, S_IRUGO, show_alarm, NULL, 0); |
---|
369 | | -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 3); |
---|
370 | | -static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 2); |
---|
371 | | -static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 7); |
---|
372 | | -static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 6); |
---|
373 | | -static SENSOR_DEVICE_ATTR(temp1_emergency_alarm, S_IRUGO, show_alarm, NULL, 5); |
---|
374 | | -static SENSOR_DEVICE_ATTR(temp2_emergency_alarm, S_IRUGO, show_alarm, NULL, 4); |
---|
| 334 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp_input, 0); |
---|
| 335 | +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp_input, 1); |
---|
| 336 | +static SENSOR_DEVICE_ATTR_RO(temp1_fault, temp_fault, 0); |
---|
| 337 | +static SENSOR_DEVICE_ATTR_RO(temp2_fault, temp_fault, 1); |
---|
| 338 | +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); |
---|
| 339 | +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); |
---|
| 340 | +static SENSOR_DEVICE_ATTR_RW(temp1_crit, temp_crit, 0); |
---|
| 341 | +static SENSOR_DEVICE_ATTR_RW(temp2_crit, temp_crit, 1); |
---|
| 342 | +static SENSOR_DEVICE_ATTR_RW(temp1_emergency, temp_emergency, 0); |
---|
| 343 | +static SENSOR_DEVICE_ATTR_RW(temp2_emergency, temp_emergency, 1); |
---|
| 344 | +static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0); |
---|
| 345 | +static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, 1); |
---|
| 346 | +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan_input, 0); |
---|
| 347 | +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan_input, 1); |
---|
| 348 | +static SENSOR_DEVICE_ATTR_RO(fan1_fault, alarm, 1); |
---|
| 349 | +static SENSOR_DEVICE_ATTR_RO(fan2_fault, alarm, 0); |
---|
| 350 | +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 3); |
---|
| 351 | +static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, alarm, 2); |
---|
| 352 | +static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, alarm, 7); |
---|
| 353 | +static SENSOR_DEVICE_ATTR_RO(temp2_crit_alarm, alarm, 6); |
---|
| 354 | +static SENSOR_DEVICE_ATTR_RO(temp1_emergency_alarm, alarm, 5); |
---|
| 355 | +static SENSOR_DEVICE_ATTR_RO(temp2_emergency_alarm, alarm, 4); |
---|
375 | 356 | |
---|
376 | 357 | |
---|
377 | 358 | static struct attribute *max6639_attrs[] = { |
---|
.. | .. |
---|
535 | 516 | return 0; |
---|
536 | 517 | } |
---|
537 | 518 | |
---|
538 | | -static int max6639_probe(struct i2c_client *client, |
---|
539 | | - const struct i2c_device_id *id) |
---|
| 519 | +static int max6639_probe(struct i2c_client *client) |
---|
540 | 520 | { |
---|
541 | 521 | struct device *dev = &client->dev; |
---|
542 | 522 | struct max6639_data *data; |
---|
.. | .. |
---|
600 | 580 | .name = "max6639", |
---|
601 | 581 | .pm = &max6639_pm_ops, |
---|
602 | 582 | }, |
---|
603 | | - .probe = max6639_probe, |
---|
| 583 | + .probe_new = max6639_probe, |
---|
604 | 584 | .id_table = max6639_id, |
---|
605 | 585 | .detect = max6639_detect, |
---|
606 | 586 | .address_list = normal_i2c, |
---|