| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * smsc47b397.c - Part of lm_sensors, Linux kernel modules |
|---|
| 3 | 4 | * for hardware monitoring |
|---|
| .. | .. |
|---|
| 10 | 11 | * derived in part from smsc47m1.c: |
|---|
| 11 | 12 | * Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> |
|---|
| 12 | 13 | * Copyright (C) 2004 Jean Delvare <jdelvare@suse.de> |
|---|
| 13 | | - * |
|---|
| 14 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 15 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 16 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 17 | | - * (at your option) any later version. |
|---|
| 18 | | - * |
|---|
| 19 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 20 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 21 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 22 | | - * GNU General Public License for more details. |
|---|
| 23 | | - * |
|---|
| 24 | | - * You should have received a copy of the GNU General Public License |
|---|
| 25 | | - * along with this program; if not, write to the Free Software |
|---|
| 26 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 27 | 14 | */ |
|---|
| 28 | 15 | |
|---|
| 29 | 16 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| .. | .. |
|---|
| 169 | 156 | return (s8)reg * 1000; |
|---|
| 170 | 157 | } |
|---|
| 171 | 158 | |
|---|
| 172 | | -static ssize_t show_temp(struct device *dev, struct device_attribute |
|---|
| 173 | | - *devattr, char *buf) |
|---|
| 159 | +static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, |
|---|
| 160 | + char *buf) |
|---|
| 174 | 161 | { |
|---|
| 175 | 162 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
|---|
| 176 | 163 | struct smsc47b397_data *data = smsc47b397_update_device(dev); |
|---|
| 177 | 164 | return sprintf(buf, "%d\n", temp_from_reg(data->temp[attr->index])); |
|---|
| 178 | 165 | } |
|---|
| 179 | 166 | |
|---|
| 180 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); |
|---|
| 181 | | -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); |
|---|
| 182 | | -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); |
|---|
| 183 | | -static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3); |
|---|
| 167 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); |
|---|
| 168 | +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); |
|---|
| 169 | +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2); |
|---|
| 170 | +static SENSOR_DEVICE_ATTR_RO(temp4_input, temp, 3); |
|---|
| 184 | 171 | |
|---|
| 185 | 172 | /* |
|---|
| 186 | 173 | * FAN: 1 RPM/bit |
|---|
| .. | .. |
|---|
| 193 | 180 | return 90000 * 60 / reg; |
|---|
| 194 | 181 | } |
|---|
| 195 | 182 | |
|---|
| 196 | | -static ssize_t show_fan(struct device *dev, struct device_attribute |
|---|
| 197 | | - *devattr, char *buf) |
|---|
| 183 | +static ssize_t fan_show(struct device *dev, struct device_attribute *devattr, |
|---|
| 184 | + char *buf) |
|---|
| 198 | 185 | { |
|---|
| 199 | 186 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
|---|
| 200 | 187 | struct smsc47b397_data *data = smsc47b397_update_device(dev); |
|---|
| 201 | 188 | return sprintf(buf, "%d\n", fan_from_reg(data->fan[attr->index])); |
|---|
| 202 | 189 | } |
|---|
| 203 | | -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); |
|---|
| 204 | | -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); |
|---|
| 205 | | -static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2); |
|---|
| 206 | | -static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3); |
|---|
| 190 | +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); |
|---|
| 191 | +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); |
|---|
| 192 | +static SENSOR_DEVICE_ATTR_RO(fan3_input, fan, 2); |
|---|
| 193 | +static SENSOR_DEVICE_ATTR_RO(fan4_input, fan, 3); |
|---|
| 207 | 194 | |
|---|
| 208 | 195 | static struct attribute *smsc47b397_attrs[] = { |
|---|
| 209 | 196 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
|---|