Staging: hv: mousevsc: Cleanup alloc_input_device()
[zen-stable.git] / arch / tile / include / asm / syscall.h
blobd35e0dcb67b11a1d2b2a573dc4bc11f1bc14d5bf
1 /*
2 * Copyright (C) 2008-2009 Red Hat, Inc. All rights reserved.
3 * Copyright 2010 Tilera Corporation. All Rights Reserved.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation, version 2.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
12 * NON INFRINGEMENT. See the GNU General Public License for
13 * more details.
15 * See asm-generic/syscall.h for descriptions of what we must do here.
18 #ifndef _ASM_TILE_SYSCALL_H
19 #define _ASM_TILE_SYSCALL_H
21 #include <linux/sched.h>
22 #include <linux/err.h>
23 #include <arch/abi.h>
26 * Only the low 32 bits of orig_r0 are meaningful, so we return int.
27 * This importantly ignores the high bits on 64-bit, so comparisons
28 * sign-extend the low 32 bits.
30 static inline int syscall_get_nr(struct task_struct *t, struct pt_regs *regs)
32 return regs->regs[TREG_SYSCALL_NR];
35 static inline void syscall_rollback(struct task_struct *task,
36 struct pt_regs *regs)
38 regs->regs[0] = regs->orig_r0;
41 static inline long syscall_get_error(struct task_struct *task,
42 struct pt_regs *regs)
44 unsigned long error = regs->regs[0];
45 return IS_ERR_VALUE(error) ? error : 0;
48 static inline long syscall_get_return_value(struct task_struct *task,
49 struct pt_regs *regs)
51 return regs->regs[0];
54 static inline void syscall_set_return_value(struct task_struct *task,
55 struct pt_regs *regs,
56 int error, long val)
58 regs->regs[0] = (long) error ?: val;
61 static inline void syscall_get_arguments(struct task_struct *task,
62 struct pt_regs *regs,
63 unsigned int i, unsigned int n,
64 unsigned long *args)
66 BUG_ON(i + n > 6);
67 memcpy(args, &regs[i], n * sizeof(args[0]));
70 static inline void syscall_set_arguments(struct task_struct *task,
71 struct pt_regs *regs,
72 unsigned int i, unsigned int n,
73 const unsigned long *args)
75 BUG_ON(i + n > 6);
76 memcpy(&regs[i], args, n * sizeof(args[0]));
79 #endif /* _ASM_TILE_SYSCALL_H */