git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git]
/
drivers
/
char
/
ds1620.c
diff --git
a/drivers/char/ds1620.c
b/drivers/char/ds1620.c
index
4171ca1
..
e2c4eca
100644
(file)
--- a/
drivers/char/ds1620.c
+++ b/
drivers/char/ds1620.c
@@
-213,15
+213,11
@@
static void ds1620_read_state(struct therm *therm)
}
static ssize_t
}
static ssize_t
-ds1620_read(struct file *file, char *buf, size_t count, loff_t *ptr)
+ds1620_read(struct file *file, char
__user
*buf, size_t count, loff_t *ptr)
{
signed int cur_temp;
signed char cur_temp_degF;
{
signed int cur_temp;
signed char cur_temp_degF;
- /* Can't seek (pread) on this device */
- if (ptr != &file->f_pos)
- return -ESPIPE;
-
cur_temp = cvt_9_to_int(ds1620_in(THERM_READ_TEMP, 9)) >> 1;
/* convert to Fahrenheit, as per wdt.c */
cur_temp = cvt_9_to_int(ds1620_in(THERM_READ_TEMP, 9)) >> 1;
/* convert to Fahrenheit, as per wdt.c */
@@
-237,8
+233,14
@@
static int
ds1620_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{
struct therm therm;
ds1620_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{
struct therm therm;
+ union {
+ struct therm __user *therm;
+ int __user *i;
+ } uarg;
int i;
int i;
+ uarg.i = (int __user *)arg;
+
switch(cmd) {
case CMD_SET_THERMOSTATE:
case CMD_SET_THERMOSTATE2:
switch(cmd) {
case CMD_SET_THERMOSTATE:
case CMD_SET_THERMOSTATE2:
@@
-246,11
+248,11
@@
ds1620_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned
return -EPERM;
if (cmd == CMD_SET_THERMOSTATE) {
return -EPERM;
if (cmd == CMD_SET_THERMOSTATE) {
- if (get_user(therm.hi,
(int *)arg
))
+ if (get_user(therm.hi,
uarg.i
))
return -EFAULT;
therm.lo = therm.hi - 3;
} else {
return -EFAULT;
therm.lo = therm.hi - 3;
} else {
- if (copy_from_user(&therm,
(void *)arg
, sizeof(therm)))
+ if (copy_from_user(&therm,
uarg.therm
, sizeof(therm)))
return -EFAULT;
}
return -EFAULT;
}
@@
-268,10
+270,10
@@
ds1620_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned
therm.hi >>= 1;
if (cmd == CMD_GET_THERMOSTATE) {
therm.hi >>= 1;
if (cmd == CMD_GET_THERMOSTATE) {
- if (put_user(therm.hi,
(int *)arg
))
+ if (put_user(therm.hi,
uarg.i
))
return -EFAULT;
} else {
return -EFAULT;
} else {
- if (copy_to_user(
(void *)arg
, &therm, sizeof(therm)))
+ if (copy_to_user(
uarg.therm
, &therm, sizeof(therm)))
return -EFAULT;
}
break;
return -EFAULT;
}
break;
@@
-283,23
+285,23
@@
ds1620_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned
if (cmd == CMD_GET_TEMPERATURE)
i >>= 1;
if (cmd == CMD_GET_TEMPERATURE)
i >>= 1;
- return put_user(i,
(int *)arg
) ? -EFAULT : 0;
+ return put_user(i,
uarg.i
) ? -EFAULT : 0;
case CMD_GET_STATUS:
i = ds1620_in(THERM_READ_CONFIG, 8) & 0xe3;
case CMD_GET_STATUS:
i = ds1620_in(THERM_READ_CONFIG, 8) & 0xe3;
- return put_user(i,
(int *)arg
) ? -EFAULT : 0;
+ return put_user(i,
uarg.i
) ? -EFAULT : 0;
case CMD_GET_FAN:
i = netwinder_get_fan();
case CMD_GET_FAN:
i = netwinder_get_fan();
- return put_user(i,
(int *)arg
) ? -EFAULT : 0;
+ return put_user(i,
uarg.i
) ? -EFAULT : 0;
case CMD_SET_FAN:
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
case CMD_SET_FAN:
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- if (get_user(i,
(int *)arg
))
+ if (get_user(i,
uarg.i
))
return -EFAULT;
netwinder_set_fan(i);
return -EFAULT;
netwinder_set_fan(i);
@@
-338,6
+340,7
@@
static struct proc_dir_entry *proc_therm_ds1620;
static struct file_operations ds1620_fops = {
.owner = THIS_MODULE,
static struct file_operations ds1620_fops = {
.owner = THIS_MODULE,
+ .open = nonseekable_open,
.read = ds1620_read,
.ioctl = ds1620_ioctl,
};
.read = ds1620_read,
.ioctl = ds1620_ioctl,
};
@@
-380,7
+383,7
@@
static int __init ds1620_init(void)
return ret;
#ifdef THERM_USE_PROC
return ret;
#ifdef THERM_USE_PROC
- proc_therm_ds1620 = create_proc_entry("therm", 0,
0
);
+ proc_therm_ds1620 = create_proc_entry("therm", 0,
NULL
);
if (proc_therm_ds1620)
proc_therm_ds1620->read_proc = proc_therm_ds1620_read;
else
if (proc_therm_ds1620)
proc_therm_ds1620->read_proc = proc_therm_ds1620_read;
else