diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/ultra45_env.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/drivers/hwmon/ultra45_env.c b/drivers/hwmon/ultra45_env.c index b9a87e89bab4..c315c59f61fe 100644 --- a/drivers/hwmon/ultra45_env.c +++ b/drivers/hwmon/ultra45_env.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* ultra45_env.c: Driver for Ultra45 PIC16F747 environmental monitor. | 1 | /* |
2 | * ultra45_env.c: Driver for Ultra45 PIC16F747 environmental monitor. | ||
2 | * | 3 | * |
3 | * Copyright (C) 2008 David S. Miller <davem@davemloft.net> | 4 | * Copyright (C) 2008 David S. Miller <davem@davemloft.net> |
4 | */ | 5 | */ |
@@ -82,7 +83,8 @@ static void env_write(struct env *p, u8 ireg, u8 val) | |||
82 | spin_unlock(&p->lock); | 83 | spin_unlock(&p->lock); |
83 | } | 84 | } |
84 | 85 | ||
85 | /* There seems to be a adr7462 providing these values, thus a lot | 86 | /* |
87 | * There seems to be a adr7462 providing these values, thus a lot | ||
86 | * of these calculations are borrowed from the adt7470 driver. | 88 | * of these calculations are borrowed from the adt7470 driver. |
87 | */ | 89 | */ |
88 | #define FAN_PERIOD_TO_RPM(x) ((90000 * 60) / (x)) | 90 | #define FAN_PERIOD_TO_RPM(x) ((90000 * 60) / (x)) |
@@ -90,7 +92,8 @@ static void env_write(struct env *p, u8 ireg, u8 val) | |||
90 | #define FAN_PERIOD_INVALID (0xff << 8) | 92 | #define FAN_PERIOD_INVALID (0xff << 8) |
91 | #define FAN_DATA_VALID(x) ((x) && (x) != FAN_PERIOD_INVALID) | 93 | #define FAN_DATA_VALID(x) ((x) && (x) != FAN_PERIOD_INVALID) |
92 | 94 | ||
93 | static ssize_t show_fan_speed(struct device *dev, struct device_attribute *attr, char *buf) | 95 | static ssize_t show_fan_speed(struct device *dev, struct device_attribute *attr, |
96 | char *buf) | ||
94 | { | 97 | { |
95 | int fan_nr = to_sensor_dev_attr(attr)->index; | 98 | int fan_nr = to_sensor_dev_attr(attr)->index; |
96 | struct env *p = dev_get_drvdata(dev); | 99 | struct env *p = dev_get_drvdata(dev); |
@@ -111,10 +114,15 @@ static ssize_t set_fan_speed(struct device *dev, struct device_attribute *attr, | |||
111 | const char *buf, size_t count) | 114 | const char *buf, size_t count) |
112 | { | 115 | { |
113 | int fan_nr = to_sensor_dev_attr(attr)->index; | 116 | int fan_nr = to_sensor_dev_attr(attr)->index; |
114 | int rpm = simple_strtol(buf, NULL, 10); | 117 | unsigned long rpm; |
115 | struct env *p = dev_get_drvdata(dev); | 118 | struct env *p = dev_get_drvdata(dev); |
116 | int period; | 119 | int period; |
117 | u8 val; | 120 | u8 val; |
121 | int err; | ||
122 | |||
123 | err = kstrtoul(buf, 10, &rpm); | ||
124 | if (err) | ||
125 | return err; | ||
118 | 126 | ||
119 | if (!rpm) | 127 | if (!rpm) |
120 | return -EINVAL; | 128 | return -EINVAL; |
@@ -126,7 +134,8 @@ static ssize_t set_fan_speed(struct device *dev, struct device_attribute *attr, | |||
126 | return count; | 134 | return count; |
127 | } | 135 | } |
128 | 136 | ||
129 | static ssize_t show_fan_fault(struct device *dev, struct device_attribute *attr, char *buf) | 137 | static ssize_t show_fan_fault(struct device *dev, struct device_attribute *attr, |
138 | char *buf) | ||
130 | { | 139 | { |
131 | int fan_nr = to_sensor_dev_attr(attr)->index; | 140 | int fan_nr = to_sensor_dev_attr(attr)->index; |
132 | struct env *p = dev_get_drvdata(dev); | 141 | struct env *p = dev_get_drvdata(dev); |
@@ -148,7 +157,8 @@ fan(4); | |||
148 | 157 | ||
149 | static SENSOR_DEVICE_ATTR(psu_fan_fault, S_IRUGO, show_fan_fault, NULL, 6); | 158 | static SENSOR_DEVICE_ATTR(psu_fan_fault, S_IRUGO, show_fan_fault, NULL, 6); |
150 | 159 | ||
151 | static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf) | 160 | static ssize_t show_temp(struct device *dev, struct device_attribute *attr, |
161 | char *buf) | ||
152 | { | 162 | { |
153 | int temp_nr = to_sensor_dev_attr(attr)->index; | 163 | int temp_nr = to_sensor_dev_attr(attr)->index; |
154 | struct env *p = dev_get_drvdata(dev); | 164 | struct env *p = dev_get_drvdata(dev); |
@@ -168,7 +178,8 @@ static SENSOR_DEVICE_ATTR(lsi1064_local_temp, S_IRUGO, show_temp, NULL, 6); | |||
168 | static SENSOR_DEVICE_ATTR(front_panel_temp, S_IRUGO, show_temp, NULL, 7); | 178 | static SENSOR_DEVICE_ATTR(front_panel_temp, S_IRUGO, show_temp, NULL, 7); |
169 | static SENSOR_DEVICE_ATTR(psu_temp, S_IRUGO, show_temp, NULL, 13); | 179 | static SENSOR_DEVICE_ATTR(psu_temp, S_IRUGO, show_temp, NULL, 13); |
170 | 180 | ||
171 | static ssize_t show_stat_bit(struct device *dev, struct device_attribute *attr, char *buf) | 181 | static ssize_t show_stat_bit(struct device *dev, struct device_attribute *attr, |
182 | char *buf) | ||
172 | { | 183 | { |
173 | int index = to_sensor_dev_attr(attr)->index; | 184 | int index = to_sensor_dev_attr(attr)->index; |
174 | struct env *p = dev_get_drvdata(dev); | 185 | struct env *p = dev_get_drvdata(dev); |
@@ -181,9 +192,11 @@ static ssize_t show_stat_bit(struct device *dev, struct device_attribute *attr, | |||
181 | static SENSOR_DEVICE_ATTR(fan_failure, S_IRUGO, show_stat_bit, NULL, 0); | 192 | static SENSOR_DEVICE_ATTR(fan_failure, S_IRUGO, show_stat_bit, NULL, 0); |
182 | static SENSOR_DEVICE_ATTR(env_bus_busy, S_IRUGO, show_stat_bit, NULL, 1); | 193 | static SENSOR_DEVICE_ATTR(env_bus_busy, S_IRUGO, show_stat_bit, NULL, 1); |
183 | static SENSOR_DEVICE_ATTR(env_data_stale, S_IRUGO, show_stat_bit, NULL, 2); | 194 | static SENSOR_DEVICE_ATTR(env_data_stale, S_IRUGO, show_stat_bit, NULL, 2); |
184 | static SENSOR_DEVICE_ATTR(tpm_self_test_passed, S_IRUGO, show_stat_bit, NULL, 3); | 195 | static SENSOR_DEVICE_ATTR(tpm_self_test_passed, S_IRUGO, show_stat_bit, NULL, |
196 | 3); | ||
185 | 197 | ||
186 | static ssize_t show_fwver(struct device *dev, struct device_attribute *attr, char *buf) | 198 | static ssize_t show_fwver(struct device *dev, struct device_attribute *attr, |
199 | char *buf) | ||
187 | { | 200 | { |
188 | struct env *p = dev_get_drvdata(dev); | 201 | struct env *p = dev_get_drvdata(dev); |
189 | u8 val; | 202 | u8 val; |
@@ -194,7 +207,8 @@ static ssize_t show_fwver(struct device *dev, struct device_attribute *attr, cha | |||
194 | 207 | ||
195 | static SENSOR_DEVICE_ATTR(firmware_version, S_IRUGO, show_fwver, NULL, 0); | 208 | static SENSOR_DEVICE_ATTR(firmware_version, S_IRUGO, show_fwver, NULL, 0); |
196 | 209 | ||
197 | static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf) | 210 | static ssize_t show_name(struct device *dev, struct device_attribute *attr, |
211 | char *buf) | ||
198 | { | 212 | { |
199 | return sprintf(buf, "ultra45\n"); | 213 | return sprintf(buf, "ultra45\n"); |
200 | } | 214 | } |