diff options
Diffstat (limited to 'drivers/rtc/rtc-dev.c')
-rw-r--r-- | drivers/rtc/rtc-dev.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c index b1e3e6179e56..2011567005f9 100644 --- a/drivers/rtc/rtc-dev.c +++ b/drivers/rtc/rtc-dev.c | |||
@@ -58,7 +58,7 @@ rtc_dev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) | |||
58 | unsigned long data; | 58 | unsigned long data; |
59 | ssize_t ret; | 59 | ssize_t ret; |
60 | 60 | ||
61 | if (count < sizeof(unsigned long)) | 61 | if (count != sizeof(unsigned int) && count < sizeof(unsigned long)) |
62 | return -EINVAL; | 62 | return -EINVAL; |
63 | 63 | ||
64 | add_wait_queue(&rtc->irq_queue, &wait); | 64 | add_wait_queue(&rtc->irq_queue, &wait); |
@@ -90,11 +90,16 @@ rtc_dev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) | |||
90 | if (ret == 0) { | 90 | if (ret == 0) { |
91 | /* Check for any data updates */ | 91 | /* Check for any data updates */ |
92 | if (rtc->ops->read_callback) | 92 | if (rtc->ops->read_callback) |
93 | data = rtc->ops->read_callback(rtc->class_dev.dev, data); | 93 | data = rtc->ops->read_callback(rtc->class_dev.dev, |
94 | 94 | data); | |
95 | ret = put_user(data, (unsigned long __user *)buf); | 95 | |
96 | if (ret == 0) | 96 | if (sizeof(int) != sizeof(long) && |
97 | ret = sizeof(unsigned long); | 97 | count == sizeof(unsigned int)) |
98 | ret = put_user(data, (unsigned int __user *)buf) ?: | ||
99 | sizeof(unsigned int); | ||
100 | else | ||
101 | ret = put_user(data, (unsigned long __user *)buf) ?: | ||
102 | sizeof(unsigned long); | ||
98 | } | 103 | } |
99 | return ret; | 104 | return ret; |
100 | } | 105 | } |
@@ -136,13 +141,13 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file, | |||
136 | /* try the driver's ioctl interface */ | 141 | /* try the driver's ioctl interface */ |
137 | if (ops->ioctl) { | 142 | if (ops->ioctl) { |
138 | err = ops->ioctl(class_dev->dev, cmd, arg); | 143 | err = ops->ioctl(class_dev->dev, cmd, arg); |
139 | if (err != -EINVAL) | 144 | if (err != -ENOIOCTLCMD) |
140 | return err; | 145 | return err; |
141 | } | 146 | } |
142 | 147 | ||
143 | /* if the driver does not provide the ioctl interface | 148 | /* if the driver does not provide the ioctl interface |
144 | * or if that particular ioctl was not implemented | 149 | * or if that particular ioctl was not implemented |
145 | * (-EINVAL), we will try to emulate here. | 150 | * (-ENOIOCTLCMD), we will try to emulate here. |
146 | */ | 151 | */ |
147 | 152 | ||
148 | switch (cmd) { | 153 | switch (cmd) { |
@@ -228,7 +233,7 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file, | |||
228 | break; | 233 | break; |
229 | 234 | ||
230 | default: | 235 | default: |
231 | err = -EINVAL; | 236 | err = -ENOTTY; |
232 | break; | 237 | break; |
233 | } | 238 | } |
234 | 239 | ||