Skip to content

Commit 6bda768

Browse files
author
Al Viro
committed
nios2: switch to ->regset_get()
Signed-off-by: Al Viro <[email protected]>
1 parent 8320514 commit 6bda768

File tree

1 file changed

+15
-36
lines changed

1 file changed

+15
-36
lines changed

arch/nios2/kernel/ptrace.c

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,45 +21,24 @@
2121

2222
static int genregs_get(struct task_struct *target,
2323
const struct user_regset *regset,
24-
unsigned int pos, unsigned int count,
25-
void *kbuf, void __user *ubuf)
24+
struct membuf to)
2625
{
2726
const struct pt_regs *regs = task_pt_regs(target);
2827
const struct switch_stack *sw = (struct switch_stack *)regs - 1;
29-
int ret = 0;
30-
31-
#define REG_O_ZERO_RANGE(START, END) \
32-
if (!ret) \
33-
ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, \
34-
START * 4, (END * 4) + 4);
35-
36-
#define REG_O_ONE(PTR, LOC) \
37-
if (!ret) \
38-
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, PTR, \
39-
LOC * 4, (LOC * 4) + 4);
4028

41-
#define REG_O_RANGE(PTR, START, END) \
42-
if (!ret) \
43-
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, PTR, \
44-
START * 4, (END * 4) + 4);
45-
46-
REG_O_ZERO_RANGE(PTR_R0, PTR_R0);
47-
REG_O_RANGE(&regs->r1, PTR_R1, PTR_R7);
48-
REG_O_RANGE(&regs->r8, PTR_R8, PTR_R15);
49-
REG_O_RANGE(sw, PTR_R16, PTR_R23);
50-
REG_O_ZERO_RANGE(PTR_R24, PTR_R25); /* et and bt */
51-
REG_O_ONE(&regs->gp, PTR_GP);
52-
REG_O_ONE(&regs->sp, PTR_SP);
53-
REG_O_ONE(&regs->fp, PTR_FP);
54-
REG_O_ONE(&regs->ea, PTR_EA);
55-
REG_O_ZERO_RANGE(PTR_BA, PTR_BA);
56-
REG_O_ONE(&regs->ra, PTR_RA);
57-
REG_O_ONE(&regs->ea, PTR_PC); /* use ea for PC */
58-
if (!ret)
59-
ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
60-
PTR_STATUS * 4, -1);
61-
62-
return ret;
29+
membuf_zero(&to, 4); // R0
30+
membuf_write(&to, &regs->r1, 7 * 4); // R1..R7
31+
membuf_write(&to, &regs->r8, 8 * 4); // R8..R15
32+
membuf_write(&to, sw, 8 * 4); // R16..R23
33+
membuf_zero(&to, 2 * 4); /* et and bt */
34+
membuf_store(&to, regs->gp);
35+
membuf_store(&to, regs->sp);
36+
membuf_store(&to, regs->fp);
37+
membuf_store(&to, regs->ea);
38+
membuf_zero(&to, 4); // PTR_BA
39+
membuf_store(&to, regs->ra);
40+
membuf_store(&to, regs->ea); /* use ea for PC */
41+
return membuf_zero(&to, (NUM_PTRACE_REG - PTR_PC) * 4);
6342
}
6443

6544
/*
@@ -121,7 +100,7 @@ static const struct user_regset nios2_regsets[] = {
121100
.n = NUM_PTRACE_REG,
122101
.size = sizeof(unsigned long),
123102
.align = sizeof(unsigned long),
124-
.get = genregs_get,
103+
.regset_get = genregs_get,
125104
.set = genregs_set,
126105
}
127106
};

0 commit comments

Comments
 (0)