| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * jc42.c - driver for Jedec JC42.4 compliant temperature sensors |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 6 | 7 | * Derived from lm77.c by Andras BALI <drewie@freemail.hu>. |
|---|
| 7 | 8 | * |
|---|
| 8 | 9 | * JC42.4 compliant temperature sensors are typically used on memory modules. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 11 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 12 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 13 | | - * (at your option) any later version. |
|---|
| 14 | | - * |
|---|
| 15 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 16 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 17 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 18 | | - * GNU General Public License for more details. |
|---|
| 19 | | - * |
|---|
| 20 | | - * You should have received a copy of the GNU General Public License |
|---|
| 21 | | - * along with this program; if not, write to the Free Software |
|---|
| 22 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 23 | 10 | */ |
|---|
| 24 | 11 | |
|---|
| 25 | 12 | #include <linux/bitops.h> |
|---|
| .. | .. |
|---|
| 390 | 377 | { |
|---|
| 391 | 378 | const struct jc42_data *data = _data; |
|---|
| 392 | 379 | unsigned int config = data->config; |
|---|
| 393 | | - umode_t mode = S_IRUGO; |
|---|
| 380 | + umode_t mode = 0444; |
|---|
| 394 | 381 | |
|---|
| 395 | 382 | switch (attr) { |
|---|
| 396 | 383 | case hwmon_temp_min: |
|---|
| 397 | 384 | case hwmon_temp_max: |
|---|
| 398 | 385 | if (!(config & JC42_CFG_EVENT_LOCK)) |
|---|
| 399 | | - mode |= S_IWUSR; |
|---|
| 386 | + mode |= 0200; |
|---|
| 400 | 387 | break; |
|---|
| 401 | 388 | case hwmon_temp_crit: |
|---|
| 402 | 389 | if (!(config & JC42_CFG_TCRIT_LOCK)) |
|---|
| 403 | | - mode |= S_IWUSR; |
|---|
| 390 | + mode |= 0200; |
|---|
| 404 | 391 | break; |
|---|
| 405 | 392 | case hwmon_temp_crit_hyst: |
|---|
| 406 | 393 | if (!(config & (JC42_CFG_EVENT_LOCK | JC42_CFG_TCRIT_LOCK))) |
|---|
| 407 | | - mode |= S_IWUSR; |
|---|
| 394 | + mode |= 0200; |
|---|
| 408 | 395 | break; |
|---|
| 409 | 396 | case hwmon_temp_input: |
|---|
| 410 | 397 | case hwmon_temp_max_hyst: |
|---|
| .. | .. |
|---|
| 451 | 438 | return -ENODEV; |
|---|
| 452 | 439 | } |
|---|
| 453 | 440 | |
|---|
| 454 | | -static const u32 jc42_temp_config[] = { |
|---|
| 455 | | - HWMON_T_INPUT | HWMON_T_MIN | HWMON_T_MAX | HWMON_T_CRIT | |
|---|
| 456 | | - HWMON_T_MAX_HYST | HWMON_T_CRIT_HYST | |
|---|
| 457 | | - HWMON_T_MIN_ALARM | HWMON_T_MAX_ALARM | HWMON_T_CRIT_ALARM, |
|---|
| 458 | | - 0 |
|---|
| 459 | | -}; |
|---|
| 460 | | - |
|---|
| 461 | | -static const struct hwmon_channel_info jc42_temp = { |
|---|
| 462 | | - .type = hwmon_temp, |
|---|
| 463 | | - .config = jc42_temp_config, |
|---|
| 464 | | -}; |
|---|
| 465 | | - |
|---|
| 466 | 441 | static const struct hwmon_channel_info *jc42_info[] = { |
|---|
| 467 | | - &jc42_temp, |
|---|
| 442 | + HWMON_CHANNEL_INFO(temp, |
|---|
| 443 | + HWMON_T_INPUT | HWMON_T_MIN | HWMON_T_MAX | |
|---|
| 444 | + HWMON_T_CRIT | HWMON_T_MAX_HYST | |
|---|
| 445 | + HWMON_T_CRIT_HYST | HWMON_T_MIN_ALARM | |
|---|
| 446 | + HWMON_T_MAX_ALARM | HWMON_T_CRIT_ALARM), |
|---|
| 468 | 447 | NULL |
|---|
| 469 | 448 | }; |
|---|
| 470 | 449 | |
|---|
| .. | .. |
|---|
| 479 | 458 | .info = jc42_info, |
|---|
| 480 | 459 | }; |
|---|
| 481 | 460 | |
|---|
| 482 | | -static int jc42_probe(struct i2c_client *client, const struct i2c_device_id *id) |
|---|
| 461 | +static int jc42_probe(struct i2c_client *client) |
|---|
| 483 | 462 | { |
|---|
| 484 | 463 | struct device *dev = &client->dev; |
|---|
| 485 | 464 | struct device *hwmon_dev; |
|---|
| .. | .. |
|---|
| 602 | 581 | .pm = JC42_DEV_PM_OPS, |
|---|
| 603 | 582 | .of_match_table = of_match_ptr(jc42_of_ids), |
|---|
| 604 | 583 | }, |
|---|
| 605 | | - .probe = jc42_probe, |
|---|
| 584 | + .probe_new = jc42_probe, |
|---|
| 606 | 585 | .remove = jc42_remove, |
|---|
| 607 | 586 | .id_table = jc42_id, |
|---|
| 608 | 587 | .detect = jc42_detect, |
|---|