| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2011 Alexander Stein <alexander.stein@systec-electronic.com> |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | * It reports up to two temperatures (its own plus an external one). |
|---|
| 6 | 7 | * |
|---|
| 7 | 8 | * This driver is based on lm95241.c |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 10 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 11 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 12 | | - * (at your option) any later version. |
|---|
| 13 | | - * |
|---|
| 14 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | | - * GNU General Public License for more details. |
|---|
| 18 | 9 | */ |
|---|
| 19 | 10 | |
|---|
| 20 | 11 | #include <linux/err.h> |
|---|
| .. | .. |
|---|
| 91 | 82 | #define MANUFACTURER_ID 0x01 |
|---|
| 92 | 83 | #define LM95235_REVISION 0xB1 |
|---|
| 93 | 84 | #define LM95245_REVISION 0xB3 |
|---|
| 94 | | - |
|---|
| 95 | | -static const u8 lm95245_reg_address[] = { |
|---|
| 96 | | - LM95245_REG_R_LOCAL_TEMPH_S, |
|---|
| 97 | | - LM95245_REG_R_LOCAL_TEMPL_S, |
|---|
| 98 | | - LM95245_REG_R_REMOTE_TEMPH_S, |
|---|
| 99 | | - LM95245_REG_R_REMOTE_TEMPL_S, |
|---|
| 100 | | - LM95245_REG_R_REMOTE_TEMPH_U, |
|---|
| 101 | | - LM95245_REG_R_REMOTE_TEMPL_U, |
|---|
| 102 | | - LM95245_REG_RW_LOCAL_OS_TCRIT_LIMIT, |
|---|
| 103 | | - LM95245_REG_RW_REMOTE_TCRIT_LIMIT, |
|---|
| 104 | | - LM95245_REG_RW_COMMON_HYSTERESIS, |
|---|
| 105 | | - LM95245_REG_R_STATUS1, |
|---|
| 106 | | -}; |
|---|
| 107 | 85 | |
|---|
| 108 | 86 | /* Client data (each client gets its own) */ |
|---|
| 109 | 87 | struct lm95245_data { |
|---|
| .. | .. |
|---|
| 421 | 399 | case hwmon_temp_max_hyst: |
|---|
| 422 | 400 | case hwmon_temp_crit_alarm: |
|---|
| 423 | 401 | case hwmon_temp_fault: |
|---|
| 424 | | - return S_IRUGO; |
|---|
| 402 | + return 0444; |
|---|
| 425 | 403 | case hwmon_temp_type: |
|---|
| 426 | 404 | case hwmon_temp_max: |
|---|
| 427 | 405 | case hwmon_temp_crit: |
|---|
| 428 | 406 | case hwmon_temp_offset: |
|---|
| 429 | | - return S_IRUGO | S_IWUSR; |
|---|
| 407 | + return 0644; |
|---|
| 430 | 408 | case hwmon_temp_crit_hyst: |
|---|
| 431 | | - return (channel == 0) ? S_IRUGO | S_IWUSR : S_IRUGO; |
|---|
| 409 | + return (channel == 0) ? 0644 : 0444; |
|---|
| 432 | 410 | default: |
|---|
| 433 | 411 | return 0; |
|---|
| 434 | 412 | } |
|---|
| .. | .. |
|---|
| 442 | 420 | case hwmon_chip: |
|---|
| 443 | 421 | switch (attr) { |
|---|
| 444 | 422 | case hwmon_chip_update_interval: |
|---|
| 445 | | - return S_IRUGO | S_IWUSR; |
|---|
| 423 | + return 0644; |
|---|
| 446 | 424 | default: |
|---|
| 447 | 425 | return 0; |
|---|
| 448 | 426 | } |
|---|
| .. | .. |
|---|
| 541 | 519 | .writeable_reg = lm95245_is_writeable_reg, |
|---|
| 542 | 520 | .volatile_reg = lm95245_is_volatile_reg, |
|---|
| 543 | 521 | .cache_type = REGCACHE_RBTREE, |
|---|
| 544 | | - .use_single_rw = true, |
|---|
| 545 | | -}; |
|---|
| 546 | | - |
|---|
| 547 | | -static const u32 lm95245_chip_config[] = { |
|---|
| 548 | | - HWMON_C_UPDATE_INTERVAL, |
|---|
| 549 | | - 0 |
|---|
| 550 | | -}; |
|---|
| 551 | | - |
|---|
| 552 | | -static const struct hwmon_channel_info lm95245_chip = { |
|---|
| 553 | | - .type = hwmon_chip, |
|---|
| 554 | | - .config = lm95245_chip_config, |
|---|
| 555 | | -}; |
|---|
| 556 | | - |
|---|
| 557 | | -static const u32 lm95245_temp_config[] = { |
|---|
| 558 | | - HWMON_T_INPUT | HWMON_T_CRIT | HWMON_T_CRIT_HYST | HWMON_T_CRIT_ALARM, |
|---|
| 559 | | - HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MAX_HYST | HWMON_T_CRIT | |
|---|
| 560 | | - HWMON_T_CRIT_HYST | HWMON_T_FAULT | HWMON_T_MAX_ALARM | |
|---|
| 561 | | - HWMON_T_CRIT_ALARM | HWMON_T_TYPE | HWMON_T_OFFSET, |
|---|
| 562 | | - 0 |
|---|
| 563 | | -}; |
|---|
| 564 | | - |
|---|
| 565 | | -static const struct hwmon_channel_info lm95245_temp = { |
|---|
| 566 | | - .type = hwmon_temp, |
|---|
| 567 | | - .config = lm95245_temp_config, |
|---|
| 522 | + .use_single_read = true, |
|---|
| 523 | + .use_single_write = true, |
|---|
| 568 | 524 | }; |
|---|
| 569 | 525 | |
|---|
| 570 | 526 | static const struct hwmon_channel_info *lm95245_info[] = { |
|---|
| 571 | | - &lm95245_chip, |
|---|
| 572 | | - &lm95245_temp, |
|---|
| 527 | + HWMON_CHANNEL_INFO(chip, |
|---|
| 528 | + HWMON_C_UPDATE_INTERVAL), |
|---|
| 529 | + HWMON_CHANNEL_INFO(temp, |
|---|
| 530 | + HWMON_T_INPUT | HWMON_T_CRIT | HWMON_T_CRIT_HYST | |
|---|
| 531 | + HWMON_T_CRIT_ALARM, |
|---|
| 532 | + HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MAX_HYST | |
|---|
| 533 | + HWMON_T_CRIT | HWMON_T_CRIT_HYST | HWMON_T_FAULT | |
|---|
| 534 | + HWMON_T_MAX_ALARM | HWMON_T_CRIT_ALARM | |
|---|
| 535 | + HWMON_T_TYPE | HWMON_T_OFFSET), |
|---|
| 573 | 536 | NULL |
|---|
| 574 | 537 | }; |
|---|
| 575 | 538 | |
|---|
| .. | .. |
|---|
| 584 | 547 | .info = lm95245_info, |
|---|
| 585 | 548 | }; |
|---|
| 586 | 549 | |
|---|
| 587 | | -static int lm95245_probe(struct i2c_client *client, |
|---|
| 588 | | - const struct i2c_device_id *id) |
|---|
| 550 | +static int lm95245_probe(struct i2c_client *client) |
|---|
| 589 | 551 | { |
|---|
| 590 | 552 | struct device *dev = &client->dev; |
|---|
| 591 | 553 | struct lm95245_data *data; |
|---|
| .. | .. |
|---|
| 622 | 584 | }; |
|---|
| 623 | 585 | MODULE_DEVICE_TABLE(i2c, lm95245_id); |
|---|
| 624 | 586 | |
|---|
| 625 | | -static const struct of_device_id lm95245_of_match[] = { |
|---|
| 587 | +static const struct of_device_id __maybe_unused lm95245_of_match[] = { |
|---|
| 626 | 588 | { .compatible = "national,lm95235" }, |
|---|
| 627 | 589 | { .compatible = "national,lm95245" }, |
|---|
| 628 | 590 | { }, |
|---|
| .. | .. |
|---|
| 635 | 597 | .name = "lm95245", |
|---|
| 636 | 598 | .of_match_table = of_match_ptr(lm95245_of_match), |
|---|
| 637 | 599 | }, |
|---|
| 638 | | - .probe = lm95245_probe, |
|---|
| 600 | + .probe_new = lm95245_probe, |
|---|
| 639 | 601 | .id_table = lm95245_id, |
|---|
| 640 | 602 | .detect = lm95245_detect, |
|---|
| 641 | 603 | .address_list = normal_i2c, |
|---|