| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * lm77.c - Part of lm_sensors, Linux kernel modules for hardware |
|---|
| 3 | 4 | * monitoring |
|---|
| .. | .. |
|---|
| 9 | 10 | * resolution made by National Semiconductor. Complete datasheet can be |
|---|
| 10 | 11 | * obtained at their site: |
|---|
| 11 | 12 | * http://www.national.com/pf/LM/LM77.html |
|---|
| 12 | | - * |
|---|
| 13 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 14 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 15 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 16 | | - * (at your option) any later version. |
|---|
| 17 | | - * |
|---|
| 18 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 19 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 20 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 21 | | - * GNU General Public License for more details. |
|---|
| 22 | 13 | */ |
|---|
| 23 | 14 | |
|---|
| 24 | 15 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 137 | 128 | |
|---|
| 138 | 129 | /* sysfs stuff */ |
|---|
| 139 | 130 | |
|---|
| 140 | | -static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, |
|---|
| 131 | +static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, |
|---|
| 141 | 132 | char *buf) |
|---|
| 142 | 133 | { |
|---|
| 143 | 134 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
|---|
| .. | .. |
|---|
| 146 | 137 | return sprintf(buf, "%d\n", data->temp[attr->index]); |
|---|
| 147 | 138 | } |
|---|
| 148 | 139 | |
|---|
| 149 | | -static ssize_t show_temp_hyst(struct device *dev, |
|---|
| 140 | +static ssize_t temp_hyst_show(struct device *dev, |
|---|
| 150 | 141 | struct device_attribute *devattr, char *buf) |
|---|
| 151 | 142 | { |
|---|
| 152 | 143 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
|---|
| .. | .. |
|---|
| 160 | 151 | return sprintf(buf, "%d\n", temp); |
|---|
| 161 | 152 | } |
|---|
| 162 | 153 | |
|---|
| 163 | | -static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, |
|---|
| 164 | | - const char *buf, size_t count) |
|---|
| 154 | +static ssize_t temp_store(struct device *dev, |
|---|
| 155 | + struct device_attribute *devattr, const char *buf, |
|---|
| 156 | + size_t count) |
|---|
| 165 | 157 | { |
|---|
| 166 | 158 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
|---|
| 167 | 159 | struct lm77_data *data = dev_get_drvdata(dev); |
|---|
| .. | .. |
|---|
| 186 | 178 | * hysteresis is stored as a relative value on the chip, so it has to be |
|---|
| 187 | 179 | * converted first. |
|---|
| 188 | 180 | */ |
|---|
| 189 | | -static ssize_t set_temp_hyst(struct device *dev, |
|---|
| 190 | | - struct device_attribute *devattr, |
|---|
| 191 | | - const char *buf, size_t count) |
|---|
| 181 | +static ssize_t temp_hyst_store(struct device *dev, |
|---|
| 182 | + struct device_attribute *devattr, |
|---|
| 183 | + const char *buf, size_t count) |
|---|
| 192 | 184 | { |
|---|
| 193 | 185 | struct lm77_data *data = dev_get_drvdata(dev); |
|---|
| 194 | 186 | struct i2c_client *client = data->client; |
|---|
| .. | .. |
|---|
| 208 | 200 | return count; |
|---|
| 209 | 201 | } |
|---|
| 210 | 202 | |
|---|
| 211 | | -static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, |
|---|
| 203 | +static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, |
|---|
| 212 | 204 | char *buf) |
|---|
| 213 | 205 | { |
|---|
| 214 | 206 | int bitnr = to_sensor_dev_attr(attr)->index; |
|---|
| .. | .. |
|---|
| 216 | 208 | return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); |
|---|
| 217 | 209 | } |
|---|
| 218 | 210 | |
|---|
| 219 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, t_input); |
|---|
| 220 | | -static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp, set_temp, |
|---|
| 221 | | - t_crit); |
|---|
| 222 | | -static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp, set_temp, |
|---|
| 223 | | - t_min); |
|---|
| 224 | | -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp, set_temp, |
|---|
| 225 | | - t_max); |
|---|
| 211 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, t_input); |
|---|
| 212 | +static SENSOR_DEVICE_ATTR_RW(temp1_crit, temp, t_crit); |
|---|
| 213 | +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp, t_min); |
|---|
| 214 | +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, t_max); |
|---|
| 226 | 215 | |
|---|
| 227 | | -static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temp_hyst, |
|---|
| 228 | | - set_temp_hyst, t_crit); |
|---|
| 229 | | -static SENSOR_DEVICE_ATTR(temp1_min_hyst, S_IRUGO, show_temp_hyst, NULL, t_min); |
|---|
| 230 | | -static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO, show_temp_hyst, NULL, t_max); |
|---|
| 216 | +static SENSOR_DEVICE_ATTR_RW(temp1_crit_hyst, temp_hyst, t_crit); |
|---|
| 217 | +static SENSOR_DEVICE_ATTR_RO(temp1_min_hyst, temp_hyst, t_min); |
|---|
| 218 | +static SENSOR_DEVICE_ATTR_RO(temp1_max_hyst, temp_hyst, t_max); |
|---|
| 231 | 219 | |
|---|
| 232 | | -static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 2); |
|---|
| 233 | | -static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 0); |
|---|
| 234 | | -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 1); |
|---|
| 220 | +static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, alarm, 2); |
|---|
| 221 | +static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, 0); |
|---|
| 222 | +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 1); |
|---|
| 235 | 223 | |
|---|
| 236 | 224 | static struct attribute *lm77_attrs[] = { |
|---|
| 237 | 225 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
|---|
| .. | .. |
|---|
| 327 | 315 | lm77_write_value(client, LM77_REG_CONF, conf & 0xfe); |
|---|
| 328 | 316 | } |
|---|
| 329 | 317 | |
|---|
| 330 | | -static int lm77_probe(struct i2c_client *client, const struct i2c_device_id *id) |
|---|
| 318 | +static int lm77_probe(struct i2c_client *client) |
|---|
| 331 | 319 | { |
|---|
| 332 | 320 | struct device *dev = &client->dev; |
|---|
| 333 | 321 | struct device *hwmon_dev; |
|---|
| .. | .. |
|---|
| 360 | 348 | .driver = { |
|---|
| 361 | 349 | .name = "lm77", |
|---|
| 362 | 350 | }, |
|---|
| 363 | | - .probe = lm77_probe, |
|---|
| 351 | + .probe_new = lm77_probe, |
|---|
| 364 | 352 | .id_table = lm77_id, |
|---|
| 365 | 353 | .detect = lm77_detect, |
|---|
| 366 | 354 | .address_list = normal_i2c, |
|---|