Commit 571d4a87 authored by Andi Kleen's avatar Andi Kleen Committed by David S. Miller

[PATCH] Minor 32bit compatibility fix for /dev/rtc

Handle both unsigned int and unsigned long in rtc_read. This helps
when running 32bit userland under an 64bit kernel.
parent 7197ce26
...@@ -279,7 +279,7 @@ static ssize_t rtc_read(struct file *file, char *buf, ...@@ -279,7 +279,7 @@ static ssize_t rtc_read(struct file *file, char *buf,
if (rtc_has_irq == 0) if (rtc_has_irq == 0)
return -EIO; return -EIO;
if (count < sizeof(unsigned long)) if (count < sizeof(unsigned))
return -EINVAL; return -EINVAL;
add_wait_queue(&rtc_wait, &wait); add_wait_queue(&rtc_wait, &wait);
...@@ -310,9 +310,10 @@ static ssize_t rtc_read(struct file *file, char *buf, ...@@ -310,9 +310,10 @@ static ssize_t rtc_read(struct file *file, char *buf,
schedule(); schedule();
} while (1); } while (1);
retval = put_user(data, (unsigned long *)buf); if (count < sizeof(unsigned long))
if (!retval) retval = put_user(data, (unsigned int *)buf) ?: sizeof(int);
retval = sizeof(unsigned long); else
retval = put_user(data, (unsigned long *)buf) ?: sizeof(long);
out: out:
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
remove_wait_queue(&rtc_wait, &wait); remove_wait_queue(&rtc_wait, &wait);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment