.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * max1619.c - Part of lm_sensors, Linux kernel modules for hardware |
---|
3 | 4 | * monitoring |
---|
.. | .. |
---|
9 | 10 | * one external one). Complete datasheet can be |
---|
10 | 11 | * obtained from Maxim's website at: |
---|
11 | 12 | * http://pdfserv.maxim-ic.com/en/ds/MAX1619.pdf |
---|
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> |
---|
.. | .. |
---|
145 | 136 | * Sysfs stuff |
---|
146 | 137 | */ |
---|
147 | 138 | |
---|
148 | | -static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, |
---|
| 139 | +static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, |
---|
149 | 140 | char *buf) |
---|
150 | 141 | { |
---|
151 | 142 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
154 | 145 | return sprintf(buf, "%d\n", temp_from_reg(data->temp[attr->index])); |
---|
155 | 146 | } |
---|
156 | 147 | |
---|
157 | | -static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, |
---|
158 | | - const char *buf, size_t count) |
---|
| 148 | +static ssize_t temp_store(struct device *dev, |
---|
| 149 | + struct device_attribute *devattr, const char *buf, |
---|
| 150 | + size_t count) |
---|
159 | 151 | { |
---|
160 | 152 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
161 | 153 | struct max1619_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
180 | 172 | return sprintf(buf, "%d\n", data->alarms); |
---|
181 | 173 | } |
---|
182 | 174 | |
---|
183 | | -static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, |
---|
| 175 | +static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, |
---|
184 | 176 | char *buf) |
---|
185 | 177 | { |
---|
186 | 178 | int bitnr = to_sensor_dev_attr(attr)->index; |
---|
.. | .. |
---|
188 | 180 | return sprintf(buf, "%d\n", (data->alarms >> bitnr) & 1); |
---|
189 | 181 | } |
---|
190 | 182 | |
---|
191 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, t_input1); |
---|
192 | | -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, t_input2); |
---|
193 | | -static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp, set_temp, |
---|
194 | | - t_low2); |
---|
195 | | -static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp, set_temp, |
---|
196 | | - t_high2); |
---|
197 | | -static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp, set_temp, |
---|
198 | | - t_crit2); |
---|
199 | | -static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp, |
---|
200 | | - set_temp, t_hyst2); |
---|
| 183 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, t_input1); |
---|
| 184 | +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, t_input2); |
---|
| 185 | +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp, t_low2); |
---|
| 186 | +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp, t_high2); |
---|
| 187 | +static SENSOR_DEVICE_ATTR_RW(temp2_crit, temp, t_crit2); |
---|
| 188 | +static SENSOR_DEVICE_ATTR_RW(temp2_crit_hyst, temp, t_hyst2); |
---|
201 | 189 | |
---|
202 | 190 | static DEVICE_ATTR_RO(alarms); |
---|
203 | | -static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 1); |
---|
204 | | -static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2); |
---|
205 | | -static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3); |
---|
206 | | -static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4); |
---|
| 191 | +static SENSOR_DEVICE_ATTR_RO(temp2_crit_alarm, alarm, 1); |
---|
| 192 | +static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, 2); |
---|
| 193 | +static SENSOR_DEVICE_ATTR_RO(temp2_min_alarm, alarm, 3); |
---|
| 194 | +static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, alarm, 4); |
---|
207 | 195 | |
---|
208 | 196 | static struct attribute *max1619_attrs[] = { |
---|
209 | 197 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
---|
.. | .. |
---|
273 | 261 | config & 0xBF); /* run */ |
---|
274 | 262 | } |
---|
275 | 263 | |
---|
276 | | -static int max1619_probe(struct i2c_client *new_client, |
---|
277 | | - const struct i2c_device_id *id) |
---|
| 264 | +static int max1619_probe(struct i2c_client *new_client) |
---|
278 | 265 | { |
---|
279 | 266 | struct max1619_data *data; |
---|
280 | 267 | struct device *hwmon_dev; |
---|
.. | .. |
---|
318 | 305 | .name = "max1619", |
---|
319 | 306 | .of_match_table = of_match_ptr(max1619_of_match), |
---|
320 | 307 | }, |
---|
321 | | - .probe = max1619_probe, |
---|
| 308 | + .probe_new = max1619_probe, |
---|
322 | 309 | .id_table = max1619_id, |
---|
323 | 310 | .detect = max1619_detect, |
---|
324 | 311 | .address_list = normal_i2c, |
---|