diff options
Diffstat (limited to 'drivers/hwmon/smsc47b397.c')
-rw-r--r-- | drivers/hwmon/smsc47b397.c | 64 |
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 */ | 160 | static ssize_t show_temp(struct device *dev, struct device_attribute |
160 | static 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) \ | 168 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); |
167 | static ssize_t show_temp##num(struct device *dev, struct device_attribute *attr, char *buf) \ | 169 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); |
168 | { \ | 170 | static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); |
169 | return show_temp(dev, buf, num-1); \ | 171 | static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3); |
170 | } \ | ||
171 | static DEVICE_ATTR(temp##num##_input, S_IRUGO, show_temp##num, NULL) | ||
172 | |||
173 | sysfs_temp(1); | ||
174 | sysfs_temp(2); | ||
175 | sysfs_temp(3); | ||
176 | sysfs_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 */ | 180 | static ssize_t show_fan(struct device *dev, struct device_attribute |
186 | static 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 | 187 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); | |
192 | #define sysfs_fan(num) \ | 188 | static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); |
193 | static ssize_t show_fan##num(struct device *dev, struct device_attribute *attr, char *buf) \ | 189 | static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2); |
194 | { \ | 190 | static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3); |
195 | return show_fan(dev, buf, num-1); \ | ||
196 | } \ | ||
197 | static DEVICE_ATTR(fan##num##_input, S_IRUGO, show_fan##num, NULL) | ||
198 | |||
199 | sysfs_fan(1); | ||
200 | sysfs_fan(2); | ||
201 | sysfs_fan(3); | ||
202 | sysfs_fan(4); | ||
203 | 191 | ||
204 | static ssize_t show_name(struct device *dev, struct device_attribute | 192 | static 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 | |||
210 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | 198 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); |
211 | 199 | ||
212 | static struct attribute *smsc47b397_attributes[] = { | 200 | static 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 |