| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * adm1021.c - Part of lm_sensors, Linux kernel modules for hardware |
|---|
| 3 | 4 | * monitoring |
|---|
| 4 | 5 | * Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> and |
|---|
| 5 | 6 | * Philip Edelbrock <phil@netroedge.com> |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 9 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | | - * (at your option) any later version. |
|---|
| 11 | | - * |
|---|
| 12 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 13 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | | - * GNU General Public License for more details. |
|---|
| 16 | | - * |
|---|
| 17 | | - * You should have received a copy of the GNU General Public License |
|---|
| 18 | | - * along with this program; if not, write to the Free Software |
|---|
| 19 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 20 | 7 | */ |
|---|
| 21 | 8 | |
|---|
| 22 | 9 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 156 | 143 | return data; |
|---|
| 157 | 144 | } |
|---|
| 158 | 145 | |
|---|
| 159 | | -static ssize_t show_temp(struct device *dev, |
|---|
| 160 | | - struct device_attribute *devattr, char *buf) |
|---|
| 146 | +static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, |
|---|
| 147 | + char *buf) |
|---|
| 161 | 148 | { |
|---|
| 162 | 149 | int index = to_sensor_dev_attr(devattr)->index; |
|---|
| 163 | 150 | struct adm1021_data *data = adm1021_update_device(dev); |
|---|
| .. | .. |
|---|
| 165 | 152 | return sprintf(buf, "%d\n", data->temp[index]); |
|---|
| 166 | 153 | } |
|---|
| 167 | 154 | |
|---|
| 168 | | -static ssize_t show_temp_max(struct device *dev, |
|---|
| 155 | +static ssize_t temp_max_show(struct device *dev, |
|---|
| 169 | 156 | struct device_attribute *devattr, char *buf) |
|---|
| 170 | 157 | { |
|---|
| 171 | 158 | int index = to_sensor_dev_attr(devattr)->index; |
|---|
| .. | .. |
|---|
| 174 | 161 | return sprintf(buf, "%d\n", data->temp_max[index]); |
|---|
| 175 | 162 | } |
|---|
| 176 | 163 | |
|---|
| 177 | | -static ssize_t show_temp_min(struct device *dev, |
|---|
| 164 | +static ssize_t temp_min_show(struct device *dev, |
|---|
| 178 | 165 | struct device_attribute *devattr, char *buf) |
|---|
| 179 | 166 | { |
|---|
| 180 | 167 | int index = to_sensor_dev_attr(devattr)->index; |
|---|
| .. | .. |
|---|
| 183 | 170 | return sprintf(buf, "%d\n", data->temp_min[index]); |
|---|
| 184 | 171 | } |
|---|
| 185 | 172 | |
|---|
| 186 | | -static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, |
|---|
| 173 | +static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, |
|---|
| 187 | 174 | char *buf) |
|---|
| 188 | 175 | { |
|---|
| 189 | 176 | int index = to_sensor_dev_attr(attr)->index; |
|---|
| .. | .. |
|---|
| 199 | 186 | return sprintf(buf, "%u\n", data->alarms); |
|---|
| 200 | 187 | } |
|---|
| 201 | 188 | |
|---|
| 202 | | -static ssize_t set_temp_max(struct device *dev, |
|---|
| 203 | | - struct device_attribute *devattr, |
|---|
| 204 | | - const char *buf, size_t count) |
|---|
| 189 | +static ssize_t temp_max_store(struct device *dev, |
|---|
| 190 | + struct device_attribute *devattr, |
|---|
| 191 | + const char *buf, size_t count) |
|---|
| 205 | 192 | { |
|---|
| 206 | 193 | int index = to_sensor_dev_attr(devattr)->index; |
|---|
| 207 | 194 | struct adm1021_data *data = dev_get_drvdata(dev); |
|---|
| .. | .. |
|---|
| 225 | 212 | return count; |
|---|
| 226 | 213 | } |
|---|
| 227 | 214 | |
|---|
| 228 | | -static ssize_t set_temp_min(struct device *dev, |
|---|
| 229 | | - struct device_attribute *devattr, |
|---|
| 230 | | - const char *buf, size_t count) |
|---|
| 215 | +static ssize_t temp_min_store(struct device *dev, |
|---|
| 216 | + struct device_attribute *devattr, |
|---|
| 217 | + const char *buf, size_t count) |
|---|
| 231 | 218 | { |
|---|
| 232 | 219 | int index = to_sensor_dev_attr(devattr)->index; |
|---|
| 233 | 220 | struct adm1021_data *data = dev_get_drvdata(dev); |
|---|
| .. | .. |
|---|
| 287 | 274 | } |
|---|
| 288 | 275 | |
|---|
| 289 | 276 | |
|---|
| 290 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); |
|---|
| 291 | | -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, |
|---|
| 292 | | - set_temp_max, 0); |
|---|
| 293 | | -static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp_min, |
|---|
| 294 | | - set_temp_min, 0); |
|---|
| 295 | | -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); |
|---|
| 296 | | -static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_max, |
|---|
| 297 | | - set_temp_max, 1); |
|---|
| 298 | | -static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_min, |
|---|
| 299 | | - set_temp_min, 1); |
|---|
| 300 | | -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6); |
|---|
| 301 | | -static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 5); |
|---|
| 302 | | -static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4); |
|---|
| 303 | | -static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3); |
|---|
| 304 | | -static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2); |
|---|
| 277 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); |
|---|
| 278 | +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); |
|---|
| 279 | +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0); |
|---|
| 280 | +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); |
|---|
| 281 | +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); |
|---|
| 282 | +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1); |
|---|
| 283 | +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 6); |
|---|
| 284 | +static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, 5); |
|---|
| 285 | +static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, alarm, 4); |
|---|
| 286 | +static SENSOR_DEVICE_ATTR_RO(temp2_min_alarm, alarm, 3); |
|---|
| 287 | +static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, 2); |
|---|
| 305 | 288 | |
|---|
| 306 | 289 | static DEVICE_ATTR_RO(alarms); |
|---|
| 307 | 290 | static DEVICE_ATTR_RW(low_power); |
|---|
| .. | .. |
|---|
| 442 | 425 | i2c_smbus_write_byte_data(client, ADM1021_REG_CONV_RATE_W, 0x04); |
|---|
| 443 | 426 | } |
|---|
| 444 | 427 | |
|---|
| 445 | | -static int adm1021_probe(struct i2c_client *client, |
|---|
| 446 | | - const struct i2c_device_id *id) |
|---|
| 428 | +static const struct i2c_device_id adm1021_id[]; |
|---|
| 429 | + |
|---|
| 430 | +static int adm1021_probe(struct i2c_client *client) |
|---|
| 447 | 431 | { |
|---|
| 448 | 432 | struct device *dev = &client->dev; |
|---|
| 449 | 433 | struct adm1021_data *data; |
|---|
| .. | .. |
|---|
| 454 | 438 | return -ENOMEM; |
|---|
| 455 | 439 | |
|---|
| 456 | 440 | data->client = client; |
|---|
| 457 | | - data->type = id->driver_data; |
|---|
| 441 | + data->type = i2c_match_id(adm1021_id, client)->driver_data; |
|---|
| 458 | 442 | mutex_init(&data->update_lock); |
|---|
| 459 | 443 | |
|---|
| 460 | 444 | /* Initialize the ADM1021 chip */ |
|---|
| .. | .. |
|---|
| 489 | 473 | .driver = { |
|---|
| 490 | 474 | .name = "adm1021", |
|---|
| 491 | 475 | }, |
|---|
| 492 | | - .probe = adm1021_probe, |
|---|
| 476 | + .probe_new = adm1021_probe, |
|---|
| 493 | 477 | .id_table = adm1021_id, |
|---|
| 494 | 478 | .detect = adm1021_detect, |
|---|
| 495 | 479 | .address_list = normal_i2c, |
|---|