| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * gl520sm.c - Part of lm_sensors, Linux kernel modules for hardware |
|---|
| 3 | 4 | * monitoring |
|---|
| 4 | 5 | * Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>, |
|---|
| 5 | 6 | * Kyösti Mälkki <kmalkki@cc.hut.fi> |
|---|
| 6 | 7 | * Copyright (c) 2005 Maarten Deprez <maartendeprez@users.sourceforge.net> |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 9 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 10 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 11 | | - * (at your option) any later version. |
|---|
| 12 | | - * |
|---|
| 13 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 14 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | | - * GNU General Public License for more details. |
|---|
| 17 | | - * |
|---|
| 18 | | - * You should have received a copy of the GNU General Public License |
|---|
| 19 | | - * along with this program; if not, write to the Free Software |
|---|
| 20 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 21 | | - * |
|---|
| 22 | 8 | */ |
|---|
| 23 | 9 | |
|---|
| 24 | 10 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 216 | 202 | #define IN_CLAMP(val) clamp_val(val, 0, 255 * 19) |
|---|
| 217 | 203 | #define IN_TO_REG(val) DIV_ROUND_CLOSEST(IN_CLAMP(val), 19) |
|---|
| 218 | 204 | |
|---|
| 219 | | -static ssize_t get_in_input(struct device *dev, struct device_attribute *attr, |
|---|
| 220 | | - char *buf) |
|---|
| 205 | +static ssize_t in_input_show(struct device *dev, |
|---|
| 206 | + struct device_attribute *attr, char *buf) |
|---|
| 221 | 207 | { |
|---|
| 222 | 208 | int n = to_sensor_dev_attr(attr)->index; |
|---|
| 223 | 209 | struct gl520_data *data = gl520_update_device(dev); |
|---|
| .. | .. |
|---|
| 229 | 215 | return sprintf(buf, "%d\n", IN_FROM_REG(r)); |
|---|
| 230 | 216 | } |
|---|
| 231 | 217 | |
|---|
| 232 | | -static ssize_t get_in_min(struct device *dev, struct device_attribute *attr, |
|---|
| 233 | | - char *buf) |
|---|
| 218 | +static ssize_t in_min_show(struct device *dev, struct device_attribute *attr, |
|---|
| 219 | + char *buf) |
|---|
| 234 | 220 | { |
|---|
| 235 | 221 | int n = to_sensor_dev_attr(attr)->index; |
|---|
| 236 | 222 | struct gl520_data *data = gl520_update_device(dev); |
|---|
| .. | .. |
|---|
| 242 | 228 | return sprintf(buf, "%d\n", IN_FROM_REG(r)); |
|---|
| 243 | 229 | } |
|---|
| 244 | 230 | |
|---|
| 245 | | -static ssize_t get_in_max(struct device *dev, struct device_attribute *attr, |
|---|
| 246 | | - char *buf) |
|---|
| 231 | +static ssize_t in_max_show(struct device *dev, struct device_attribute *attr, |
|---|
| 232 | + char *buf) |
|---|
| 247 | 233 | { |
|---|
| 248 | 234 | int n = to_sensor_dev_attr(attr)->index; |
|---|
| 249 | 235 | struct gl520_data *data = gl520_update_device(dev); |
|---|
| .. | .. |
|---|
| 255 | 241 | return sprintf(buf, "%d\n", IN_FROM_REG(r)); |
|---|
| 256 | 242 | } |
|---|
| 257 | 243 | |
|---|
| 258 | | -static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, |
|---|
| 259 | | - const char *buf, size_t count) |
|---|
| 244 | +static ssize_t in_min_store(struct device *dev, struct device_attribute *attr, |
|---|
| 245 | + const char *buf, size_t count) |
|---|
| 260 | 246 | { |
|---|
| 261 | 247 | struct gl520_data *data = dev_get_drvdata(dev); |
|---|
| 262 | 248 | struct i2c_client *client = data->client; |
|---|
| .. | .. |
|---|
| 289 | 275 | return count; |
|---|
| 290 | 276 | } |
|---|
| 291 | 277 | |
|---|
| 292 | | -static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, |
|---|
| 293 | | - const char *buf, size_t count) |
|---|
| 278 | +static ssize_t in_max_store(struct device *dev, struct device_attribute *attr, |
|---|
| 279 | + const char *buf, size_t count) |
|---|
| 294 | 280 | { |
|---|
| 295 | 281 | struct gl520_data *data = dev_get_drvdata(dev); |
|---|
| 296 | 282 | struct i2c_client *client = data->client; |
|---|
| .. | .. |
|---|
| 323 | 309 | return count; |
|---|
| 324 | 310 | } |
|---|
| 325 | 311 | |
|---|
| 326 | | -static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, get_in_input, NULL, 0); |
|---|
| 327 | | -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, get_in_input, NULL, 1); |
|---|
| 328 | | -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, get_in_input, NULL, 2); |
|---|
| 329 | | -static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, get_in_input, NULL, 3); |
|---|
| 330 | | -static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, get_in_input, NULL, 4); |
|---|
| 331 | | -static SENSOR_DEVICE_ATTR(in0_min, S_IRUGO | S_IWUSR, |
|---|
| 332 | | - get_in_min, set_in_min, 0); |
|---|
| 333 | | -static SENSOR_DEVICE_ATTR(in1_min, S_IRUGO | S_IWUSR, |
|---|
| 334 | | - get_in_min, set_in_min, 1); |
|---|
| 335 | | -static SENSOR_DEVICE_ATTR(in2_min, S_IRUGO | S_IWUSR, |
|---|
| 336 | | - get_in_min, set_in_min, 2); |
|---|
| 337 | | -static SENSOR_DEVICE_ATTR(in3_min, S_IRUGO | S_IWUSR, |
|---|
| 338 | | - get_in_min, set_in_min, 3); |
|---|
| 339 | | -static SENSOR_DEVICE_ATTR(in4_min, S_IRUGO | S_IWUSR, |
|---|
| 340 | | - get_in_min, set_in_min, 4); |
|---|
| 341 | | -static SENSOR_DEVICE_ATTR(in0_max, S_IRUGO | S_IWUSR, |
|---|
| 342 | | - get_in_max, set_in_max, 0); |
|---|
| 343 | | -static SENSOR_DEVICE_ATTR(in1_max, S_IRUGO | S_IWUSR, |
|---|
| 344 | | - get_in_max, set_in_max, 1); |
|---|
| 345 | | -static SENSOR_DEVICE_ATTR(in2_max, S_IRUGO | S_IWUSR, |
|---|
| 346 | | - get_in_max, set_in_max, 2); |
|---|
| 347 | | -static SENSOR_DEVICE_ATTR(in3_max, S_IRUGO | S_IWUSR, |
|---|
| 348 | | - get_in_max, set_in_max, 3); |
|---|
| 349 | | -static SENSOR_DEVICE_ATTR(in4_max, S_IRUGO | S_IWUSR, |
|---|
| 350 | | - get_in_max, set_in_max, 4); |
|---|
| 312 | +static SENSOR_DEVICE_ATTR_RO(in0_input, in_input, 0); |
|---|
| 313 | +static SENSOR_DEVICE_ATTR_RO(in1_input, in_input, 1); |
|---|
| 314 | +static SENSOR_DEVICE_ATTR_RO(in2_input, in_input, 2); |
|---|
| 315 | +static SENSOR_DEVICE_ATTR_RO(in3_input, in_input, 3); |
|---|
| 316 | +static SENSOR_DEVICE_ATTR_RO(in4_input, in_input, 4); |
|---|
| 317 | +static SENSOR_DEVICE_ATTR_RW(in0_min, in_min, 0); |
|---|
| 318 | +static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1); |
|---|
| 319 | +static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2); |
|---|
| 320 | +static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3); |
|---|
| 321 | +static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4); |
|---|
| 322 | +static SENSOR_DEVICE_ATTR_RW(in0_max, in_max, 0); |
|---|
| 323 | +static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1); |
|---|
| 324 | +static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2); |
|---|
| 325 | +static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3); |
|---|
| 326 | +static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4); |
|---|
| 351 | 327 | |
|---|
| 352 | 328 | #define DIV_FROM_REG(val) (1 << (val)) |
|---|
| 353 | 329 | #define FAN_FROM_REG(val, div) ((val) == 0 ? 0 : (480000 / ((val) << (div)))) |
|---|
| .. | .. |
|---|
| 359 | 335 | DIV_ROUND_CLOSEST(480000, \ |
|---|
| 360 | 336 | FAN_CLAMP(val, div) << (div))) |
|---|
| 361 | 337 | |
|---|
| 362 | | -static ssize_t get_fan_input(struct device *dev, struct device_attribute *attr, |
|---|
| 363 | | - char *buf) |
|---|
| 338 | +static ssize_t fan_input_show(struct device *dev, |
|---|
| 339 | + struct device_attribute *attr, char *buf) |
|---|
| 364 | 340 | { |
|---|
| 365 | 341 | int n = to_sensor_dev_attr(attr)->index; |
|---|
| 366 | 342 | struct gl520_data *data = gl520_update_device(dev); |
|---|
| .. | .. |
|---|
| 369 | 345 | data->fan_div[n])); |
|---|
| 370 | 346 | } |
|---|
| 371 | 347 | |
|---|
| 372 | | -static ssize_t get_fan_min(struct device *dev, struct device_attribute *attr, |
|---|
| 373 | | - char *buf) |
|---|
| 348 | +static ssize_t fan_min_show(struct device *dev, struct device_attribute *attr, |
|---|
| 349 | + char *buf) |
|---|
| 374 | 350 | { |
|---|
| 375 | 351 | int n = to_sensor_dev_attr(attr)->index; |
|---|
| 376 | 352 | struct gl520_data *data = gl520_update_device(dev); |
|---|
| .. | .. |
|---|
| 379 | 355 | data->fan_div[n])); |
|---|
| 380 | 356 | } |
|---|
| 381 | 357 | |
|---|
| 382 | | -static ssize_t get_fan_div(struct device *dev, struct device_attribute *attr, |
|---|
| 383 | | - char *buf) |
|---|
| 358 | +static ssize_t fan_div_show(struct device *dev, struct device_attribute *attr, |
|---|
| 359 | + char *buf) |
|---|
| 384 | 360 | { |
|---|
| 385 | 361 | int n = to_sensor_dev_attr(attr)->index; |
|---|
| 386 | 362 | struct gl520_data *data = gl520_update_device(dev); |
|---|
| .. | .. |
|---|
| 395 | 371 | return sprintf(buf, "%d\n", data->fan_off); |
|---|
| 396 | 372 | } |
|---|
| 397 | 373 | |
|---|
| 398 | | -static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, |
|---|
| 399 | | - const char *buf, size_t count) |
|---|
| 374 | +static ssize_t fan_min_store(struct device *dev, |
|---|
| 375 | + struct device_attribute *attr, const char *buf, |
|---|
| 376 | + size_t count) |
|---|
| 400 | 377 | { |
|---|
| 401 | 378 | struct gl520_data *data = dev_get_drvdata(dev); |
|---|
| 402 | 379 | struct i2c_client *client = data->client; |
|---|
| .. | .. |
|---|
| 434 | 411 | return count; |
|---|
| 435 | 412 | } |
|---|
| 436 | 413 | |
|---|
| 437 | | -static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, |
|---|
| 438 | | - const char *buf, size_t count) |
|---|
| 414 | +static ssize_t fan_div_store(struct device *dev, |
|---|
| 415 | + struct device_attribute *attr, const char *buf, |
|---|
| 416 | + size_t count) |
|---|
| 439 | 417 | { |
|---|
| 440 | 418 | struct gl520_data *data = dev_get_drvdata(dev); |
|---|
| 441 | 419 | struct i2c_client *client = data->client; |
|---|
| .. | .. |
|---|
| 508 | 486 | return count; |
|---|
| 509 | 487 | } |
|---|
| 510 | 488 | |
|---|
| 511 | | -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, get_fan_input, NULL, 0); |
|---|
| 512 | | -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, get_fan_input, NULL, 1); |
|---|
| 513 | | -static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO | S_IWUSR, |
|---|
| 514 | | - get_fan_min, set_fan_min, 0); |
|---|
| 515 | | -static SENSOR_DEVICE_ATTR(fan2_min, S_IRUGO | S_IWUSR, |
|---|
| 516 | | - get_fan_min, set_fan_min, 1); |
|---|
| 517 | | -static SENSOR_DEVICE_ATTR(fan1_div, S_IRUGO | S_IWUSR, |
|---|
| 518 | | - get_fan_div, set_fan_div, 0); |
|---|
| 519 | | -static SENSOR_DEVICE_ATTR(fan2_div, S_IRUGO | S_IWUSR, |
|---|
| 520 | | - get_fan_div, set_fan_div, 1); |
|---|
| 489 | +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan_input, 0); |
|---|
| 490 | +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan_input, 1); |
|---|
| 491 | +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); |
|---|
| 492 | +static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); |
|---|
| 493 | +static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0); |
|---|
| 494 | +static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1); |
|---|
| 521 | 495 | static DEVICE_ATTR_RW(fan1_off); |
|---|
| 522 | 496 | |
|---|
| 523 | 497 | #define TEMP_FROM_REG(val) (((val) - 130) * 1000) |
|---|
| 524 | 498 | #define TEMP_CLAMP(val) clamp_val(val, -130000, 125000) |
|---|
| 525 | 499 | #define TEMP_TO_REG(val) (DIV_ROUND_CLOSEST(TEMP_CLAMP(val), 1000) + 130) |
|---|
| 526 | 500 | |
|---|
| 527 | | -static ssize_t get_temp_input(struct device *dev, struct device_attribute *attr, |
|---|
| 528 | | - char *buf) |
|---|
| 501 | +static ssize_t temp_input_show(struct device *dev, |
|---|
| 502 | + struct device_attribute *attr, char *buf) |
|---|
| 529 | 503 | { |
|---|
| 530 | 504 | int n = to_sensor_dev_attr(attr)->index; |
|---|
| 531 | 505 | struct gl520_data *data = gl520_update_device(dev); |
|---|
| .. | .. |
|---|
| 533 | 507 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_input[n])); |
|---|
| 534 | 508 | } |
|---|
| 535 | 509 | |
|---|
| 536 | | -static ssize_t get_temp_max(struct device *dev, struct device_attribute *attr, |
|---|
| 537 | | - char *buf) |
|---|
| 510 | +static ssize_t temp_max_show(struct device *dev, |
|---|
| 511 | + struct device_attribute *attr, char *buf) |
|---|
| 538 | 512 | { |
|---|
| 539 | 513 | int n = to_sensor_dev_attr(attr)->index; |
|---|
| 540 | 514 | struct gl520_data *data = gl520_update_device(dev); |
|---|
| .. | .. |
|---|
| 542 | 516 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[n])); |
|---|
| 543 | 517 | } |
|---|
| 544 | 518 | |
|---|
| 545 | | -static ssize_t get_temp_max_hyst(struct device *dev, |
|---|
| 546 | | - struct device_attribute *attr, char *buf) |
|---|
| 519 | +static ssize_t temp_max_hyst_show(struct device *dev, |
|---|
| 520 | + struct device_attribute *attr, char *buf) |
|---|
| 547 | 521 | { |
|---|
| 548 | 522 | int n = to_sensor_dev_attr(attr)->index; |
|---|
| 549 | 523 | struct gl520_data *data = gl520_update_device(dev); |
|---|
| .. | .. |
|---|
| 551 | 525 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max_hyst[n])); |
|---|
| 552 | 526 | } |
|---|
| 553 | 527 | |
|---|
| 554 | | -static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, |
|---|
| 555 | | - const char *buf, size_t count) |
|---|
| 528 | +static ssize_t temp_max_store(struct device *dev, |
|---|
| 529 | + struct device_attribute *attr, const char *buf, |
|---|
| 530 | + size_t count) |
|---|
| 556 | 531 | { |
|---|
| 557 | 532 | struct gl520_data *data = dev_get_drvdata(dev); |
|---|
| 558 | 533 | struct i2c_client *client = data->client; |
|---|
| .. | .. |
|---|
| 571 | 546 | return count; |
|---|
| 572 | 547 | } |
|---|
| 573 | 548 | |
|---|
| 574 | | -static ssize_t set_temp_max_hyst(struct device *dev, struct device_attribute |
|---|
| 575 | | - *attr, const char *buf, size_t count) |
|---|
| 549 | +static ssize_t temp_max_hyst_store(struct device *dev, |
|---|
| 550 | + struct device_attribute *attr, |
|---|
| 551 | + const char *buf, size_t count) |
|---|
| 576 | 552 | { |
|---|
| 577 | 553 | struct gl520_data *data = dev_get_drvdata(dev); |
|---|
| 578 | 554 | struct i2c_client *client = data->client; |
|---|
| .. | .. |
|---|
| 592 | 568 | return count; |
|---|
| 593 | 569 | } |
|---|
| 594 | 570 | |
|---|
| 595 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, get_temp_input, NULL, 0); |
|---|
| 596 | | -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, get_temp_input, NULL, 1); |
|---|
| 597 | | -static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, |
|---|
| 598 | | - get_temp_max, set_temp_max, 0); |
|---|
| 599 | | -static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO | S_IWUSR, |
|---|
| 600 | | - get_temp_max, set_temp_max, 1); |
|---|
| 601 | | -static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, |
|---|
| 602 | | - get_temp_max_hyst, set_temp_max_hyst, 0); |
|---|
| 603 | | -static SENSOR_DEVICE_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR, |
|---|
| 604 | | - get_temp_max_hyst, set_temp_max_hyst, 1); |
|---|
| 571 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp_input, 0); |
|---|
| 572 | +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp_input, 1); |
|---|
| 573 | +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); |
|---|
| 574 | +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); |
|---|
| 575 | +static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, temp_max_hyst, 0); |
|---|
| 576 | +static SENSOR_DEVICE_ATTR_RW(temp2_max_hyst, temp_max_hyst, 1); |
|---|
| 605 | 577 | |
|---|
| 606 | 578 | static ssize_t alarms_show(struct device *dev, struct device_attribute *attr, |
|---|
| 607 | 579 | char *buf) |
|---|
| .. | .. |
|---|
| 674 | 646 | static DEVICE_ATTR_RW(beep_enable); |
|---|
| 675 | 647 | static DEVICE_ATTR_RW(beep_mask); |
|---|
| 676 | 648 | |
|---|
| 677 | | -static ssize_t get_alarm(struct device *dev, struct device_attribute *attr, |
|---|
| 678 | | - char *buf) |
|---|
| 649 | +static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, |
|---|
| 650 | + char *buf) |
|---|
| 679 | 651 | { |
|---|
| 680 | 652 | int bit_nr = to_sensor_dev_attr(attr)->index; |
|---|
| 681 | 653 | struct gl520_data *data = gl520_update_device(dev); |
|---|
| .. | .. |
|---|
| 683 | 655 | return sprintf(buf, "%d\n", (data->alarms >> bit_nr) & 1); |
|---|
| 684 | 656 | } |
|---|
| 685 | 657 | |
|---|
| 686 | | -static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, get_alarm, NULL, 0); |
|---|
| 687 | | -static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, get_alarm, NULL, 1); |
|---|
| 688 | | -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, get_alarm, NULL, 2); |
|---|
| 689 | | -static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, get_alarm, NULL, 3); |
|---|
| 690 | | -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, get_alarm, NULL, 4); |
|---|
| 691 | | -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, get_alarm, NULL, 5); |
|---|
| 692 | | -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, get_alarm, NULL, 6); |
|---|
| 693 | | -static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, get_alarm, NULL, 7); |
|---|
| 694 | | -static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, get_alarm, NULL, 7); |
|---|
| 658 | +static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 0); |
|---|
| 659 | +static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 1); |
|---|
| 660 | +static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 2); |
|---|
| 661 | +static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3); |
|---|
| 662 | +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 4); |
|---|
| 663 | +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 5); |
|---|
| 664 | +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 6); |
|---|
| 665 | +static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, 7); |
|---|
| 666 | +static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 7); |
|---|
| 695 | 667 | |
|---|
| 696 | | -static ssize_t get_beep(struct device *dev, struct device_attribute *attr, |
|---|
| 697 | | - char *buf) |
|---|
| 668 | +static ssize_t beep_show(struct device *dev, struct device_attribute *attr, |
|---|
| 669 | + char *buf) |
|---|
| 698 | 670 | { |
|---|
| 699 | 671 | int bitnr = to_sensor_dev_attr(attr)->index; |
|---|
| 700 | 672 | struct gl520_data *data = gl520_update_device(dev); |
|---|
| .. | .. |
|---|
| 702 | 674 | return sprintf(buf, "%d\n", (data->beep_mask >> bitnr) & 1); |
|---|
| 703 | 675 | } |
|---|
| 704 | 676 | |
|---|
| 705 | | -static ssize_t set_beep(struct device *dev, struct device_attribute *attr, |
|---|
| 706 | | - const char *buf, size_t count) |
|---|
| 677 | +static ssize_t beep_store(struct device *dev, struct device_attribute *attr, |
|---|
| 678 | + const char *buf, size_t count) |
|---|
| 707 | 679 | { |
|---|
| 708 | 680 | struct gl520_data *data = dev_get_drvdata(dev); |
|---|
| 709 | 681 | struct i2c_client *client = data->client; |
|---|
| .. | .. |
|---|
| 729 | 701 | return count; |
|---|
| 730 | 702 | } |
|---|
| 731 | 703 | |
|---|
| 732 | | -static SENSOR_DEVICE_ATTR(in0_beep, S_IRUGO | S_IWUSR, get_beep, set_beep, 0); |
|---|
| 733 | | -static SENSOR_DEVICE_ATTR(in1_beep, S_IRUGO | S_IWUSR, get_beep, set_beep, 1); |
|---|
| 734 | | -static SENSOR_DEVICE_ATTR(in2_beep, S_IRUGO | S_IWUSR, get_beep, set_beep, 2); |
|---|
| 735 | | -static SENSOR_DEVICE_ATTR(in3_beep, S_IRUGO | S_IWUSR, get_beep, set_beep, 3); |
|---|
| 736 | | -static SENSOR_DEVICE_ATTR(temp1_beep, S_IRUGO | S_IWUSR, get_beep, set_beep, 4); |
|---|
| 737 | | -static SENSOR_DEVICE_ATTR(fan1_beep, S_IRUGO | S_IWUSR, get_beep, set_beep, 5); |
|---|
| 738 | | -static SENSOR_DEVICE_ATTR(fan2_beep, S_IRUGO | S_IWUSR, get_beep, set_beep, 6); |
|---|
| 739 | | -static SENSOR_DEVICE_ATTR(temp2_beep, S_IRUGO | S_IWUSR, get_beep, set_beep, 7); |
|---|
| 740 | | -static SENSOR_DEVICE_ATTR(in4_beep, S_IRUGO | S_IWUSR, get_beep, set_beep, 7); |
|---|
| 704 | +static SENSOR_DEVICE_ATTR_RW(in0_beep, beep, 0); |
|---|
| 705 | +static SENSOR_DEVICE_ATTR_RW(in1_beep, beep, 1); |
|---|
| 706 | +static SENSOR_DEVICE_ATTR_RW(in2_beep, beep, 2); |
|---|
| 707 | +static SENSOR_DEVICE_ATTR_RW(in3_beep, beep, 3); |
|---|
| 708 | +static SENSOR_DEVICE_ATTR_RW(temp1_beep, beep, 4); |
|---|
| 709 | +static SENSOR_DEVICE_ATTR_RW(fan1_beep, beep, 5); |
|---|
| 710 | +static SENSOR_DEVICE_ATTR_RW(fan2_beep, beep, 6); |
|---|
| 711 | +static SENSOR_DEVICE_ATTR_RW(temp2_beep, beep, 7); |
|---|
| 712 | +static SENSOR_DEVICE_ATTR_RW(in4_beep, beep, 7); |
|---|
| 741 | 713 | |
|---|
| 742 | 714 | static struct attribute *gl520_attributes[] = { |
|---|
| 743 | 715 | &dev_attr_cpu0_vid.attr, |
|---|
| .. | .. |
|---|
| 882 | 854 | gl520_write_value(client, GL520_REG_BEEP_MASK, data->beep_mask); |
|---|
| 883 | 855 | } |
|---|
| 884 | 856 | |
|---|
| 885 | | -static int gl520_probe(struct i2c_client *client, |
|---|
| 886 | | - const struct i2c_device_id *id) |
|---|
| 857 | +static int gl520_probe(struct i2c_client *client) |
|---|
| 887 | 858 | { |
|---|
| 888 | 859 | struct device *dev = &client->dev; |
|---|
| 889 | 860 | struct device *hwmon_dev; |
|---|
| .. | .. |
|---|
| 924 | 895 | .driver = { |
|---|
| 925 | 896 | .name = "gl520sm", |
|---|
| 926 | 897 | }, |
|---|
| 927 | | - .probe = gl520_probe, |
|---|
| 898 | + .probe_new = gl520_probe, |
|---|
| 928 | 899 | .id_table = gl520_id, |
|---|
| 929 | 900 | .detect = gl520_detect, |
|---|
| 930 | 901 | .address_list = normal_i2c, |
|---|