Commit df493935 authored by Dongdong Deng's avatar Dongdong Deng Committed by Jason Wessel

kgdb,x86: use macro HBP_NUM to replace magic number 4

Use the macros provided by the HW breakpoint API.
Signed-off-by: default avatarDongdong Deng <dongdong.deng@windriver.com>
Signed-off-by: default avatarJason Wessel <jason.wessel@windriver.com>
parent 7aeb48b7
...@@ -195,7 +195,7 @@ static struct hw_breakpoint { ...@@ -195,7 +195,7 @@ static struct hw_breakpoint {
int len; int len;
int type; int type;
struct perf_event **pev; struct perf_event **pev;
} breakinfo[4]; } breakinfo[HBP_NUM];
static unsigned long early_dr7; static unsigned long early_dr7;
...@@ -203,7 +203,7 @@ static void kgdb_correct_hw_break(void) ...@@ -203,7 +203,7 @@ static void kgdb_correct_hw_break(void)
{ {
int breakno; int breakno;
for (breakno = 0; breakno < 4; breakno++) { for (breakno = 0; breakno < HBP_NUM; breakno++) {
struct perf_event *bp; struct perf_event *bp;
struct arch_hw_breakpoint *info; struct arch_hw_breakpoint *info;
int val; int val;
...@@ -290,10 +290,10 @@ kgdb_remove_hw_break(unsigned long addr, int len, enum kgdb_bptype bptype) ...@@ -290,10 +290,10 @@ kgdb_remove_hw_break(unsigned long addr, int len, enum kgdb_bptype bptype)
{ {
int i; int i;
for (i = 0; i < 4; i++) for (i = 0; i < HBP_NUM; i++)
if (breakinfo[i].addr == addr && breakinfo[i].enabled) if (breakinfo[i].addr == addr && breakinfo[i].enabled)
break; break;
if (i == 4) if (i == HBP_NUM)
return -1; return -1;
if (hw_break_release_slot(i)) { if (hw_break_release_slot(i)) {
...@@ -311,7 +311,7 @@ static void kgdb_remove_all_hw_break(void) ...@@ -311,7 +311,7 @@ static void kgdb_remove_all_hw_break(void)
int cpu = raw_smp_processor_id(); int cpu = raw_smp_processor_id();
struct perf_event *bp; struct perf_event *bp;
for (i = 0; i < 4; i++) { for (i = 0; i < HBP_NUM; i++) {
if (!breakinfo[i].enabled) if (!breakinfo[i].enabled)
continue; continue;
bp = *per_cpu_ptr(breakinfo[i].pev, cpu); bp = *per_cpu_ptr(breakinfo[i].pev, cpu);
...@@ -331,10 +331,10 @@ kgdb_set_hw_break(unsigned long addr, int len, enum kgdb_bptype bptype) ...@@ -331,10 +331,10 @@ kgdb_set_hw_break(unsigned long addr, int len, enum kgdb_bptype bptype)
{ {
int i; int i;
for (i = 0; i < 4; i++) for (i = 0; i < HBP_NUM; i++)
if (!breakinfo[i].enabled) if (!breakinfo[i].enabled)
break; break;
if (i == 4) if (i == HBP_NUM)
return -1; return -1;
switch (bptype) { switch (bptype) {
...@@ -395,7 +395,7 @@ void kgdb_disable_hw_debug(struct pt_regs *regs) ...@@ -395,7 +395,7 @@ void kgdb_disable_hw_debug(struct pt_regs *regs)
/* Disable hardware debugging while we are in kgdb: */ /* Disable hardware debugging while we are in kgdb: */
set_debugreg(0UL, 7); set_debugreg(0UL, 7);
for (i = 0; i < 4; i++) { for (i = 0; i < HBP_NUM; i++) {
if (!breakinfo[i].enabled) if (!breakinfo[i].enabled)
continue; continue;
if (dbg_is_early) { if (dbg_is_early) {
...@@ -640,7 +640,7 @@ void kgdb_arch_late(void) ...@@ -640,7 +640,7 @@ void kgdb_arch_late(void)
attr.bp_len = HW_BREAKPOINT_LEN_1; attr.bp_len = HW_BREAKPOINT_LEN_1;
attr.bp_type = HW_BREAKPOINT_W; attr.bp_type = HW_BREAKPOINT_W;
attr.disabled = 1; attr.disabled = 1;
for (i = 0; i < 4; i++) { for (i = 0; i < HBP_NUM; i++) {
if (breakinfo[i].pev) if (breakinfo[i].pev)
continue; continue;
breakinfo[i].pev = register_wide_hw_breakpoint(&attr, NULL); breakinfo[i].pev = register_wide_hw_breakpoint(&attr, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment