| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* Honeywell HIH-6130/HIH-6131 humidity and temperature sensor driver |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * Copyright (C) 2012 Iain Paton <ipaton0@gmail.com> |
|---|
| 4 | 5 | * |
|---|
| 5 | 6 | * heavily based on the sht21 driver |
|---|
| 6 | 7 | * Copyright (C) 2010 Urs Fleisch <urs.fleisch@sensirion.com> |
|---|
| 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 21 | 8 | * |
|---|
| 22 | 9 | * Data sheets available (2012-06-22) at |
|---|
| 23 | 10 | * http://sensing.honeywell.com/index.php?ci_id=3106&la_id=1&defId=44872 |
|---|
| .. | .. |
|---|
| 171 | 158 | * Will be called on read access to temp1_input sysfs attribute. |
|---|
| 172 | 159 | * Returns number of bytes written into buffer, negative errno on error. |
|---|
| 173 | 160 | */ |
|---|
| 174 | | -static ssize_t hih6130_show_temperature(struct device *dev, |
|---|
| 161 | +static ssize_t hih6130_temperature_show(struct device *dev, |
|---|
| 175 | 162 | struct device_attribute *attr, |
|---|
| 176 | 163 | char *buf) |
|---|
| 177 | 164 | { |
|---|
| .. | .. |
|---|
| 193 | 180 | * Will be called on read access to humidity1_input sysfs attribute. |
|---|
| 194 | 181 | * Returns number of bytes written into buffer, negative errno on error. |
|---|
| 195 | 182 | */ |
|---|
| 196 | | -static ssize_t hih6130_show_humidity(struct device *dev, |
|---|
| 183 | +static ssize_t hih6130_humidity_show(struct device *dev, |
|---|
| 197 | 184 | struct device_attribute *attr, char *buf) |
|---|
| 198 | 185 | { |
|---|
| 199 | 186 | struct hih6130 *hih6130 = dev_get_drvdata(dev); |
|---|
| .. | .. |
|---|
| 206 | 193 | } |
|---|
| 207 | 194 | |
|---|
| 208 | 195 | /* sysfs attributes */ |
|---|
| 209 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, hih6130_show_temperature, |
|---|
| 210 | | - NULL, 0); |
|---|
| 211 | | -static SENSOR_DEVICE_ATTR(humidity1_input, S_IRUGO, hih6130_show_humidity, |
|---|
| 212 | | - NULL, 0); |
|---|
| 196 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, hih6130_temperature, 0); |
|---|
| 197 | +static SENSOR_DEVICE_ATTR_RO(humidity1_input, hih6130_humidity, 0); |
|---|
| 213 | 198 | |
|---|
| 214 | 199 | static struct attribute *hih6130_attrs[] = { |
|---|
| 215 | 200 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
|---|
| .. | .. |
|---|
| 219 | 204 | |
|---|
| 220 | 205 | ATTRIBUTE_GROUPS(hih6130); |
|---|
| 221 | 206 | |
|---|
| 222 | | -static int hih6130_probe(struct i2c_client *client, |
|---|
| 223 | | - const struct i2c_device_id *id) |
|---|
| 207 | +static int hih6130_probe(struct i2c_client *client) |
|---|
| 224 | 208 | { |
|---|
| 225 | 209 | struct device *dev = &client->dev; |
|---|
| 226 | 210 | struct hih6130 *hih6130; |
|---|
| .. | .. |
|---|
| 254 | 238 | }; |
|---|
| 255 | 239 | MODULE_DEVICE_TABLE(i2c, hih6130_id); |
|---|
| 256 | 240 | |
|---|
| 241 | +static const struct of_device_id __maybe_unused hih6130_of_match[] = { |
|---|
| 242 | + { .compatible = "honeywell,hih6130", }, |
|---|
| 243 | + { } |
|---|
| 244 | +}; |
|---|
| 245 | +MODULE_DEVICE_TABLE(of, hih6130_of_match); |
|---|
| 246 | + |
|---|
| 257 | 247 | static struct i2c_driver hih6130_driver = { |
|---|
| 258 | | - .driver.name = "hih6130", |
|---|
| 259 | | - .probe = hih6130_probe, |
|---|
| 248 | + .driver = { |
|---|
| 249 | + .name = "hih6130", |
|---|
| 250 | + .of_match_table = of_match_ptr(hih6130_of_match), |
|---|
| 251 | + }, |
|---|
| 252 | + .probe_new = hih6130_probe, |
|---|
| 260 | 253 | .id_table = hih6130_id, |
|---|
| 261 | 254 | }; |
|---|
| 262 | 255 | |
|---|