aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/ds1620.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/ds1620.c')
-rw-r--r--drivers/char/ds1620.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/char/ds1620.c b/drivers/char/ds1620.c
index 24ffd8cec51e..544b4ce617f8 100644
--- a/drivers/char/ds1620.c
+++ b/drivers/char/ds1620.c
@@ -6,6 +6,7 @@
6#include <linux/miscdevice.h> 6#include <linux/miscdevice.h>
7#include <linux/delay.h> 7#include <linux/delay.h>
8#include <linux/proc_fs.h> 8#include <linux/proc_fs.h>
9#include <linux/seq_file.h>
9#include <linux/capability.h> 10#include <linux/capability.h>
10#include <linux/init.h> 11#include <linux/init.h>
11#include <linux/mutex.h> 12#include <linux/mutex.h>
@@ -329,9 +330,7 @@ ds1620_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
329} 330}
330 331
331#ifdef THERM_USE_PROC 332#ifdef THERM_USE_PROC
332static int 333static int ds1620_proc_therm_show(struct seq_file *m, void *v)
333proc_therm_ds1620_read(char *buf, char **start, off_t offset,
334 int len, int *eof, void *unused)
335{ 334{
336 struct therm th; 335 struct therm th;
337 int temp; 336 int temp;
@@ -339,17 +338,25 @@ proc_therm_ds1620_read(char *buf, char **start, off_t offset,
339 ds1620_read_state(&th); 338 ds1620_read_state(&th);
340 temp = cvt_9_to_int(ds1620_in(THERM_READ_TEMP, 9)); 339 temp = cvt_9_to_int(ds1620_in(THERM_READ_TEMP, 9));
341 340
342 len = sprintf(buf, "Thermostat: HI %i.%i, LOW %i.%i; " 341 seq_printf(m, "Thermostat: HI %i.%i, LOW %i.%i; temperature: %i.%i C, fan %s\n",
343 "temperature: %i.%i C, fan %s\n", 342 th.hi >> 1, th.hi & 1 ? 5 : 0,
344 th.hi >> 1, th.hi & 1 ? 5 : 0, 343 th.lo >> 1, th.lo & 1 ? 5 : 0,
345 th.lo >> 1, th.lo & 1 ? 5 : 0, 344 temp >> 1, temp & 1 ? 5 : 0,
346 temp >> 1, temp & 1 ? 5 : 0, 345 fan_state[netwinder_get_fan()]);
347 fan_state[netwinder_get_fan()]); 346 return 0;
347}
348 348
349 return len; 349static int ds1620_proc_therm_open(struct inode *inode, struct file *file)
350{
351 return single_open(file, ds1620_proc_therm_show, NULL);
350} 352}
351 353
352static struct proc_dir_entry *proc_therm_ds1620; 354static const struct file_operations ds1620_proc_therm_fops = {
355 .open = ds1620_proc_therm_open,
356 .read = seq_read,
357 .llseek = seq_lseek,
358 .release = seq_release,
359};
353#endif 360#endif
354 361
355static const struct file_operations ds1620_fops = { 362static const struct file_operations ds1620_fops = {
@@ -397,10 +404,7 @@ static int __init ds1620_init(void)
397 return ret; 404 return ret;
398 405
399#ifdef THERM_USE_PROC 406#ifdef THERM_USE_PROC
400 proc_therm_ds1620 = create_proc_entry("therm", 0, NULL); 407 if (!proc_create("therm", 0, NULL, &ds1620_proc_therm_fops))
401 if (proc_therm_ds1620)
402 proc_therm_ds1620->read_proc = proc_therm_ds1620_read;
403 else
404 printk(KERN_ERR "therm: unable to register /proc/therm\n"); 408 printk(KERN_ERR "therm: unable to register /proc/therm\n");
405#endif 409#endif
406 410