| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Driver for |
|---|
| 3 | 4 | * Maxim MAX16065/MAX16066 12-Channel/8-Channel, Flash-Configurable |
|---|
| .. | .. |
|---|
| 8 | 9 | * Monitors with Nonvolatile Fault Registers |
|---|
| 9 | 10 | * |
|---|
| 10 | 11 | * Copyright (C) 2011 Ericsson AB. |
|---|
| 11 | | - * |
|---|
| 12 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 13 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 14 | | - * the Free Software Foundation; version 2 of the License. |
|---|
| 15 | 12 | */ |
|---|
| 16 | 13 | |
|---|
| 17 | 14 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 175 | 172 | return data; |
|---|
| 176 | 173 | } |
|---|
| 177 | 174 | |
|---|
| 178 | | -static ssize_t max16065_show_alarm(struct device *dev, |
|---|
| 175 | +static ssize_t max16065_alarm_show(struct device *dev, |
|---|
| 179 | 176 | struct device_attribute *da, char *buf) |
|---|
| 180 | 177 | { |
|---|
| 181 | 178 | struct sensor_device_attribute_2 *attr2 = to_sensor_dev_attr_2(da); |
|---|
| .. | .. |
|---|
| 193 | 190 | return snprintf(buf, PAGE_SIZE, "%d\n", !!val); |
|---|
| 194 | 191 | } |
|---|
| 195 | 192 | |
|---|
| 196 | | -static ssize_t max16065_show_input(struct device *dev, |
|---|
| 193 | +static ssize_t max16065_input_show(struct device *dev, |
|---|
| 197 | 194 | struct device_attribute *da, char *buf) |
|---|
| 198 | 195 | { |
|---|
| 199 | 196 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
|---|
| .. | .. |
|---|
| 207 | 204 | ADC_TO_MV(adc, data->range[attr->index])); |
|---|
| 208 | 205 | } |
|---|
| 209 | 206 | |
|---|
| 210 | | -static ssize_t max16065_show_current(struct device *dev, |
|---|
| 207 | +static ssize_t max16065_current_show(struct device *dev, |
|---|
| 211 | 208 | struct device_attribute *da, char *buf) |
|---|
| 212 | 209 | { |
|---|
| 213 | 210 | struct max16065_data *data = max16065_update_device(dev); |
|---|
| .. | .. |
|---|
| 219 | 216 | ADC_TO_CURR(data->curr_sense, data->curr_gain)); |
|---|
| 220 | 217 | } |
|---|
| 221 | 218 | |
|---|
| 222 | | -static ssize_t max16065_set_limit(struct device *dev, |
|---|
| 223 | | - struct device_attribute *da, |
|---|
| 224 | | - const char *buf, size_t count) |
|---|
| 219 | +static ssize_t max16065_limit_store(struct device *dev, |
|---|
| 220 | + struct device_attribute *da, |
|---|
| 221 | + const char *buf, size_t count) |
|---|
| 225 | 222 | { |
|---|
| 226 | 223 | struct sensor_device_attribute_2 *attr2 = to_sensor_dev_attr_2(da); |
|---|
| 227 | 224 | struct max16065_data *data = dev_get_drvdata(dev); |
|---|
| .. | .. |
|---|
| 246 | 243 | return count; |
|---|
| 247 | 244 | } |
|---|
| 248 | 245 | |
|---|
| 249 | | -static ssize_t max16065_show_limit(struct device *dev, |
|---|
| 246 | +static ssize_t max16065_limit_show(struct device *dev, |
|---|
| 250 | 247 | struct device_attribute *da, char *buf) |
|---|
| 251 | 248 | { |
|---|
| 252 | 249 | struct sensor_device_attribute_2 *attr2 = to_sensor_dev_attr_2(da); |
|---|
| .. | .. |
|---|
| 259 | 256 | /* Construct a sensor_device_attribute structure for each register */ |
|---|
| 260 | 257 | |
|---|
| 261 | 258 | /* Input voltages */ |
|---|
| 262 | | -static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, max16065_show_input, NULL, 0); |
|---|
| 263 | | -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, max16065_show_input, NULL, 1); |
|---|
| 264 | | -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, max16065_show_input, NULL, 2); |
|---|
| 265 | | -static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, max16065_show_input, NULL, 3); |
|---|
| 266 | | -static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, max16065_show_input, NULL, 4); |
|---|
| 267 | | -static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, max16065_show_input, NULL, 5); |
|---|
| 268 | | -static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, max16065_show_input, NULL, 6); |
|---|
| 269 | | -static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, max16065_show_input, NULL, 7); |
|---|
| 270 | | -static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, max16065_show_input, NULL, 8); |
|---|
| 271 | | -static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, max16065_show_input, NULL, 9); |
|---|
| 272 | | -static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, max16065_show_input, NULL, 10); |
|---|
| 273 | | -static SENSOR_DEVICE_ATTR(in11_input, S_IRUGO, max16065_show_input, NULL, 11); |
|---|
| 274 | | -static SENSOR_DEVICE_ATTR(in12_input, S_IRUGO, max16065_show_input, NULL, 12); |
|---|
| 259 | +static SENSOR_DEVICE_ATTR_RO(in0_input, max16065_input, 0); |
|---|
| 260 | +static SENSOR_DEVICE_ATTR_RO(in1_input, max16065_input, 1); |
|---|
| 261 | +static SENSOR_DEVICE_ATTR_RO(in2_input, max16065_input, 2); |
|---|
| 262 | +static SENSOR_DEVICE_ATTR_RO(in3_input, max16065_input, 3); |
|---|
| 263 | +static SENSOR_DEVICE_ATTR_RO(in4_input, max16065_input, 4); |
|---|
| 264 | +static SENSOR_DEVICE_ATTR_RO(in5_input, max16065_input, 5); |
|---|
| 265 | +static SENSOR_DEVICE_ATTR_RO(in6_input, max16065_input, 6); |
|---|
| 266 | +static SENSOR_DEVICE_ATTR_RO(in7_input, max16065_input, 7); |
|---|
| 267 | +static SENSOR_DEVICE_ATTR_RO(in8_input, max16065_input, 8); |
|---|
| 268 | +static SENSOR_DEVICE_ATTR_RO(in9_input, max16065_input, 9); |
|---|
| 269 | +static SENSOR_DEVICE_ATTR_RO(in10_input, max16065_input, 10); |
|---|
| 270 | +static SENSOR_DEVICE_ATTR_RO(in11_input, max16065_input, 11); |
|---|
| 271 | +static SENSOR_DEVICE_ATTR_RO(in12_input, max16065_input, 12); |
|---|
| 275 | 272 | |
|---|
| 276 | 273 | /* Input voltages lcrit */ |
|---|
| 277 | | -static SENSOR_DEVICE_ATTR_2(in0_lcrit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 278 | | - max16065_set_limit, 2, 0); |
|---|
| 279 | | -static SENSOR_DEVICE_ATTR_2(in1_lcrit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 280 | | - max16065_set_limit, 2, 1); |
|---|
| 281 | | -static SENSOR_DEVICE_ATTR_2(in2_lcrit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 282 | | - max16065_set_limit, 2, 2); |
|---|
| 283 | | -static SENSOR_DEVICE_ATTR_2(in3_lcrit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 284 | | - max16065_set_limit, 2, 3); |
|---|
| 285 | | -static SENSOR_DEVICE_ATTR_2(in4_lcrit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 286 | | - max16065_set_limit, 2, 4); |
|---|
| 287 | | -static SENSOR_DEVICE_ATTR_2(in5_lcrit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 288 | | - max16065_set_limit, 2, 5); |
|---|
| 289 | | -static SENSOR_DEVICE_ATTR_2(in6_lcrit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 290 | | - max16065_set_limit, 2, 6); |
|---|
| 291 | | -static SENSOR_DEVICE_ATTR_2(in7_lcrit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 292 | | - max16065_set_limit, 2, 7); |
|---|
| 293 | | -static SENSOR_DEVICE_ATTR_2(in8_lcrit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 294 | | - max16065_set_limit, 2, 8); |
|---|
| 295 | | -static SENSOR_DEVICE_ATTR_2(in9_lcrit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 296 | | - max16065_set_limit, 2, 9); |
|---|
| 297 | | -static SENSOR_DEVICE_ATTR_2(in10_lcrit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 298 | | - max16065_set_limit, 2, 10); |
|---|
| 299 | | -static SENSOR_DEVICE_ATTR_2(in11_lcrit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 300 | | - max16065_set_limit, 2, 11); |
|---|
| 274 | +static SENSOR_DEVICE_ATTR_2_RW(in0_lcrit, max16065_limit, 2, 0); |
|---|
| 275 | +static SENSOR_DEVICE_ATTR_2_RW(in1_lcrit, max16065_limit, 2, 1); |
|---|
| 276 | +static SENSOR_DEVICE_ATTR_2_RW(in2_lcrit, max16065_limit, 2, 2); |
|---|
| 277 | +static SENSOR_DEVICE_ATTR_2_RW(in3_lcrit, max16065_limit, 2, 3); |
|---|
| 278 | +static SENSOR_DEVICE_ATTR_2_RW(in4_lcrit, max16065_limit, 2, 4); |
|---|
| 279 | +static SENSOR_DEVICE_ATTR_2_RW(in5_lcrit, max16065_limit, 2, 5); |
|---|
| 280 | +static SENSOR_DEVICE_ATTR_2_RW(in6_lcrit, max16065_limit, 2, 6); |
|---|
| 281 | +static SENSOR_DEVICE_ATTR_2_RW(in7_lcrit, max16065_limit, 2, 7); |
|---|
| 282 | +static SENSOR_DEVICE_ATTR_2_RW(in8_lcrit, max16065_limit, 2, 8); |
|---|
| 283 | +static SENSOR_DEVICE_ATTR_2_RW(in9_lcrit, max16065_limit, 2, 9); |
|---|
| 284 | +static SENSOR_DEVICE_ATTR_2_RW(in10_lcrit, max16065_limit, 2, 10); |
|---|
| 285 | +static SENSOR_DEVICE_ATTR_2_RW(in11_lcrit, max16065_limit, 2, 11); |
|---|
| 301 | 286 | |
|---|
| 302 | 287 | /* Input voltages crit */ |
|---|
| 303 | | -static SENSOR_DEVICE_ATTR_2(in0_crit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 304 | | - max16065_set_limit, 1, 0); |
|---|
| 305 | | -static SENSOR_DEVICE_ATTR_2(in1_crit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 306 | | - max16065_set_limit, 1, 1); |
|---|
| 307 | | -static SENSOR_DEVICE_ATTR_2(in2_crit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 308 | | - max16065_set_limit, 1, 2); |
|---|
| 309 | | -static SENSOR_DEVICE_ATTR_2(in3_crit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 310 | | - max16065_set_limit, 1, 3); |
|---|
| 311 | | -static SENSOR_DEVICE_ATTR_2(in4_crit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 312 | | - max16065_set_limit, 1, 4); |
|---|
| 313 | | -static SENSOR_DEVICE_ATTR_2(in5_crit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 314 | | - max16065_set_limit, 1, 5); |
|---|
| 315 | | -static SENSOR_DEVICE_ATTR_2(in6_crit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 316 | | - max16065_set_limit, 1, 6); |
|---|
| 317 | | -static SENSOR_DEVICE_ATTR_2(in7_crit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 318 | | - max16065_set_limit, 1, 7); |
|---|
| 319 | | -static SENSOR_DEVICE_ATTR_2(in8_crit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 320 | | - max16065_set_limit, 1, 8); |
|---|
| 321 | | -static SENSOR_DEVICE_ATTR_2(in9_crit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 322 | | - max16065_set_limit, 1, 9); |
|---|
| 323 | | -static SENSOR_DEVICE_ATTR_2(in10_crit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 324 | | - max16065_set_limit, 1, 10); |
|---|
| 325 | | -static SENSOR_DEVICE_ATTR_2(in11_crit, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 326 | | - max16065_set_limit, 1, 11); |
|---|
| 288 | +static SENSOR_DEVICE_ATTR_2_RW(in0_crit, max16065_limit, 1, 0); |
|---|
| 289 | +static SENSOR_DEVICE_ATTR_2_RW(in1_crit, max16065_limit, 1, 1); |
|---|
| 290 | +static SENSOR_DEVICE_ATTR_2_RW(in2_crit, max16065_limit, 1, 2); |
|---|
| 291 | +static SENSOR_DEVICE_ATTR_2_RW(in3_crit, max16065_limit, 1, 3); |
|---|
| 292 | +static SENSOR_DEVICE_ATTR_2_RW(in4_crit, max16065_limit, 1, 4); |
|---|
| 293 | +static SENSOR_DEVICE_ATTR_2_RW(in5_crit, max16065_limit, 1, 5); |
|---|
| 294 | +static SENSOR_DEVICE_ATTR_2_RW(in6_crit, max16065_limit, 1, 6); |
|---|
| 295 | +static SENSOR_DEVICE_ATTR_2_RW(in7_crit, max16065_limit, 1, 7); |
|---|
| 296 | +static SENSOR_DEVICE_ATTR_2_RW(in8_crit, max16065_limit, 1, 8); |
|---|
| 297 | +static SENSOR_DEVICE_ATTR_2_RW(in9_crit, max16065_limit, 1, 9); |
|---|
| 298 | +static SENSOR_DEVICE_ATTR_2_RW(in10_crit, max16065_limit, 1, 10); |
|---|
| 299 | +static SENSOR_DEVICE_ATTR_2_RW(in11_crit, max16065_limit, 1, 11); |
|---|
| 327 | 300 | |
|---|
| 328 | 301 | /* Input voltages min */ |
|---|
| 329 | | -static SENSOR_DEVICE_ATTR_2(in0_min, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 330 | | - max16065_set_limit, 0, 0); |
|---|
| 331 | | -static SENSOR_DEVICE_ATTR_2(in1_min, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 332 | | - max16065_set_limit, 0, 1); |
|---|
| 333 | | -static SENSOR_DEVICE_ATTR_2(in2_min, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 334 | | - max16065_set_limit, 0, 2); |
|---|
| 335 | | -static SENSOR_DEVICE_ATTR_2(in3_min, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 336 | | - max16065_set_limit, 0, 3); |
|---|
| 337 | | -static SENSOR_DEVICE_ATTR_2(in4_min, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 338 | | - max16065_set_limit, 0, 4); |
|---|
| 339 | | -static SENSOR_DEVICE_ATTR_2(in5_min, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 340 | | - max16065_set_limit, 0, 5); |
|---|
| 341 | | -static SENSOR_DEVICE_ATTR_2(in6_min, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 342 | | - max16065_set_limit, 0, 6); |
|---|
| 343 | | -static SENSOR_DEVICE_ATTR_2(in7_min, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 344 | | - max16065_set_limit, 0, 7); |
|---|
| 345 | | -static SENSOR_DEVICE_ATTR_2(in8_min, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 346 | | - max16065_set_limit, 0, 8); |
|---|
| 347 | | -static SENSOR_DEVICE_ATTR_2(in9_min, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 348 | | - max16065_set_limit, 0, 9); |
|---|
| 349 | | -static SENSOR_DEVICE_ATTR_2(in10_min, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 350 | | - max16065_set_limit, 0, 10); |
|---|
| 351 | | -static SENSOR_DEVICE_ATTR_2(in11_min, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 352 | | - max16065_set_limit, 0, 11); |
|---|
| 302 | +static SENSOR_DEVICE_ATTR_2_RW(in0_min, max16065_limit, 0, 0); |
|---|
| 303 | +static SENSOR_DEVICE_ATTR_2_RW(in1_min, max16065_limit, 0, 1); |
|---|
| 304 | +static SENSOR_DEVICE_ATTR_2_RW(in2_min, max16065_limit, 0, 2); |
|---|
| 305 | +static SENSOR_DEVICE_ATTR_2_RW(in3_min, max16065_limit, 0, 3); |
|---|
| 306 | +static SENSOR_DEVICE_ATTR_2_RW(in4_min, max16065_limit, 0, 4); |
|---|
| 307 | +static SENSOR_DEVICE_ATTR_2_RW(in5_min, max16065_limit, 0, 5); |
|---|
| 308 | +static SENSOR_DEVICE_ATTR_2_RW(in6_min, max16065_limit, 0, 6); |
|---|
| 309 | +static SENSOR_DEVICE_ATTR_2_RW(in7_min, max16065_limit, 0, 7); |
|---|
| 310 | +static SENSOR_DEVICE_ATTR_2_RW(in8_min, max16065_limit, 0, 8); |
|---|
| 311 | +static SENSOR_DEVICE_ATTR_2_RW(in9_min, max16065_limit, 0, 9); |
|---|
| 312 | +static SENSOR_DEVICE_ATTR_2_RW(in10_min, max16065_limit, 0, 10); |
|---|
| 313 | +static SENSOR_DEVICE_ATTR_2_RW(in11_min, max16065_limit, 0, 11); |
|---|
| 353 | 314 | |
|---|
| 354 | 315 | /* Input voltages max */ |
|---|
| 355 | | -static SENSOR_DEVICE_ATTR_2(in0_max, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 356 | | - max16065_set_limit, 0, 0); |
|---|
| 357 | | -static SENSOR_DEVICE_ATTR_2(in1_max, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 358 | | - max16065_set_limit, 0, 1); |
|---|
| 359 | | -static SENSOR_DEVICE_ATTR_2(in2_max, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 360 | | - max16065_set_limit, 0, 2); |
|---|
| 361 | | -static SENSOR_DEVICE_ATTR_2(in3_max, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 362 | | - max16065_set_limit, 0, 3); |
|---|
| 363 | | -static SENSOR_DEVICE_ATTR_2(in4_max, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 364 | | - max16065_set_limit, 0, 4); |
|---|
| 365 | | -static SENSOR_DEVICE_ATTR_2(in5_max, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 366 | | - max16065_set_limit, 0, 5); |
|---|
| 367 | | -static SENSOR_DEVICE_ATTR_2(in6_max, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 368 | | - max16065_set_limit, 0, 6); |
|---|
| 369 | | -static SENSOR_DEVICE_ATTR_2(in7_max, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 370 | | - max16065_set_limit, 0, 7); |
|---|
| 371 | | -static SENSOR_DEVICE_ATTR_2(in8_max, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 372 | | - max16065_set_limit, 0, 8); |
|---|
| 373 | | -static SENSOR_DEVICE_ATTR_2(in9_max, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 374 | | - max16065_set_limit, 0, 9); |
|---|
| 375 | | -static SENSOR_DEVICE_ATTR_2(in10_max, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 376 | | - max16065_set_limit, 0, 10); |
|---|
| 377 | | -static SENSOR_DEVICE_ATTR_2(in11_max, S_IWUSR | S_IRUGO, max16065_show_limit, |
|---|
| 378 | | - max16065_set_limit, 0, 11); |
|---|
| 316 | +static SENSOR_DEVICE_ATTR_2_RW(in0_max, max16065_limit, 0, 0); |
|---|
| 317 | +static SENSOR_DEVICE_ATTR_2_RW(in1_max, max16065_limit, 0, 1); |
|---|
| 318 | +static SENSOR_DEVICE_ATTR_2_RW(in2_max, max16065_limit, 0, 2); |
|---|
| 319 | +static SENSOR_DEVICE_ATTR_2_RW(in3_max, max16065_limit, 0, 3); |
|---|
| 320 | +static SENSOR_DEVICE_ATTR_2_RW(in4_max, max16065_limit, 0, 4); |
|---|
| 321 | +static SENSOR_DEVICE_ATTR_2_RW(in5_max, max16065_limit, 0, 5); |
|---|
| 322 | +static SENSOR_DEVICE_ATTR_2_RW(in6_max, max16065_limit, 0, 6); |
|---|
| 323 | +static SENSOR_DEVICE_ATTR_2_RW(in7_max, max16065_limit, 0, 7); |
|---|
| 324 | +static SENSOR_DEVICE_ATTR_2_RW(in8_max, max16065_limit, 0, 8); |
|---|
| 325 | +static SENSOR_DEVICE_ATTR_2_RW(in9_max, max16065_limit, 0, 9); |
|---|
| 326 | +static SENSOR_DEVICE_ATTR_2_RW(in10_max, max16065_limit, 0, 10); |
|---|
| 327 | +static SENSOR_DEVICE_ATTR_2_RW(in11_max, max16065_limit, 0, 11); |
|---|
| 379 | 328 | |
|---|
| 380 | 329 | /* alarms */ |
|---|
| 381 | | -static SENSOR_DEVICE_ATTR_2(in0_alarm, S_IRUGO, max16065_show_alarm, NULL, |
|---|
| 382 | | - 0, 0); |
|---|
| 383 | | -static SENSOR_DEVICE_ATTR_2(in1_alarm, S_IRUGO, max16065_show_alarm, NULL, |
|---|
| 384 | | - 0, 1); |
|---|
| 385 | | -static SENSOR_DEVICE_ATTR_2(in2_alarm, S_IRUGO, max16065_show_alarm, NULL, |
|---|
| 386 | | - 0, 2); |
|---|
| 387 | | -static SENSOR_DEVICE_ATTR_2(in3_alarm, S_IRUGO, max16065_show_alarm, NULL, |
|---|
| 388 | | - 0, 3); |
|---|
| 389 | | -static SENSOR_DEVICE_ATTR_2(in4_alarm, S_IRUGO, max16065_show_alarm, NULL, |
|---|
| 390 | | - 0, 4); |
|---|
| 391 | | -static SENSOR_DEVICE_ATTR_2(in5_alarm, S_IRUGO, max16065_show_alarm, NULL, |
|---|
| 392 | | - 0, 5); |
|---|
| 393 | | -static SENSOR_DEVICE_ATTR_2(in6_alarm, S_IRUGO, max16065_show_alarm, NULL, |
|---|
| 394 | | - 0, 6); |
|---|
| 395 | | -static SENSOR_DEVICE_ATTR_2(in7_alarm, S_IRUGO, max16065_show_alarm, NULL, |
|---|
| 396 | | - 0, 7); |
|---|
| 397 | | -static SENSOR_DEVICE_ATTR_2(in8_alarm, S_IRUGO, max16065_show_alarm, NULL, |
|---|
| 398 | | - 1, 0); |
|---|
| 399 | | -static SENSOR_DEVICE_ATTR_2(in9_alarm, S_IRUGO, max16065_show_alarm, NULL, |
|---|
| 400 | | - 1, 1); |
|---|
| 401 | | -static SENSOR_DEVICE_ATTR_2(in10_alarm, S_IRUGO, max16065_show_alarm, NULL, |
|---|
| 402 | | - 1, 2); |
|---|
| 403 | | -static SENSOR_DEVICE_ATTR_2(in11_alarm, S_IRUGO, max16065_show_alarm, NULL, |
|---|
| 404 | | - 1, 3); |
|---|
| 330 | +static SENSOR_DEVICE_ATTR_2_RO(in0_alarm, max16065_alarm, 0, 0); |
|---|
| 331 | +static SENSOR_DEVICE_ATTR_2_RO(in1_alarm, max16065_alarm, 0, 1); |
|---|
| 332 | +static SENSOR_DEVICE_ATTR_2_RO(in2_alarm, max16065_alarm, 0, 2); |
|---|
| 333 | +static SENSOR_DEVICE_ATTR_2_RO(in3_alarm, max16065_alarm, 0, 3); |
|---|
| 334 | +static SENSOR_DEVICE_ATTR_2_RO(in4_alarm, max16065_alarm, 0, 4); |
|---|
| 335 | +static SENSOR_DEVICE_ATTR_2_RO(in5_alarm, max16065_alarm, 0, 5); |
|---|
| 336 | +static SENSOR_DEVICE_ATTR_2_RO(in6_alarm, max16065_alarm, 0, 6); |
|---|
| 337 | +static SENSOR_DEVICE_ATTR_2_RO(in7_alarm, max16065_alarm, 0, 7); |
|---|
| 338 | +static SENSOR_DEVICE_ATTR_2_RO(in8_alarm, max16065_alarm, 1, 0); |
|---|
| 339 | +static SENSOR_DEVICE_ATTR_2_RO(in9_alarm, max16065_alarm, 1, 1); |
|---|
| 340 | +static SENSOR_DEVICE_ATTR_2_RO(in10_alarm, max16065_alarm, 1, 2); |
|---|
| 341 | +static SENSOR_DEVICE_ATTR_2_RO(in11_alarm, max16065_alarm, 1, 3); |
|---|
| 405 | 342 | |
|---|
| 406 | 343 | /* Current and alarm */ |
|---|
| 407 | | -static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, max16065_show_current, NULL, 0); |
|---|
| 408 | | -static SENSOR_DEVICE_ATTR_2(curr1_alarm, S_IRUGO, max16065_show_alarm, NULL, |
|---|
| 409 | | - 1, 4); |
|---|
| 344 | +static SENSOR_DEVICE_ATTR_RO(curr1_input, max16065_current, 0); |
|---|
| 345 | +static SENSOR_DEVICE_ATTR_2_RO(curr1_alarm, max16065_alarm, 1, 4); |
|---|
| 410 | 346 | |
|---|
| 411 | 347 | /* |
|---|
| 412 | 348 | * Finally, construct an array of pointers to members of the above objects, |
|---|
| .. | .. |
|---|
| 557 | 493 | .is_visible = max16065_secondary_is_visible, |
|---|
| 558 | 494 | }; |
|---|
| 559 | 495 | |
|---|
| 560 | | -static int max16065_probe(struct i2c_client *client, |
|---|
| 561 | | - const struct i2c_device_id *id) |
|---|
| 496 | +static const struct i2c_device_id max16065_id[]; |
|---|
| 497 | + |
|---|
| 498 | +static int max16065_probe(struct i2c_client *client) |
|---|
| 562 | 499 | { |
|---|
| 563 | 500 | struct i2c_adapter *adapter = client->adapter; |
|---|
| 564 | 501 | struct max16065_data *data; |
|---|
| .. | .. |
|---|
| 568 | 505 | bool have_secondary; /* true if chip has secondary limits */ |
|---|
| 569 | 506 | bool secondary_is_max = false; /* secondary limits reflect max */ |
|---|
| 570 | 507 | int groups = 0; |
|---|
| 508 | + const struct i2c_device_id *id = i2c_match_id(max16065_id, client); |
|---|
| 571 | 509 | |
|---|
| 572 | 510 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
|---|
| 573 | 511 | | I2C_FUNC_SMBUS_READ_WORD_DATA)) |
|---|
| .. | .. |
|---|
| 662 | 600 | .driver = { |
|---|
| 663 | 601 | .name = "max16065", |
|---|
| 664 | 602 | }, |
|---|
| 665 | | - .probe = max16065_probe, |
|---|
| 603 | + .probe_new = max16065_probe, |
|---|
| 666 | 604 | .id_table = max16065_id, |
|---|
| 667 | 605 | }; |
|---|
| 668 | 606 | |
|---|