| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* Sensirion SHT3x-DIS humidity and temperature sensor driver. |
|---|
| 2 | 3 | * The SHT3x comes in many different versions, this driver is for the |
|---|
| 3 | 4 | * I2C version only. |
|---|
| .. | .. |
|---|
| 5 | 6 | * Copyright (C) 2016 Sensirion AG, Switzerland |
|---|
| 6 | 7 | * Author: David Frey <david.frey@sensirion.com> |
|---|
| 7 | 8 | * Author: Pascal Sachs <pascal.sachs@sensirion.com> |
|---|
| 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 | | - * |
|---|
| 19 | 9 | */ |
|---|
| 20 | 10 | |
|---|
| 21 | 11 | #include <asm/page.h> |
|---|
| .. | .. |
|---|
| 629 | 619 | return count; |
|---|
| 630 | 620 | } |
|---|
| 631 | 621 | |
|---|
| 632 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, temp1_input_show, NULL, 0); |
|---|
| 633 | | -static SENSOR_DEVICE_ATTR(humidity1_input, S_IRUGO, humidity1_input_show, |
|---|
| 634 | | - NULL, 0); |
|---|
| 635 | | -static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, |
|---|
| 636 | | - temp1_limit_show, temp1_limit_store, |
|---|
| 637 | | - limit_max); |
|---|
| 638 | | -static SENSOR_DEVICE_ATTR(humidity1_max, S_IRUGO | S_IWUSR, |
|---|
| 639 | | - humidity1_limit_show, humidity1_limit_store, |
|---|
| 640 | | - limit_max); |
|---|
| 641 | | -static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, |
|---|
| 642 | | - temp1_limit_show, temp1_limit_store, |
|---|
| 643 | | - limit_max_hyst); |
|---|
| 644 | | -static SENSOR_DEVICE_ATTR(humidity1_max_hyst, S_IRUGO | S_IWUSR, |
|---|
| 645 | | - humidity1_limit_show, humidity1_limit_store, |
|---|
| 646 | | - limit_max_hyst); |
|---|
| 647 | | -static SENSOR_DEVICE_ATTR(temp1_min, S_IRUGO | S_IWUSR, |
|---|
| 648 | | - temp1_limit_show, temp1_limit_store, |
|---|
| 649 | | - limit_min); |
|---|
| 650 | | -static SENSOR_DEVICE_ATTR(humidity1_min, S_IRUGO | S_IWUSR, |
|---|
| 651 | | - humidity1_limit_show, humidity1_limit_store, |
|---|
| 652 | | - limit_min); |
|---|
| 653 | | -static SENSOR_DEVICE_ATTR(temp1_min_hyst, S_IRUGO | S_IWUSR, |
|---|
| 654 | | - temp1_limit_show, temp1_limit_store, |
|---|
| 655 | | - limit_min_hyst); |
|---|
| 656 | | -static SENSOR_DEVICE_ATTR(humidity1_min_hyst, S_IRUGO | S_IWUSR, |
|---|
| 657 | | - humidity1_limit_show, humidity1_limit_store, |
|---|
| 658 | | - limit_min_hyst); |
|---|
| 659 | | -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, temp1_alarm_show, NULL, 0); |
|---|
| 660 | | -static SENSOR_DEVICE_ATTR(humidity1_alarm, S_IRUGO, humidity1_alarm_show, |
|---|
| 661 | | - NULL, 0); |
|---|
| 662 | | -static SENSOR_DEVICE_ATTR(heater_enable, S_IRUGO | S_IWUSR, |
|---|
| 663 | | - heater_enable_show, heater_enable_store, 0); |
|---|
| 664 | | -static SENSOR_DEVICE_ATTR(update_interval, S_IRUGO | S_IWUSR, |
|---|
| 665 | | - update_interval_show, update_interval_store, 0); |
|---|
| 622 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp1_input, 0); |
|---|
| 623 | +static SENSOR_DEVICE_ATTR_RO(humidity1_input, humidity1_input, 0); |
|---|
| 624 | +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp1_limit, limit_max); |
|---|
| 625 | +static SENSOR_DEVICE_ATTR_RW(humidity1_max, humidity1_limit, limit_max); |
|---|
| 626 | +static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, temp1_limit, limit_max_hyst); |
|---|
| 627 | +static SENSOR_DEVICE_ATTR_RW(humidity1_max_hyst, humidity1_limit, |
|---|
| 628 | + limit_max_hyst); |
|---|
| 629 | +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp1_limit, limit_min); |
|---|
| 630 | +static SENSOR_DEVICE_ATTR_RW(humidity1_min, humidity1_limit, limit_min); |
|---|
| 631 | +static SENSOR_DEVICE_ATTR_RW(temp1_min_hyst, temp1_limit, limit_min_hyst); |
|---|
| 632 | +static SENSOR_DEVICE_ATTR_RW(humidity1_min_hyst, humidity1_limit, |
|---|
| 633 | + limit_min_hyst); |
|---|
| 634 | +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, temp1_alarm, 0); |
|---|
| 635 | +static SENSOR_DEVICE_ATTR_RO(humidity1_alarm, humidity1_alarm, 0); |
|---|
| 636 | +static SENSOR_DEVICE_ATTR_RW(heater_enable, heater_enable, 0); |
|---|
| 637 | +static SENSOR_DEVICE_ATTR_RW(update_interval, update_interval, 0); |
|---|
| 666 | 638 | |
|---|
| 667 | 639 | static struct attribute *sht3x_attrs[] = { |
|---|
| 668 | 640 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
|---|
| .. | .. |
|---|
| 690 | 662 | ATTRIBUTE_GROUPS(sht3x); |
|---|
| 691 | 663 | ATTRIBUTE_GROUPS(sts3x); |
|---|
| 692 | 664 | |
|---|
| 693 | | -static int sht3x_probe(struct i2c_client *client, |
|---|
| 694 | | - const struct i2c_device_id *id) |
|---|
| 665 | +static const struct i2c_device_id sht3x_ids[]; |
|---|
| 666 | + |
|---|
| 667 | +static int sht3x_probe(struct i2c_client *client) |
|---|
| 695 | 668 | { |
|---|
| 696 | 669 | int ret; |
|---|
| 697 | 670 | struct sht3x_data *data; |
|---|
| .. | .. |
|---|
| 743 | 716 | if (ret) |
|---|
| 744 | 717 | return ret; |
|---|
| 745 | 718 | |
|---|
| 746 | | - if (id->driver_data == sts3x) |
|---|
| 719 | + if (i2c_match_id(sht3x_ids, client)->driver_data == sts3x) |
|---|
| 747 | 720 | attribute_groups = sts3x_groups; |
|---|
| 748 | 721 | else |
|---|
| 749 | 722 | attribute_groups = sht3x_groups; |
|---|
| .. | .. |
|---|
| 770 | 743 | |
|---|
| 771 | 744 | static struct i2c_driver sht3x_i2c_driver = { |
|---|
| 772 | 745 | .driver.name = "sht3x", |
|---|
| 773 | | - .probe = sht3x_probe, |
|---|
| 746 | + .probe_new = sht3x_probe, |
|---|
| 774 | 747 | .id_table = sht3x_ids, |
|---|
| 775 | 748 | }; |
|---|
| 776 | 749 | |
|---|