Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 354049
b: refs/heads/master
c: 532572b
h: refs/heads/master
i:
  354047: da6a08e
v: v3
  • Loading branch information
John Stultz authored and Greg Kroah-Hartman committed Jan 18, 2013
1 parent 42bc983 commit 0b1db36
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cec8bb73a2c603034b04b5d56e16878d0b0ef2dd
refs/heads/master: 532572b94815e1ede5d9c5434ddb94835df4429e
35 changes: 35 additions & 0 deletions trunk/drivers/staging/android/alarm-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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 = {
Expand Down
19 changes: 19 additions & 0 deletions trunk/drivers/staging/android/android_alarm.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <linux/ioctl.h>
#include <linux/time.h>
#include <linux/compat.h>

enum android_alarm_type {
/* return code bit numbers or set alarm arg */
Expand Down Expand Up @@ -59,4 +60,22 @@ enum android_alarm_return_flags {
#define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0)))
#define ANDROID_ALARM_IOCTL_TO_TYPE(cmd) (_IOC_NR(cmd) >> 4)


#ifdef CONFIG_COMPAT
#define ANDROID_ALARM_SET_COMPAT(type) ALARM_IOW(2, type, \
struct compat_timespec)
#define ANDROID_ALARM_SET_AND_WAIT_COMPAT(type) ALARM_IOW(3, type, \
struct compat_timespec)
#define ANDROID_ALARM_GET_TIME_COMPAT(type) ALARM_IOW(4, type, \
struct compat_timespec)
#define ANDROID_ALARM_SET_RTC_COMPAT _IOW('a', 5, \
struct compat_timespec)
#define ANDROID_ALARM_IOCTL_NR(cmd) (_IOC_NR(cmd) & ((1<<4)-1))
#define ANDROID_ALARM_COMPAT_TO_NORM(cmd) \
ALARM_IOW(ANDROID_ALARM_IOCTL_NR(cmd), \
ANDROID_ALARM_IOCTL_TO_TYPE(cmd), \
struct timespec)

#endif

#endif

0 comments on commit 0b1db36

Please sign in to comment.