aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/android/alarm-dev.c
diff options
context:
space:
mode:
authorJohn Stultz <john.stultz@linaro.org>2013-01-11 15:46:24 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-18 12:37:11 -0800
commit532572b94815e1ede5d9c5434ddb94835df4429e (patch)
tree0475f48d2f44ba5a08865632c7c81cb18a63160f /drivers/staging/android/alarm-dev.c
parentstaging: alarm-dev: Refactor alarm-dev ioctl code in prep for compat_ioctl (diff)
downloadlinux-dev-532572b94815e1ede5d9c5434ddb94835df4429e.tar.xz
linux-dev-532572b94815e1ede5d9c5434ddb94835df4429e.zip
staging: alarm-dev: Implement compat_ioctl support
Implement compat_ioctl support for the alarm-dev ioctl. Cc: Serban Constantinescu <serban.constantinescu@arm.com> Cc: Arve Hjønnevåg <arve@android.com> Cc: Colin Cross <ccross@google.com> Cc: Android Kernel Team <kernel-team@android.com> Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/android/alarm-dev.c')
-rw-r--r--drivers/staging/android/alarm-dev.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/staging/android/alarm-dev.c b/drivers/staging/android/alarm-dev.c
index 43af3b36d4cb..ceb1c643753d 100644
--- a/drivers/staging/android/alarm-dev.c
+++ b/drivers/staging/android/alarm-dev.c
@@ -274,6 +274,38 @@ static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return rv;
}
+#ifdef CONFIG_COMPAT
+static long alarm_compat_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
+{
+
+ struct timespec ts;
+ int rv;
+
+ switch (ANDROID_ALARM_BASE_CMD(cmd)) {
+ case ANDROID_ALARM_SET_AND_WAIT_COMPAT(0):
+ case ANDROID_ALARM_SET_COMPAT(0):
+ case ANDROID_ALARM_SET_RTC_COMPAT:
+ if (compat_get_timespec(&ts, (void __user *)arg))
+ return -EFAULT;
+ /* fall through */
+ case ANDROID_ALARM_GET_TIME_COMPAT(0):
+ cmd = ANDROID_ALARM_COMPAT_TO_NORM(cmd);
+ break;
+ }
+
+ rv = alarm_do_ioctl(file, cmd, &ts);
+
+ switch (ANDROID_ALARM_BASE_CMD(cmd)) {
+ case ANDROID_ALARM_GET_TIME(0): /* NOTE: we modified cmd above */
+ if (compat_put_timespec(&ts, (void __user *)arg))
+ return -EFAULT;
+ break;
+ }
+
+ return rv;
+}
+#endif
static int alarm_open(struct inode *inode, struct file *file)
{
@@ -355,6 +387,9 @@ static const struct file_operations alarm_fops = {
.unlocked_ioctl = alarm_ioctl,
.open = alarm_open,
.release = alarm_release,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = alarm_compat_ioctl,
+#endif
};
static struct miscdevice alarm_device = {