aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/pc87360.c
diff options
context:
space:
mode:
authorJim Cromie <jim.cromie@gmail.com>2005-09-02 17:05:07 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-09-05 12:26:55 -0400
commit11be27ea9bfd0ea7bca797ba6937285d18d426c2 (patch)
tree84d4952d0784b42990a3fbe1836d47992a22448d /drivers/hwmon/pc87360.c
parent694fa056a60828ef54a5db958468cc600c3b3622 (diff)
[PATCH] hwmon: (3/3) pc87360 driver update
pc87360: consolidate fan helper This patch consolidates the _set_fan_min() helper routine into the 2 line sysfs-callback wrapper that uses it. Signed-off-by: Jim Cromie <jim.cromie@gmail.com> Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/hwmon/pc87360.c')
-rw-r--r--drivers/hwmon/pc87360.c54
1 files changed, 24 insertions, 30 deletions
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c
index 5e87b2f1f13b..cf2a35799c7c 100644
--- a/drivers/hwmon/pc87360.c
+++ b/drivers/hwmon/pc87360.c
@@ -246,35 +246,6 @@ static struct i2c_driver pc87360_driver = {
246 * Sysfs stuff 246 * Sysfs stuff
247 */ 247 */
248 248
249static ssize_t _set_fan_min(struct device *dev, const char *buf,
250 size_t count, int nr)
251{
252 struct i2c_client *client = to_i2c_client(dev);
253 struct pc87360_data *data = i2c_get_clientdata(client);
254 long fan_min = simple_strtol(buf, NULL, 10);
255
256 down(&data->update_lock);
257 fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[nr]));
258
259 /* If it wouldn't fit, change clock divisor */
260 while (fan_min > 255
261 && (data->fan_status[nr] & 0x60) != 0x60) {
262 fan_min >>= 1;
263 data->fan[nr] >>= 1;
264 data->fan_status[nr] += 0x20;
265 }
266 data->fan_min[nr] = fan_min > 255 ? 255 : fan_min;
267 pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_MIN(nr),
268 data->fan_min[nr]);
269
270 /* Write new divider, preserve alarm bits */
271 pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(nr),
272 data->fan_status[nr] & 0xF9);
273 up(&data->update_lock);
274
275 return count;
276}
277
278static ssize_t show_fan_input(struct device *dev, struct device_attribute *devattr, char *buf) 249static ssize_t show_fan_input(struct device *dev, struct device_attribute *devattr, char *buf)
279{ 250{
280 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 251 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
@@ -307,7 +278,30 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr,
307 size_t count) 278 size_t count)
308{ 279{
309 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 280 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
310 return _set_fan_min(dev, buf, count, attr->index); 281 struct i2c_client *client = to_i2c_client(dev);
282 struct pc87360_data *data = i2c_get_clientdata(client);
283 long fan_min = simple_strtol(buf, NULL, 10);
284
285 down(&data->update_lock);
286 fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[attr->index]));
287
288 /* If it wouldn't fit, change clock divisor */
289 while (fan_min > 255
290 && (data->fan_status[attr->index] & 0x60) != 0x60) {
291 fan_min >>= 1;
292 data->fan[attr->index] >>= 1;
293 data->fan_status[attr->index] += 0x20;
294 }
295 data->fan_min[attr->index] = fan_min > 255 ? 255 : fan_min;
296 pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_MIN(attr->index),
297 data->fan_min[attr->index]);
298
299 /* Write new divider, preserve alarm bits */
300 pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(attr->index),
301 data->fan_status[attr->index] & 0xF9);
302 up(&data->update_lock);
303
304 return count;
311} 305}
312 306
313#define show_and_set_fan(offset) \ 307#define show_and_set_fan(offset) \