aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2013-07-08 19:01:03 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-09 13:33:26 -0400
commit61e305c716c0737c97bd133313cc90e99a93712e (patch)
treee4c37ce9d33c3a63b2c70e851f55eb7e52b4bd88
parentb87a95ad609619482df0690320d5ace33ace8e7a (diff)
ptrace/x86: cleanup ptrace_set_debugreg()
ptrace_set_debugreg() is trivial but looks horrible. Kill the unnecessary goto's and return's to cleanup the code. This matches ptrace_get_debugreg() which also needs the trivial whitespace cleanups. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jan Kratochvil <jan.kratochvil@redhat.com> Cc: Michael Neuling <mikey@neuling.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Paul Mundt <lethal@linux-sh.org> Cc: Will Deacon <will.deacon@arm.com> Cc: Prasad <prasad@linux.vnet.ibm.com> Cc: Russell King <linux@arm.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/x86/kernel/ptrace.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 5c387b3dce3f..7461f50d5bb1 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -703,7 +703,7 @@ restore:
703 */ 703 */
704static unsigned long ptrace_get_debugreg(struct task_struct *tsk, int n) 704static unsigned long ptrace_get_debugreg(struct task_struct *tsk, int n)
705{ 705{
706 struct thread_struct *thread = &(tsk->thread); 706 struct thread_struct *thread = &tsk->thread;
707 unsigned long val = 0; 707 unsigned long val = 0;
708 708
709 if (n < HBP_NUM) { 709 if (n < HBP_NUM) {
@@ -713,7 +713,7 @@ static unsigned long ptrace_get_debugreg(struct task_struct *tsk, int n)
713 val = bp->hw.info.address; 713 val = bp->hw.info.address;
714 } else if (n == 6) { 714 } else if (n == 6) {
715 val = thread->debugreg6; 715 val = thread->debugreg6;
716 } else if (n == 7) { 716 } else if (n == 7) {
717 val = thread->ptrace_dr7; 717 val = thread->ptrace_dr7;
718 } 718 }
719 return val; 719 return val;
@@ -761,30 +761,20 @@ static int ptrace_set_breakpoint_addr(struct task_struct *tsk, int nr,
761static int ptrace_set_debugreg(struct task_struct *tsk, int n, 761static int ptrace_set_debugreg(struct task_struct *tsk, int n,
762 unsigned long val) 762 unsigned long val)
763{ 763{
764 struct thread_struct *thread = &(tsk->thread); 764 struct thread_struct *thread = &tsk->thread;
765 int rc = 0;
766
767 /* There are no DR4 or DR5 registers */ 765 /* There are no DR4 or DR5 registers */
768 if (n == 4 || n == 5) 766 int rc = -EIO;
769 return -EIO;
770 767
771 if (n == 6) {
772 thread->debugreg6 = val;
773 goto ret_path;
774 }
775 if (n < HBP_NUM) { 768 if (n < HBP_NUM) {
776 rc = ptrace_set_breakpoint_addr(tsk, n, val); 769 rc = ptrace_set_breakpoint_addr(tsk, n, val);
777 if (rc) 770 } else if (n == 6) {
778 return rc; 771 thread->debugreg6 = val;
779 } 772 rc = 0;
780 /* All that's left is DR7 */ 773 } else if (n == 7) {
781 if (n == 7) {
782 rc = ptrace_write_dr7(tsk, val); 774 rc = ptrace_write_dr7(tsk, val);
783 if (!rc) 775 if (!rc)
784 thread->ptrace_dr7 = val; 776 thread->ptrace_dr7 = val;
785 } 777 }
786
787ret_path:
788 return rc; 778 return rc;
789} 779}
790 780