| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Driver for Linear Technology LTC4261 I2C Negative Voltage Hot Swap Controller |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 9 | 10 | * Copyright (C) 2008 Ira W. Snyder <iws@ovro.caltech.edu> |
|---|
| 10 | 11 | * |
|---|
| 11 | 12 | * Datasheet: http://cds.linear.com/docs/Datasheet/42612fb.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 | | - * |
|---|
| 23 | | - * You should have received a copy of the GNU General Public License |
|---|
| 24 | | - * along with this program; if not, write to the Free Software |
|---|
| 25 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 26 | 13 | */ |
|---|
| 27 | 14 | |
|---|
| 28 | 15 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 132 | 119 | return val; |
|---|
| 133 | 120 | } |
|---|
| 134 | 121 | |
|---|
| 135 | | -static ssize_t ltc4261_show_value(struct device *dev, |
|---|
| 122 | +static ssize_t ltc4261_value_show(struct device *dev, |
|---|
| 136 | 123 | struct device_attribute *da, char *buf) |
|---|
| 137 | 124 | { |
|---|
| 138 | 125 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
|---|
| .. | .. |
|---|
| 146 | 133 | return snprintf(buf, PAGE_SIZE, "%d\n", value); |
|---|
| 147 | 134 | } |
|---|
| 148 | 135 | |
|---|
| 149 | | -static ssize_t ltc4261_show_bool(struct device *dev, |
|---|
| 136 | +static ssize_t ltc4261_bool_show(struct device *dev, |
|---|
| 150 | 137 | struct device_attribute *da, char *buf) |
|---|
| 151 | 138 | { |
|---|
| 152 | 139 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
|---|
| .. | .. |
|---|
| 166 | 153 | /* |
|---|
| 167 | 154 | * Input voltages. |
|---|
| 168 | 155 | */ |
|---|
| 169 | | -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ltc4261_show_value, NULL, |
|---|
| 170 | | - LTC4261_ADIN_H); |
|---|
| 171 | | -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ltc4261_show_value, NULL, |
|---|
| 172 | | - LTC4261_ADIN2_H); |
|---|
| 156 | +static SENSOR_DEVICE_ATTR_RO(in1_input, ltc4261_value, LTC4261_ADIN_H); |
|---|
| 157 | +static SENSOR_DEVICE_ATTR_RO(in2_input, ltc4261_value, LTC4261_ADIN2_H); |
|---|
| 173 | 158 | |
|---|
| 174 | 159 | /* |
|---|
| 175 | 160 | * Voltage alarms. The chip has only one set of voltage alarm status bits, |
|---|
| .. | .. |
|---|
| 179 | 164 | * To ensure that the alarm condition is reported to the user, report it |
|---|
| 180 | 165 | * with both voltage sensors. |
|---|
| 181 | 166 | */ |
|---|
| 182 | | -static SENSOR_DEVICE_ATTR(in1_min_alarm, S_IRUGO, ltc4261_show_bool, NULL, |
|---|
| 183 | | - FAULT_UV); |
|---|
| 184 | | -static SENSOR_DEVICE_ATTR(in1_max_alarm, S_IRUGO, ltc4261_show_bool, NULL, |
|---|
| 185 | | - FAULT_OV); |
|---|
| 186 | | -static SENSOR_DEVICE_ATTR(in2_min_alarm, S_IRUGO, ltc4261_show_bool, NULL, |
|---|
| 187 | | - FAULT_UV); |
|---|
| 188 | | -static SENSOR_DEVICE_ATTR(in2_max_alarm, S_IRUGO, ltc4261_show_bool, NULL, |
|---|
| 189 | | - FAULT_OV); |
|---|
| 167 | +static SENSOR_DEVICE_ATTR_RO(in1_min_alarm, ltc4261_bool, FAULT_UV); |
|---|
| 168 | +static SENSOR_DEVICE_ATTR_RO(in1_max_alarm, ltc4261_bool, FAULT_OV); |
|---|
| 169 | +static SENSOR_DEVICE_ATTR_RO(in2_min_alarm, ltc4261_bool, FAULT_UV); |
|---|
| 170 | +static SENSOR_DEVICE_ATTR_RO(in2_max_alarm, ltc4261_bool, FAULT_OV); |
|---|
| 190 | 171 | |
|---|
| 191 | 172 | /* Currents (via sense resistor) */ |
|---|
| 192 | | -static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, ltc4261_show_value, NULL, |
|---|
| 193 | | - LTC4261_SENSE_H); |
|---|
| 173 | +static SENSOR_DEVICE_ATTR_RO(curr1_input, ltc4261_value, LTC4261_SENSE_H); |
|---|
| 194 | 174 | |
|---|
| 195 | 175 | /* Overcurrent alarm */ |
|---|
| 196 | | -static SENSOR_DEVICE_ATTR(curr1_max_alarm, S_IRUGO, ltc4261_show_bool, NULL, |
|---|
| 197 | | - FAULT_OC); |
|---|
| 176 | +static SENSOR_DEVICE_ATTR_RO(curr1_max_alarm, ltc4261_bool, FAULT_OC); |
|---|
| 198 | 177 | |
|---|
| 199 | 178 | static struct attribute *ltc4261_attrs[] = { |
|---|
| 200 | 179 | &sensor_dev_attr_in1_input.dev_attr.attr, |
|---|
| .. | .. |
|---|
| 211 | 190 | }; |
|---|
| 212 | 191 | ATTRIBUTE_GROUPS(ltc4261); |
|---|
| 213 | 192 | |
|---|
| 214 | | -static int ltc4261_probe(struct i2c_client *client, |
|---|
| 215 | | - const struct i2c_device_id *id) |
|---|
| 193 | +static int ltc4261_probe(struct i2c_client *client) |
|---|
| 216 | 194 | { |
|---|
| 217 | 195 | struct i2c_adapter *adapter = client->adapter; |
|---|
| 218 | 196 | struct device *dev = &client->dev; |
|---|
| .. | .. |
|---|
| 255 | 233 | .driver = { |
|---|
| 256 | 234 | .name = "ltc4261", |
|---|
| 257 | 235 | }, |
|---|
| 258 | | - .probe = ltc4261_probe, |
|---|
| 236 | + .probe_new = ltc4261_probe, |
|---|
| 259 | 237 | .id_table = ltc4261_id, |
|---|
| 260 | 238 | }; |
|---|
| 261 | 239 | |
|---|