| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Driver for Linear Technology LTC2990 power monitor |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2014 Topic Embedded Products |
|---|
| 5 | 6 | * Author: Mike Looijmans <mike.looijmans@topic.nl> |
|---|
| 6 | | - * |
|---|
| 7 | | - * License: GPLv2 |
|---|
| 8 | 7 | */ |
|---|
| 9 | 8 | |
|---|
| 10 | 9 | #include <linux/bitops.h> |
|---|
| .. | .. |
|---|
| 14 | 13 | #include <linux/i2c.h> |
|---|
| 15 | 14 | #include <linux/kernel.h> |
|---|
| 16 | 15 | #include <linux/module.h> |
|---|
| 17 | | -#include <linux/of.h> |
|---|
| 16 | +#include <linux/property.h> |
|---|
| 18 | 17 | |
|---|
| 19 | 18 | #define LTC2990_STATUS 0x00 |
|---|
| 20 | 19 | #define LTC2990_CONTROL 0x01 |
|---|
| .. | .. |
|---|
| 136 | 135 | return 0; |
|---|
| 137 | 136 | } |
|---|
| 138 | 137 | |
|---|
| 139 | | -static ssize_t ltc2990_show_value(struct device *dev, |
|---|
| 138 | +static ssize_t ltc2990_value_show(struct device *dev, |
|---|
| 140 | 139 | struct device_attribute *da, char *buf) |
|---|
| 141 | 140 | { |
|---|
| 142 | 141 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
|---|
| .. | .. |
|---|
| 170 | 169 | return 0; |
|---|
| 171 | 170 | } |
|---|
| 172 | 171 | |
|---|
| 173 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, ltc2990_show_value, NULL, |
|---|
| 174 | | - LTC2990_TEMP1); |
|---|
| 175 | | -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, ltc2990_show_value, NULL, |
|---|
| 176 | | - LTC2990_TEMP2); |
|---|
| 177 | | -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, ltc2990_show_value, NULL, |
|---|
| 178 | | - LTC2990_TEMP3); |
|---|
| 179 | | -static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, ltc2990_show_value, NULL, |
|---|
| 180 | | - LTC2990_CURR1); |
|---|
| 181 | | -static SENSOR_DEVICE_ATTR(curr2_input, S_IRUGO, ltc2990_show_value, NULL, |
|---|
| 182 | | - LTC2990_CURR2); |
|---|
| 183 | | -static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, ltc2990_show_value, NULL, |
|---|
| 184 | | - LTC2990_IN0); |
|---|
| 185 | | -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ltc2990_show_value, NULL, |
|---|
| 186 | | - LTC2990_IN1); |
|---|
| 187 | | -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ltc2990_show_value, NULL, |
|---|
| 188 | | - LTC2990_IN2); |
|---|
| 189 | | -static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, ltc2990_show_value, NULL, |
|---|
| 190 | | - LTC2990_IN3); |
|---|
| 191 | | -static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, ltc2990_show_value, NULL, |
|---|
| 192 | | - LTC2990_IN4); |
|---|
| 172 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, ltc2990_value, LTC2990_TEMP1); |
|---|
| 173 | +static SENSOR_DEVICE_ATTR_RO(temp2_input, ltc2990_value, LTC2990_TEMP2); |
|---|
| 174 | +static SENSOR_DEVICE_ATTR_RO(temp3_input, ltc2990_value, LTC2990_TEMP3); |
|---|
| 175 | +static SENSOR_DEVICE_ATTR_RO(curr1_input, ltc2990_value, LTC2990_CURR1); |
|---|
| 176 | +static SENSOR_DEVICE_ATTR_RO(curr2_input, ltc2990_value, LTC2990_CURR2); |
|---|
| 177 | +static SENSOR_DEVICE_ATTR_RO(in0_input, ltc2990_value, LTC2990_IN0); |
|---|
| 178 | +static SENSOR_DEVICE_ATTR_RO(in1_input, ltc2990_value, LTC2990_IN1); |
|---|
| 179 | +static SENSOR_DEVICE_ATTR_RO(in2_input, ltc2990_value, LTC2990_IN2); |
|---|
| 180 | +static SENSOR_DEVICE_ATTR_RO(in3_input, ltc2990_value, LTC2990_IN3); |
|---|
| 181 | +static SENSOR_DEVICE_ATTR_RO(in4_input, ltc2990_value, LTC2990_IN4); |
|---|
| 193 | 182 | |
|---|
| 194 | 183 | static struct attribute *ltc2990_attrs[] = { |
|---|
| 195 | 184 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
|---|
| .. | .. |
|---|
| 211 | 200 | }; |
|---|
| 212 | 201 | __ATTRIBUTE_GROUPS(ltc2990); |
|---|
| 213 | 202 | |
|---|
| 214 | | -static int ltc2990_i2c_probe(struct i2c_client *i2c, |
|---|
| 215 | | - const struct i2c_device_id *id) |
|---|
| 203 | +static int ltc2990_i2c_probe(struct i2c_client *i2c) |
|---|
| 216 | 204 | { |
|---|
| 217 | 205 | int ret; |
|---|
| 218 | 206 | struct device *hwmon_dev; |
|---|
| 219 | 207 | struct ltc2990_data *data; |
|---|
| 220 | | - struct device_node *of_node = i2c->dev.of_node; |
|---|
| 221 | 208 | |
|---|
| 222 | 209 | if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA | |
|---|
| 223 | 210 | I2C_FUNC_SMBUS_WORD_DATA)) |
|---|
| .. | .. |
|---|
| 229 | 216 | |
|---|
| 230 | 217 | data->i2c = i2c; |
|---|
| 231 | 218 | |
|---|
| 232 | | - if (of_node) { |
|---|
| 233 | | - ret = of_property_read_u32_array(of_node, "lltc,meas-mode", |
|---|
| 234 | | - data->mode, 2); |
|---|
| 219 | + if (dev_fwnode(&i2c->dev)) { |
|---|
| 220 | + ret = device_property_read_u32_array(&i2c->dev, |
|---|
| 221 | + "lltc,meas-mode", |
|---|
| 222 | + data->mode, 2); |
|---|
| 235 | 223 | if (ret < 0) |
|---|
| 236 | 224 | return ret; |
|---|
| 237 | 225 | |
|---|
| .. | .. |
|---|
| 280 | 268 | .driver = { |
|---|
| 281 | 269 | .name = "ltc2990", |
|---|
| 282 | 270 | }, |
|---|
| 283 | | - .probe = ltc2990_i2c_probe, |
|---|
| 271 | + .probe_new = ltc2990_i2c_probe, |
|---|
| 284 | 272 | .id_table = ltc2990_i2c_id, |
|---|
| 285 | 273 | }; |
|---|
| 286 | 274 | |
|---|