| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) ST-Ericsson 2010 - 2013 |
|---|
| 3 | 4 | * Author: Martin Persson <martin.persson@stericsson.com> |
|---|
| 4 | 5 | * Hongbo Zhang <hongbo.zhang@linaro.org> |
|---|
| 5 | | - * License Terms: GNU General Public License v2 |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * ABX500 does not provide auto ADC, so to monitor the required temperatures, |
|---|
| 8 | 8 | * a periodic work is used. It is more important to not wake up the CPU than |
|---|
| .. | .. |
|---|
| 121 | 121 | } |
|---|
| 122 | 122 | |
|---|
| 123 | 123 | /* HWMON sysfs interfaces */ |
|---|
| 124 | | -static ssize_t show_name(struct device *dev, struct device_attribute *devattr, |
|---|
| 124 | +static ssize_t name_show(struct device *dev, struct device_attribute *devattr, |
|---|
| 125 | 125 | char *buf) |
|---|
| 126 | 126 | { |
|---|
| 127 | 127 | struct abx500_temp *data = dev_get_drvdata(dev); |
|---|
| .. | .. |
|---|
| 129 | 129 | return data->ops.show_name(dev, devattr, buf); |
|---|
| 130 | 130 | } |
|---|
| 131 | 131 | |
|---|
| 132 | | -static ssize_t show_label(struct device *dev, |
|---|
| 132 | +static ssize_t label_show(struct device *dev, |
|---|
| 133 | 133 | struct device_attribute *devattr, char *buf) |
|---|
| 134 | 134 | { |
|---|
| 135 | 135 | struct abx500_temp *data = dev_get_drvdata(dev); |
|---|
| .. | .. |
|---|
| 137 | 137 | return data->ops.show_label(dev, devattr, buf); |
|---|
| 138 | 138 | } |
|---|
| 139 | 139 | |
|---|
| 140 | | -static ssize_t show_input(struct device *dev, |
|---|
| 140 | +static ssize_t input_show(struct device *dev, |
|---|
| 141 | 141 | struct device_attribute *devattr, char *buf) |
|---|
| 142 | 142 | { |
|---|
| 143 | 143 | int ret, temp; |
|---|
| .. | .. |
|---|
| 153 | 153 | } |
|---|
| 154 | 154 | |
|---|
| 155 | 155 | /* Set functions (RW nodes) */ |
|---|
| 156 | | -static ssize_t set_min(struct device *dev, struct device_attribute *devattr, |
|---|
| 157 | | - const char *buf, size_t count) |
|---|
| 156 | +static ssize_t min_store(struct device *dev, struct device_attribute *devattr, |
|---|
| 157 | + const char *buf, size_t count) |
|---|
| 158 | 158 | { |
|---|
| 159 | 159 | unsigned long val; |
|---|
| 160 | 160 | struct abx500_temp *data = dev_get_drvdata(dev); |
|---|
| .. | .. |
|---|
| 173 | 173 | return count; |
|---|
| 174 | 174 | } |
|---|
| 175 | 175 | |
|---|
| 176 | | -static ssize_t set_max(struct device *dev, struct device_attribute *devattr, |
|---|
| 177 | | - const char *buf, size_t count) |
|---|
| 176 | +static ssize_t max_store(struct device *dev, struct device_attribute *devattr, |
|---|
| 177 | + const char *buf, size_t count) |
|---|
| 178 | 178 | { |
|---|
| 179 | 179 | unsigned long val; |
|---|
| 180 | 180 | struct abx500_temp *data = dev_get_drvdata(dev); |
|---|
| .. | .. |
|---|
| 193 | 193 | return count; |
|---|
| 194 | 194 | } |
|---|
| 195 | 195 | |
|---|
| 196 | | -static ssize_t set_max_hyst(struct device *dev, |
|---|
| 197 | | - struct device_attribute *devattr, |
|---|
| 198 | | - const char *buf, size_t count) |
|---|
| 196 | +static ssize_t max_hyst_store(struct device *dev, |
|---|
| 197 | + struct device_attribute *devattr, |
|---|
| 198 | + const char *buf, size_t count) |
|---|
| 199 | 199 | { |
|---|
| 200 | 200 | unsigned long val; |
|---|
| 201 | 201 | struct abx500_temp *data = dev_get_drvdata(dev); |
|---|
| .. | .. |
|---|
| 215 | 215 | } |
|---|
| 216 | 216 | |
|---|
| 217 | 217 | /* Show functions (RO nodes) */ |
|---|
| 218 | | -static ssize_t show_min(struct device *dev, |
|---|
| 219 | | - struct device_attribute *devattr, char *buf) |
|---|
| 218 | +static ssize_t min_show(struct device *dev, struct device_attribute *devattr, |
|---|
| 219 | + char *buf) |
|---|
| 220 | 220 | { |
|---|
| 221 | 221 | struct abx500_temp *data = dev_get_drvdata(dev); |
|---|
| 222 | 222 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
|---|
| .. | .. |
|---|
| 224 | 224 | return sprintf(buf, "%lu\n", data->min[attr->index]); |
|---|
| 225 | 225 | } |
|---|
| 226 | 226 | |
|---|
| 227 | | -static ssize_t show_max(struct device *dev, |
|---|
| 228 | | - struct device_attribute *devattr, char *buf) |
|---|
| 227 | +static ssize_t max_show(struct device *dev, struct device_attribute *devattr, |
|---|
| 228 | + char *buf) |
|---|
| 229 | 229 | { |
|---|
| 230 | 230 | struct abx500_temp *data = dev_get_drvdata(dev); |
|---|
| 231 | 231 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
|---|
| .. | .. |
|---|
| 233 | 233 | return sprintf(buf, "%lu\n", data->max[attr->index]); |
|---|
| 234 | 234 | } |
|---|
| 235 | 235 | |
|---|
| 236 | | -static ssize_t show_max_hyst(struct device *dev, |
|---|
| 236 | +static ssize_t max_hyst_show(struct device *dev, |
|---|
| 237 | 237 | struct device_attribute *devattr, char *buf) |
|---|
| 238 | 238 | { |
|---|
| 239 | 239 | struct abx500_temp *data = dev_get_drvdata(dev); |
|---|
| .. | .. |
|---|
| 242 | 242 | return sprintf(buf, "%lu\n", data->max_hyst[attr->index]); |
|---|
| 243 | 243 | } |
|---|
| 244 | 244 | |
|---|
| 245 | | -static ssize_t show_min_alarm(struct device *dev, |
|---|
| 245 | +static ssize_t min_alarm_show(struct device *dev, |
|---|
| 246 | 246 | struct device_attribute *devattr, char *buf) |
|---|
| 247 | 247 | { |
|---|
| 248 | 248 | struct abx500_temp *data = dev_get_drvdata(dev); |
|---|
| .. | .. |
|---|
| 251 | 251 | return sprintf(buf, "%d\n", data->min_alarm[attr->index]); |
|---|
| 252 | 252 | } |
|---|
| 253 | 253 | |
|---|
| 254 | | -static ssize_t show_max_alarm(struct device *dev, |
|---|
| 254 | +static ssize_t max_alarm_show(struct device *dev, |
|---|
| 255 | 255 | struct device_attribute *devattr, char *buf) |
|---|
| 256 | 256 | { |
|---|
| 257 | 257 | struct abx500_temp *data = dev_get_drvdata(dev); |
|---|
| .. | .. |
|---|
| 273 | 273 | } |
|---|
| 274 | 274 | |
|---|
| 275 | 275 | /* Chip name, required by hwmon */ |
|---|
| 276 | | -static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, 0); |
|---|
| 276 | +static SENSOR_DEVICE_ATTR_RO(name, name, 0); |
|---|
| 277 | 277 | |
|---|
| 278 | 278 | /* GPADC - SENSOR1 */ |
|---|
| 279 | | -static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, show_label, NULL, 0); |
|---|
| 280 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_input, NULL, 0); |
|---|
| 281 | | -static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_min, set_min, 0); |
|---|
| 282 | | -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_max, set_max, 0); |
|---|
| 283 | | -static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, |
|---|
| 284 | | - show_max_hyst, set_max_hyst, 0); |
|---|
| 285 | | -static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_min_alarm, NULL, 0); |
|---|
| 286 | | -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_max_alarm, NULL, 0); |
|---|
| 279 | +static SENSOR_DEVICE_ATTR_RO(temp1_label, label, 0); |
|---|
| 280 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, input, 0); |
|---|
| 281 | +static SENSOR_DEVICE_ATTR_RW(temp1_min, min, 0); |
|---|
| 282 | +static SENSOR_DEVICE_ATTR_RW(temp1_max, max, 0); |
|---|
| 283 | +static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, max_hyst, 0); |
|---|
| 284 | +static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, min_alarm, 0); |
|---|
| 285 | +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, max_alarm, 0); |
|---|
| 287 | 286 | |
|---|
| 288 | 287 | /* GPADC - SENSOR2 */ |
|---|
| 289 | | -static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, show_label, NULL, 1); |
|---|
| 290 | | -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_input, NULL, 1); |
|---|
| 291 | | -static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_min, set_min, 1); |
|---|
| 292 | | -static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_max, set_max, 1); |
|---|
| 293 | | -static SENSOR_DEVICE_ATTR(temp2_max_hyst, S_IWUSR | S_IRUGO, |
|---|
| 294 | | - show_max_hyst, set_max_hyst, 1); |
|---|
| 295 | | -static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_min_alarm, NULL, 1); |
|---|
| 296 | | -static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_max_alarm, NULL, 1); |
|---|
| 288 | +static SENSOR_DEVICE_ATTR_RO(temp2_label, label, 1); |
|---|
| 289 | +static SENSOR_DEVICE_ATTR_RO(temp2_input, input, 1); |
|---|
| 290 | +static SENSOR_DEVICE_ATTR_RW(temp2_min, min, 1); |
|---|
| 291 | +static SENSOR_DEVICE_ATTR_RW(temp2_max, max, 1); |
|---|
| 292 | +static SENSOR_DEVICE_ATTR_RW(temp2_max_hyst, max_hyst, 1); |
|---|
| 293 | +static SENSOR_DEVICE_ATTR_RO(temp2_min_alarm, min_alarm, 1); |
|---|
| 294 | +static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, max_alarm, 1); |
|---|
| 297 | 295 | |
|---|
| 298 | 296 | /* GPADC - SENSOR3 */ |
|---|
| 299 | | -static SENSOR_DEVICE_ATTR(temp3_label, S_IRUGO, show_label, NULL, 2); |
|---|
| 300 | | -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_input, NULL, 2); |
|---|
| 301 | | -static SENSOR_DEVICE_ATTR(temp3_min, S_IWUSR | S_IRUGO, show_min, set_min, 2); |
|---|
| 302 | | -static SENSOR_DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_max, set_max, 2); |
|---|
| 303 | | -static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IWUSR | S_IRUGO, |
|---|
| 304 | | - show_max_hyst, set_max_hyst, 2); |
|---|
| 305 | | -static SENSOR_DEVICE_ATTR(temp3_min_alarm, S_IRUGO, show_min_alarm, NULL, 2); |
|---|
| 306 | | -static SENSOR_DEVICE_ATTR(temp3_max_alarm, S_IRUGO, show_max_alarm, NULL, 2); |
|---|
| 297 | +static SENSOR_DEVICE_ATTR_RO(temp3_label, label, 2); |
|---|
| 298 | +static SENSOR_DEVICE_ATTR_RO(temp3_input, input, 2); |
|---|
| 299 | +static SENSOR_DEVICE_ATTR_RW(temp3_min, min, 2); |
|---|
| 300 | +static SENSOR_DEVICE_ATTR_RW(temp3_max, max, 2); |
|---|
| 301 | +static SENSOR_DEVICE_ATTR_RW(temp3_max_hyst, max_hyst, 2); |
|---|
| 302 | +static SENSOR_DEVICE_ATTR_RO(temp3_min_alarm, min_alarm, 2); |
|---|
| 303 | +static SENSOR_DEVICE_ATTR_RO(temp3_max_alarm, max_alarm, 2); |
|---|
| 307 | 304 | |
|---|
| 308 | 305 | /* GPADC - SENSOR4 */ |
|---|
| 309 | | -static SENSOR_DEVICE_ATTR(temp4_label, S_IRUGO, show_label, NULL, 3); |
|---|
| 310 | | -static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_input, NULL, 3); |
|---|
| 311 | | -static SENSOR_DEVICE_ATTR(temp4_min, S_IWUSR | S_IRUGO, show_min, set_min, 3); |
|---|
| 312 | | -static SENSOR_DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_max, set_max, 3); |
|---|
| 313 | | -static SENSOR_DEVICE_ATTR(temp4_max_hyst, S_IWUSR | S_IRUGO, |
|---|
| 314 | | - show_max_hyst, set_max_hyst, 3); |
|---|
| 315 | | -static SENSOR_DEVICE_ATTR(temp4_min_alarm, S_IRUGO, show_min_alarm, NULL, 3); |
|---|
| 316 | | -static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_max_alarm, NULL, 3); |
|---|
| 306 | +static SENSOR_DEVICE_ATTR_RO(temp4_label, label, 3); |
|---|
| 307 | +static SENSOR_DEVICE_ATTR_RO(temp4_input, input, 3); |
|---|
| 308 | +static SENSOR_DEVICE_ATTR_RW(temp4_min, min, 3); |
|---|
| 309 | +static SENSOR_DEVICE_ATTR_RW(temp4_max, max, 3); |
|---|
| 310 | +static SENSOR_DEVICE_ATTR_RW(temp4_max_hyst, max_hyst, 3); |
|---|
| 311 | +static SENSOR_DEVICE_ATTR_RO(temp4_min_alarm, min_alarm, 3); |
|---|
| 312 | +static SENSOR_DEVICE_ATTR_RO(temp4_max_alarm, max_alarm, 3); |
|---|
| 317 | 313 | |
|---|
| 318 | 314 | static struct attribute *abx500_temp_attributes[] = { |
|---|
| 319 | 315 | &sensor_dev_attr_name.dev_attr.attr, |
|---|