| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * adt7x10.c - Part of lm_sensors, Linux kernel modules for hardware |
|---|
| 3 | 4 | * monitoring |
|---|
| .. | .. |
|---|
| 5 | 6 | * Hartmut Knaack <knaack.h@gmx.de> 2012-07-22 |
|---|
| 6 | 7 | * based on lm75.c by Frodo Looijaard <frodol@dds.nl> |
|---|
| 7 | 8 | * and adt7410.c from iio-staging by Sonic Zhang <sonic.zhang@analog.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 | | - * You should have received a copy of the GNU General Public License |
|---|
| 20 | | - * along with this program; if not, write to the Free Software |
|---|
| 21 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 22 | 9 | */ |
|---|
| 23 | 10 | |
|---|
| 24 | 11 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 230 | 217 | |
|---|
| 231 | 218 | /* sysfs attributes for hwmon */ |
|---|
| 232 | 219 | |
|---|
| 233 | | -static ssize_t adt7x10_show_temp(struct device *dev, |
|---|
| 234 | | - struct device_attribute *da, |
|---|
| 235 | | - char *buf) |
|---|
| 220 | +static ssize_t adt7x10_temp_show(struct device *dev, |
|---|
| 221 | + struct device_attribute *da, char *buf) |
|---|
| 236 | 222 | { |
|---|
| 237 | 223 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
|---|
| 238 | 224 | struct adt7x10_data *data = dev_get_drvdata(dev); |
|---|
| .. | .. |
|---|
| 250 | 236 | data->temp[attr->index])); |
|---|
| 251 | 237 | } |
|---|
| 252 | 238 | |
|---|
| 253 | | -static ssize_t adt7x10_set_temp(struct device *dev, |
|---|
| 254 | | - struct device_attribute *da, |
|---|
| 255 | | - const char *buf, size_t count) |
|---|
| 239 | +static ssize_t adt7x10_temp_store(struct device *dev, |
|---|
| 240 | + struct device_attribute *da, |
|---|
| 241 | + const char *buf, size_t count) |
|---|
| 256 | 242 | { |
|---|
| 257 | 243 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
|---|
| 258 | 244 | struct adt7x10_data *data = dev_get_drvdata(dev); |
|---|
| .. | .. |
|---|
| 273 | 259 | return count; |
|---|
| 274 | 260 | } |
|---|
| 275 | 261 | |
|---|
| 276 | | -static ssize_t adt7x10_show_t_hyst(struct device *dev, |
|---|
| 277 | | - struct device_attribute *da, |
|---|
| 278 | | - char *buf) |
|---|
| 262 | +static ssize_t adt7x10_t_hyst_show(struct device *dev, |
|---|
| 263 | + struct device_attribute *da, char *buf) |
|---|
| 279 | 264 | { |
|---|
| 280 | 265 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
|---|
| 281 | 266 | struct adt7x10_data *data = dev_get_drvdata(dev); |
|---|
| .. | .. |
|---|
| 294 | 279 | ADT7X10_REG_TO_TEMP(data, data->temp[nr]) - hyst); |
|---|
| 295 | 280 | } |
|---|
| 296 | 281 | |
|---|
| 297 | | -static ssize_t adt7x10_set_t_hyst(struct device *dev, |
|---|
| 298 | | - struct device_attribute *da, |
|---|
| 299 | | - const char *buf, size_t count) |
|---|
| 282 | +static ssize_t adt7x10_t_hyst_store(struct device *dev, |
|---|
| 283 | + struct device_attribute *da, |
|---|
| 284 | + const char *buf, size_t count) |
|---|
| 300 | 285 | { |
|---|
| 301 | 286 | struct adt7x10_data *data = dev_get_drvdata(dev); |
|---|
| 302 | 287 | int limit, ret; |
|---|
| .. | .. |
|---|
| 317 | 302 | return count; |
|---|
| 318 | 303 | } |
|---|
| 319 | 304 | |
|---|
| 320 | | -static ssize_t adt7x10_show_alarm(struct device *dev, |
|---|
| 321 | | - struct device_attribute *da, |
|---|
| 322 | | - char *buf) |
|---|
| 305 | +static ssize_t adt7x10_alarm_show(struct device *dev, |
|---|
| 306 | + struct device_attribute *da, char *buf) |
|---|
| 323 | 307 | { |
|---|
| 324 | 308 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
|---|
| 325 | 309 | int ret; |
|---|
| .. | .. |
|---|
| 339 | 323 | return sprintf(buf, "%s\n", data->name); |
|---|
| 340 | 324 | } |
|---|
| 341 | 325 | |
|---|
| 342 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, adt7x10_show_temp, NULL, 0); |
|---|
| 343 | | -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, |
|---|
| 344 | | - adt7x10_show_temp, adt7x10_set_temp, 1); |
|---|
| 345 | | -static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, |
|---|
| 346 | | - adt7x10_show_temp, adt7x10_set_temp, 2); |
|---|
| 347 | | -static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, |
|---|
| 348 | | - adt7x10_show_temp, adt7x10_set_temp, 3); |
|---|
| 349 | | -static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, |
|---|
| 350 | | - adt7x10_show_t_hyst, adt7x10_set_t_hyst, 1); |
|---|
| 351 | | -static SENSOR_DEVICE_ATTR(temp1_min_hyst, S_IRUGO, |
|---|
| 352 | | - adt7x10_show_t_hyst, NULL, 2); |
|---|
| 353 | | -static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, |
|---|
| 354 | | - adt7x10_show_t_hyst, NULL, 3); |
|---|
| 355 | | -static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, adt7x10_show_alarm, |
|---|
| 356 | | - NULL, ADT7X10_STAT_T_LOW); |
|---|
| 357 | | -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, adt7x10_show_alarm, |
|---|
| 358 | | - NULL, ADT7X10_STAT_T_HIGH); |
|---|
| 359 | | -static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, adt7x10_show_alarm, |
|---|
| 360 | | - NULL, ADT7X10_STAT_T_CRIT); |
|---|
| 326 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, adt7x10_temp, 0); |
|---|
| 327 | +static SENSOR_DEVICE_ATTR_RW(temp1_max, adt7x10_temp, 1); |
|---|
| 328 | +static SENSOR_DEVICE_ATTR_RW(temp1_min, adt7x10_temp, 2); |
|---|
| 329 | +static SENSOR_DEVICE_ATTR_RW(temp1_crit, adt7x10_temp, 3); |
|---|
| 330 | +static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, adt7x10_t_hyst, 1); |
|---|
| 331 | +static SENSOR_DEVICE_ATTR_RO(temp1_min_hyst, adt7x10_t_hyst, 2); |
|---|
| 332 | +static SENSOR_DEVICE_ATTR_RO(temp1_crit_hyst, adt7x10_t_hyst, 3); |
|---|
| 333 | +static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, adt7x10_alarm, |
|---|
| 334 | + ADT7X10_STAT_T_LOW); |
|---|
| 335 | +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, adt7x10_alarm, |
|---|
| 336 | + ADT7X10_STAT_T_HIGH); |
|---|
| 337 | +static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, adt7x10_alarm, |
|---|
| 338 | + ADT7X10_STAT_T_CRIT); |
|---|
| 361 | 339 | static DEVICE_ATTR_RO(name); |
|---|
| 362 | 340 | |
|---|
| 363 | 341 | static struct attribute *adt7x10_attributes[] = { |
|---|