| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Driver for Linear Technology LTC4260 I2C Positive Voltage Hot Swap Controller |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) 2014 Guenter Roeck |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | | - * (at your option) any later version. |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - * GNU General Public License for more details. |
|---|
| 15 | 6 | */ |
|---|
| 16 | 7 | |
|---|
| 17 | 8 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 79 | 70 | return val; |
|---|
| 80 | 71 | } |
|---|
| 81 | 72 | |
|---|
| 82 | | -static ssize_t ltc4260_show_value(struct device *dev, |
|---|
| 73 | +static ssize_t ltc4260_value_show(struct device *dev, |
|---|
| 83 | 74 | struct device_attribute *da, char *buf) |
|---|
| 84 | 75 | { |
|---|
| 85 | 76 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
|---|
| .. | .. |
|---|
| 91 | 82 | return snprintf(buf, PAGE_SIZE, "%d\n", value); |
|---|
| 92 | 83 | } |
|---|
| 93 | 84 | |
|---|
| 94 | | -static ssize_t ltc4260_show_bool(struct device *dev, |
|---|
| 85 | +static ssize_t ltc4260_bool_show(struct device *dev, |
|---|
| 95 | 86 | struct device_attribute *da, char *buf) |
|---|
| 96 | 87 | { |
|---|
| 97 | 88 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
|---|
| .. | .. |
|---|
| 111 | 102 | } |
|---|
| 112 | 103 | |
|---|
| 113 | 104 | /* Voltages */ |
|---|
| 114 | | -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ltc4260_show_value, NULL, |
|---|
| 115 | | - LTC4260_SOURCE); |
|---|
| 116 | | -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ltc4260_show_value, NULL, |
|---|
| 117 | | - LTC4260_ADIN); |
|---|
| 105 | +static SENSOR_DEVICE_ATTR_RO(in1_input, ltc4260_value, LTC4260_SOURCE); |
|---|
| 106 | +static SENSOR_DEVICE_ATTR_RO(in2_input, ltc4260_value, LTC4260_ADIN); |
|---|
| 118 | 107 | |
|---|
| 119 | 108 | /* |
|---|
| 120 | 109 | * Voltage alarms |
|---|
| 121 | 110 | * UV/OV faults are associated with the input voltage, and the POWER BAD and |
|---|
| 122 | 111 | * FET SHORT faults are associated with the output voltage. |
|---|
| 123 | 112 | */ |
|---|
| 124 | | -static SENSOR_DEVICE_ATTR(in1_min_alarm, S_IRUGO, ltc4260_show_bool, NULL, |
|---|
| 125 | | - FAULT_UV); |
|---|
| 126 | | -static SENSOR_DEVICE_ATTR(in1_max_alarm, S_IRUGO, ltc4260_show_bool, NULL, |
|---|
| 127 | | - FAULT_OV); |
|---|
| 128 | | -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, ltc4260_show_bool, NULL, |
|---|
| 129 | | - FAULT_POWER_BAD | FAULT_FET_SHORT); |
|---|
| 113 | +static SENSOR_DEVICE_ATTR_RO(in1_min_alarm, ltc4260_bool, FAULT_UV); |
|---|
| 114 | +static SENSOR_DEVICE_ATTR_RO(in1_max_alarm, ltc4260_bool, FAULT_OV); |
|---|
| 115 | +static SENSOR_DEVICE_ATTR_RO(in2_alarm, ltc4260_bool, |
|---|
| 116 | + FAULT_POWER_BAD | FAULT_FET_SHORT); |
|---|
| 130 | 117 | |
|---|
| 131 | 118 | /* Current (via sense resistor) */ |
|---|
| 132 | | -static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, ltc4260_show_value, NULL, |
|---|
| 133 | | - LTC4260_SENSE); |
|---|
| 119 | +static SENSOR_DEVICE_ATTR_RO(curr1_input, ltc4260_value, LTC4260_SENSE); |
|---|
| 134 | 120 | |
|---|
| 135 | 121 | /* Overcurrent alarm */ |
|---|
| 136 | | -static SENSOR_DEVICE_ATTR(curr1_max_alarm, S_IRUGO, ltc4260_show_bool, NULL, |
|---|
| 137 | | - FAULT_OC); |
|---|
| 122 | +static SENSOR_DEVICE_ATTR_RO(curr1_max_alarm, ltc4260_bool, FAULT_OC); |
|---|
| 138 | 123 | |
|---|
| 139 | 124 | static struct attribute *ltc4260_attrs[] = { |
|---|
| 140 | 125 | &sensor_dev_attr_in1_input.dev_attr.attr, |
|---|
| .. | .. |
|---|
| 156 | 141 | .max_register = LTC4260_ADIN, |
|---|
| 157 | 142 | }; |
|---|
| 158 | 143 | |
|---|
| 159 | | -static int ltc4260_probe(struct i2c_client *client, |
|---|
| 160 | | - const struct i2c_device_id *id) |
|---|
| 144 | +static int ltc4260_probe(struct i2c_client *client) |
|---|
| 161 | 145 | { |
|---|
| 162 | 146 | struct device *dev = &client->dev; |
|---|
| 163 | 147 | struct device *hwmon_dev; |
|---|
| .. | .. |
|---|
| 189 | 173 | .driver = { |
|---|
| 190 | 174 | .name = "ltc4260", |
|---|
| 191 | 175 | }, |
|---|
| 192 | | - .probe = ltc4260_probe, |
|---|
| 176 | + .probe_new = ltc4260_probe, |
|---|
| 193 | 177 | .id_table = ltc4260_id, |
|---|
| 194 | 178 | }; |
|---|
| 195 | 179 | |
|---|