* [PATCH] RTC: rtc-dev tweak for 64-bit kernel
@ 2006-04-28 16:25 Atsushi Nemoto
2006-04-29 6:31 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Atsushi Nemoto @ 2006-04-28 16:25 UTC (permalink / raw)
To: Alessandro Zummo; +Cc: linux-kernel, akpm
Make rtc-dev more friendly to 64-bit platforms with 32-bit userland.
This tweak is came from genrtc driver.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index b1e3e61..ae6adc4 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -58,7 +58,7 @@ rtc_dev_read(struct file *file, char __u
unsigned long data;
ssize_t ret;
- if (count < sizeof(unsigned long))
+ if (count != sizeof (unsigned int) && count < sizeof (unsigned long))
return -EINVAL;
add_wait_queue(&rtc->irq_queue, &wait);
@@ -92,9 +92,13 @@ rtc_dev_read(struct file *file, char __u
if (rtc->ops->read_callback)
data = rtc->ops->read_callback(rtc->class_dev.dev, data);
- ret = put_user(data, (unsigned long __user *)buf);
- if (ret == 0)
- ret = sizeof(unsigned long);
+ if (sizeof (int) != sizeof (long) &&
+ count == sizeof (unsigned int))
+ ret = put_user(data, (unsigned int __user *)buf) ?:
+ sizeof(unsigned int);
+ else
+ ret = put_user(data, (unsigned long __user *)buf) ?:
+ sizeof(unsigned long);
}
return ret;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] RTC: rtc-dev tweak for 64-bit kernel
2006-04-28 16:25 [PATCH] RTC: rtc-dev tweak for 64-bit kernel Atsushi Nemoto
@ 2006-04-29 6:31 ` Andrew Morton
2006-04-29 13:56 ` Atsushi Nemoto
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2006-04-29 6:31 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: a.zummo, linux-kernel
Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
>
> Make rtc-dev more friendly to 64-bit platforms with 32-bit userland.
> This tweak is came from genrtc driver.
Please define "friendly". It's not clear what this patch does...
> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
>
> diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
> index b1e3e61..ae6adc4 100644
> --- a/drivers/rtc/rtc-dev.c
> +++ b/drivers/rtc/rtc-dev.c
> @@ -58,7 +58,7 @@ rtc_dev_read(struct file *file, char __u
> unsigned long data;
> ssize_t ret;
>
> - if (count < sizeof(unsigned long))
> + if (count != sizeof (unsigned int) && count < sizeof (unsigned long))
We normally omit the space between "sizeof" and "(".
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] RTC: rtc-dev tweak for 64-bit kernel
2006-04-29 6:31 ` Andrew Morton
@ 2006-04-29 13:56 ` Atsushi Nemoto
0 siblings, 0 replies; 3+ messages in thread
From: Atsushi Nemoto @ 2006-04-29 13:56 UTC (permalink / raw)
To: akpm; +Cc: a.zummo, linux-kernel
On Fri, 28 Apr 2006 23:31:52 -0700, Andrew Morton <akpm@osdl.org> wrote:
> > Make rtc-dev more friendly to 64-bit platforms with 32-bit userland.
> > This tweak is came from genrtc driver.
>
> Please define "friendly". It's not clear what this patch does...
...
>
> We normally omit the space between "sizeof" and "(".
Thanks for your comments. Here is an updated patch.
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>
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index b1e3e61..6c9ad92 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -58,7 +58,7 @@ rtc_dev_read(struct file *file, char __u
unsigned long data;
ssize_t ret;
- if (count < sizeof(unsigned long))
+ if (count != sizeof(unsigned int) && count < sizeof(unsigned long))
return -EINVAL;
add_wait_queue(&rtc->irq_queue, &wait);
@@ -90,11 +90,16 @@ rtc_dev_read(struct file *file, char __u
if (ret == 0) {
/* Check for any data updates */
if (rtc->ops->read_callback)
- data = rtc->ops->read_callback(rtc->class_dev.dev, data);
+ data = rtc->ops->read_callback(rtc->class_dev.dev,
+ data);
- ret = put_user(data, (unsigned long __user *)buf);
- if (ret == 0)
- ret = sizeof(unsigned long);
+ if (sizeof(int) != sizeof(long) &&
+ count == sizeof(unsigned int))
+ ret = put_user(data, (unsigned int __user *)buf) ?:
+ sizeof(unsigned int);
+ else
+ ret = put_user(data, (unsigned long __user *)buf) ?:
+ sizeof(unsigned long);
}
return ret;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-04-29 13:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-28 16:25 [PATCH] RTC: rtc-dev tweak for 64-bit kernel Atsushi Nemoto
2006-04-29 6:31 ` Andrew Morton
2006-04-29 13:56 ` Atsushi Nemoto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®