.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * An hwmon driver for the Analog Devices AD7414 |
---|
3 | 4 | * |
---|
.. | .. |
---|
12 | 13 | * |
---|
13 | 14 | * Based on ad7418.c |
---|
14 | 15 | * Copyright 2006 Tower Technologies, Alessandro Zummo <a.zummo at towertech.it> |
---|
15 | | - * |
---|
16 | | - * This program is free software; you can redistribute it and/or modify |
---|
17 | | - * it under the terms of the GNU General Public License as published by |
---|
18 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
19 | | - * (at your option) any later version. |
---|
20 | 16 | */ |
---|
21 | 17 | |
---|
22 | 18 | #include <linux/module.h> |
---|
.. | .. |
---|
107 | 103 | return data; |
---|
108 | 104 | } |
---|
109 | 105 | |
---|
110 | | -static ssize_t show_temp_input(struct device *dev, |
---|
| 106 | +static ssize_t temp_input_show(struct device *dev, |
---|
111 | 107 | struct device_attribute *attr, char *buf) |
---|
112 | 108 | { |
---|
113 | 109 | struct ad7414_data *data = ad7414_update_device(dev); |
---|
114 | 110 | return sprintf(buf, "%d\n", ad7414_temp_from_reg(data->temp_input)); |
---|
115 | 111 | } |
---|
116 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL, 0); |
---|
| 112 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp_input, 0); |
---|
117 | 113 | |
---|
118 | | -static ssize_t show_max_min(struct device *dev, struct device_attribute *attr, |
---|
119 | | - char *buf) |
---|
| 114 | +static ssize_t max_min_show(struct device *dev, struct device_attribute *attr, |
---|
| 115 | + char *buf) |
---|
120 | 116 | { |
---|
121 | 117 | int index = to_sensor_dev_attr(attr)->index; |
---|
122 | 118 | struct ad7414_data *data = ad7414_update_device(dev); |
---|
123 | 119 | return sprintf(buf, "%d\n", data->temps[index] * 1000); |
---|
124 | 120 | } |
---|
125 | 121 | |
---|
126 | | -static ssize_t set_max_min(struct device *dev, |
---|
127 | | - struct device_attribute *attr, |
---|
128 | | - const char *buf, size_t count) |
---|
| 122 | +static ssize_t max_min_store(struct device *dev, |
---|
| 123 | + struct device_attribute *attr, const char *buf, |
---|
| 124 | + size_t count) |
---|
129 | 125 | { |
---|
130 | 126 | struct ad7414_data *data = dev_get_drvdata(dev); |
---|
131 | 127 | struct i2c_client *client = data->client; |
---|
.. | .. |
---|
147 | 143 | return count; |
---|
148 | 144 | } |
---|
149 | 145 | |
---|
150 | | -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, |
---|
151 | | - show_max_min, set_max_min, 0); |
---|
152 | | -static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, |
---|
153 | | - show_max_min, set_max_min, 1); |
---|
| 146 | +static SENSOR_DEVICE_ATTR_RW(temp1_max, max_min, 0); |
---|
| 147 | +static SENSOR_DEVICE_ATTR_RW(temp1_min, max_min, 1); |
---|
154 | 148 | |
---|
155 | | -static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, |
---|
| 149 | +static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, |
---|
156 | 150 | char *buf) |
---|
157 | 151 | { |
---|
158 | 152 | int bitnr = to_sensor_dev_attr(attr)->index; |
---|
.. | .. |
---|
161 | 155 | return sprintf(buf, "%d\n", value); |
---|
162 | 156 | } |
---|
163 | 157 | |
---|
164 | | -static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 3); |
---|
165 | | -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 4); |
---|
| 158 | +static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, 3); |
---|
| 159 | +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 4); |
---|
166 | 160 | |
---|
167 | 161 | static struct attribute *ad7414_attrs[] = { |
---|
168 | 162 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
---|
.. | .. |
---|
175 | 169 | |
---|
176 | 170 | ATTRIBUTE_GROUPS(ad7414); |
---|
177 | 171 | |
---|
178 | | -static int ad7414_probe(struct i2c_client *client, |
---|
179 | | - const struct i2c_device_id *dev_id) |
---|
| 172 | +static int ad7414_probe(struct i2c_client *client) |
---|
180 | 173 | { |
---|
181 | 174 | struct device *dev = &client->dev; |
---|
182 | 175 | struct ad7414_data *data; |
---|
.. | .. |
---|
217 | 210 | }; |
---|
218 | 211 | MODULE_DEVICE_TABLE(i2c, ad7414_id); |
---|
219 | 212 | |
---|
220 | | -static const struct of_device_id ad7414_of_match[] = { |
---|
| 213 | +static const struct of_device_id __maybe_unused ad7414_of_match[] = { |
---|
221 | 214 | { .compatible = "ad,ad7414" }, |
---|
222 | 215 | { }, |
---|
223 | 216 | }; |
---|
.. | .. |
---|
228 | 221 | .name = "ad7414", |
---|
229 | 222 | .of_match_table = of_match_ptr(ad7414_of_match), |
---|
230 | 223 | }, |
---|
231 | | - .probe = ad7414_probe, |
---|
| 224 | + .probe_new = ad7414_probe, |
---|
232 | 225 | .id_table = ad7414_id, |
---|
233 | 226 | }; |
---|
234 | 227 | |
---|