aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hwmon/smsc47b397.c64
1 files changed, 26 insertions, 38 deletions
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index 09df56118e18..943abbd95ab5 100644
--- a/drivers/hwmon/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
@@ -32,6 +32,7 @@
32#include <linux/jiffies.h> 32#include <linux/jiffies.h>
33#include <linux/platform_device.h> 33#include <linux/platform_device.h>
34#include <linux/hwmon.h> 34#include <linux/hwmon.h>
35#include <linux/hwmon-sysfs.h>
35#include <linux/err.h> 36#include <linux/err.h>
36#include <linux/init.h> 37#include <linux/init.h>
37#include <linux/mutex.h> 38#include <linux/mutex.h>
@@ -156,24 +157,18 @@ static int temp_from_reg(u8 reg)
156 return (s8)reg * 1000; 157 return (s8)reg * 1000;
157} 158}
158 159
159/* 0 <= nr <= 3 */ 160static ssize_t show_temp(struct device *dev, struct device_attribute
160static ssize_t show_temp(struct device *dev, char *buf, int nr) 161 *devattr, char *buf)
161{ 162{
163 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
162 struct smsc47b397_data *data = smsc47b397_update_device(dev); 164 struct smsc47b397_data *data = smsc47b397_update_device(dev);
163 return sprintf(buf, "%d\n", temp_from_reg(data->temp[nr])); 165 return sprintf(buf, "%d\n", temp_from_reg(data->temp[attr->index]));
164} 166}
165 167
166#define sysfs_temp(num) \ 168static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
167static ssize_t show_temp##num(struct device *dev, struct device_attribute *attr, char *buf) \ 169static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1);
168{ \ 170static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2);
169 return show_temp(dev, buf, num-1); \ 171static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3);
170} \
171static DEVICE_ATTR(temp##num##_input, S_IRUGO, show_temp##num, NULL)
172
173sysfs_temp(1);
174sysfs_temp(2);
175sysfs_temp(3);
176sysfs_temp(4);
177 172
178/* FAN: 1 RPM/bit 173/* FAN: 1 RPM/bit
179 REG: count of 90kHz pulses / revolution */ 174 REG: count of 90kHz pulses / revolution */
@@ -182,24 +177,17 @@ static int fan_from_reg(u16 reg)
182 return 90000 * 60 / reg; 177 return 90000 * 60 / reg;
183} 178}
184 179
185/* 0 <= nr <= 3 */ 180static ssize_t show_fan(struct device *dev, struct device_attribute
186static ssize_t show_fan(struct device *dev, char *buf, int nr) 181 *devattr, char *buf)
187{ 182{
188 struct smsc47b397_data *data = smsc47b397_update_device(dev); 183 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
189 return sprintf(buf, "%d\n", fan_from_reg(data->fan[nr])); 184 struct smsc47b397_data *data = smsc47b397_update_device(dev);
185 return sprintf(buf, "%d\n", fan_from_reg(data->fan[attr->index]));
190} 186}
191 187static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0);
192#define sysfs_fan(num) \ 188static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1);
193static ssize_t show_fan##num(struct device *dev, struct device_attribute *attr, char *buf) \ 189static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2);
194{ \ 190static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3);
195 return show_fan(dev, buf, num-1); \
196} \
197static DEVICE_ATTR(fan##num##_input, S_IRUGO, show_fan##num, NULL)
198
199sysfs_fan(1);
200sysfs_fan(2);
201sysfs_fan(3);
202sysfs_fan(4);
203 191
204static ssize_t show_name(struct device *dev, struct device_attribute 192static ssize_t show_name(struct device *dev, struct device_attribute
205 *devattr, char *buf) 193 *devattr, char *buf)
@@ -210,14 +198,14 @@ static ssize_t show_name(struct device *dev, struct device_attribute
210static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); 198static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
211 199
212static struct attribute *smsc47b397_attributes[] = { 200static struct attribute *smsc47b397_attributes[] = {
213 &dev_attr_temp1_input.attr, 201 &sensor_dev_attr_temp1_input.dev_attr.attr,
214 &dev_attr_temp2_input.attr, 202 &sensor_dev_attr_temp2_input.dev_attr.attr,
215 &dev_attr_temp3_input.attr, 203 &sensor_dev_attr_temp3_input.dev_attr.attr,
216 &dev_attr_temp4_input.attr, 204 &sensor_dev_attr_temp4_input.dev_attr.attr,
217 &dev_attr_fan1_input.attr, 205 &sensor_dev_attr_fan1_input.dev_attr.attr,
218 &dev_attr_fan2_input.attr, 206 &sensor_dev_attr_fan2_input.dev_attr.attr,
219 &dev_attr_fan3_input.attr, 207 &sensor_dev_attr_fan3_input.dev_attr.attr,
220 &dev_attr_fan4_input.attr, 208 &sensor_dev_attr_fan4_input.dev_attr.attr,
221 209
222 &dev_attr_name.attr, 210 &dev_attr_name.attr,
223 NULL 211 NULL