diff options
-rw-r--r-- | drivers/rtc/rtc-dev.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c index b1e3e6179e56..6c9ad92747fd 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 | } |