Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] RTC: rtc-dev tweak for 64-bit kernel

Make rtc-dev work well on 64-bit platforms with 32-bit userland. On those
platforms, users might try to read 32-bit integer value. This patch make
rtc-dev's read() work well for both "int" and "long" size. This tweak is came
from genrtc driver.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Atsushi Nemoto and committed by
Linus Torvalds
3418ff76 b44df334

+10 -5
+10 -5
drivers/rtc/rtc-dev.c
··· 58 58 unsigned long data; 59 59 ssize_t ret; 60 60 61 - if (count < sizeof(unsigned long)) 61 + if (count != sizeof(unsigned int) && count < sizeof(unsigned long)) 62 62 return -EINVAL; 63 63 64 64 add_wait_queue(&rtc->irq_queue, &wait); ··· 90 90 if (ret == 0) { 91 91 /* Check for any data updates */ 92 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 + data); 94 95 95 - ret = put_user(data, (unsigned long __user *)buf); 96 - if (ret == 0) 97 - ret = sizeof(unsigned long); 96 + if (sizeof(int) != sizeof(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 104 return ret; 100 105 }