aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-06-04 13:28:16 -0400
committerMike Frysinger <vapier@gentoo.org>2009-06-12 06:12:06 -0400
commit11aca0e7352b6a28193221cd2dd85f758fb71b23 (patch)
treed9c502423099ba27cd88ac39a52492bfe62a70f6 /arch/blackfin
parenta43b739f257fd2569e11c6c93fbb86df382848e9 (diff)
Blackfin: kgdb: fix up error return values
The Blackfin kgdb code was all passing back positive errno values when it really should have been using negative errno values. Reported-by: Roel Kluin <roel.kluin@gmail.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch/blackfin')
-rw-r--r--arch/blackfin/kernel/kgdb.c55
1 files changed, 30 insertions, 25 deletions
diff --git a/arch/blackfin/kernel/kgdb.c b/arch/blackfin/kernel/kgdb.c
index b163f6d3330d..c5362b2b9ed1 100644
--- a/arch/blackfin/kernel/kgdb.c
+++ b/arch/blackfin/kernel/kgdb.c
@@ -466,7 +466,7 @@ static int validate_memory_access_address(unsigned long addr, int size)
466 int cpu = raw_smp_processor_id(); 466 int cpu = raw_smp_processor_id();
467 467
468 if (size < 0) 468 if (size < 0)
469 return EFAULT; 469 return -EFAULT;
470 if (addr >= 0x1000 && (addr + size) <= physical_mem_end) 470 if (addr >= 0x1000 && (addr + size) <= physical_mem_end)
471 return 0; 471 return 0;
472 if (addr >= SYSMMR_BASE) 472 if (addr >= SYSMMR_BASE)
@@ -498,7 +498,7 @@ static int validate_memory_access_address(unsigned long addr, int size)
498 if (IN_MEM(addr, size, L2_START, L2_LENGTH)) 498 if (IN_MEM(addr, size, L2_START, L2_LENGTH))
499 return 0; 499 return 0;
500 500
501 return EFAULT; 501 return -EFAULT;
502} 502}
503 503
504/* 504/*
@@ -508,14 +508,15 @@ static int validate_memory_access_address(unsigned long addr, int size)
508int kgdb_mem2hex(char *mem, char *buf, int count) 508int kgdb_mem2hex(char *mem, char *buf, int count)
509{ 509{
510 char *tmp; 510 char *tmp;
511 int err = 0; 511 int err;
512 unsigned char *pch; 512 unsigned char *pch;
513 unsigned short mmr16; 513 unsigned short mmr16;
514 unsigned long mmr32; 514 unsigned long mmr32;
515 int cpu = raw_smp_processor_id(); 515 int cpu = raw_smp_processor_id();
516 516
517 if (validate_memory_access_address((unsigned long)mem, count)) 517 err = validate_memory_access_address((unsigned long)mem, count);
518 return EFAULT; 518 if (err)
519 return err;
519 520
520 /* 521 /*
521 * We use the upper half of buf as an intermediate buffer for the 522 * We use the upper half of buf as an intermediate buffer for the
@@ -533,7 +534,7 @@ int kgdb_mem2hex(char *mem, char *buf, int count)
533 *tmp++ = *pch++; 534 *tmp++ = *pch++;
534 tmp -= 2; 535 tmp -= 2;
535 } else 536 } else
536 err = EFAULT; 537 err = -EFAULT;
537 break; 538 break;
538 case 4: 539 case 4:
539 if ((unsigned int)mem % 4 == 0) { 540 if ((unsigned int)mem % 4 == 0) {
@@ -545,10 +546,10 @@ int kgdb_mem2hex(char *mem, char *buf, int count)
545 *tmp++ = *pch++; 546 *tmp++ = *pch++;
546 tmp -= 4; 547 tmp -= 4;
547 } else 548 } else
548 err = EFAULT; 549 err = -EFAULT;
549 break; 550 break;
550 default: 551 default:
551 err = EFAULT; 552 err = -EFAULT;
552 } 553 }
553 } else if ((cpu == 0 && IN_MEM(mem, count, L1_CODE_START, L1_CODE_LENGTH)) 554 } else if ((cpu == 0 && IN_MEM(mem, count, L1_CODE_START, L1_CODE_LENGTH))
554#ifdef CONFIG_SMP 555#ifdef CONFIG_SMP
@@ -557,7 +558,7 @@ int kgdb_mem2hex(char *mem, char *buf, int count)
557 ) { 558 ) {
558 /* access L1 instruction SRAM*/ 559 /* access L1 instruction SRAM*/
559 if (dma_memcpy(tmp, mem, count) == NULL) 560 if (dma_memcpy(tmp, mem, count) == NULL)
560 err = EFAULT; 561 err = -EFAULT;
561 } else 562 } else
562 err = probe_kernel_read(tmp, mem, count); 563 err = probe_kernel_read(tmp, mem, count);
563 564
@@ -585,7 +586,7 @@ int kgdb_ebin2mem(char *buf, char *mem, int count)
585 char *tmp_new; 586 char *tmp_new;
586 unsigned short *mmr16; 587 unsigned short *mmr16;
587 unsigned long *mmr32; 588 unsigned long *mmr32;
588 int err = 0; 589 int err;
589 int size = 0; 590 int size = 0;
590 int cpu = raw_smp_processor_id(); 591 int cpu = raw_smp_processor_id();
591 592
@@ -601,8 +602,9 @@ int kgdb_ebin2mem(char *buf, char *mem, int count)
601 size++; 602 size++;
602 } 603 }
603 604
604 if (validate_memory_access_address((unsigned long)mem, size)) 605 err = validate_memory_access_address((unsigned long)mem, size);
605 return EFAULT; 606 if (err)
607 return err;
606 608
607 if ((unsigned int)mem >= SYSMMR_BASE) { /*access MMR registers*/ 609 if ((unsigned int)mem >= SYSMMR_BASE) { /*access MMR registers*/
608 switch (size) { 610 switch (size) {
@@ -611,17 +613,17 @@ int kgdb_ebin2mem(char *buf, char *mem, int count)
611 mmr16 = (unsigned short *)buf; 613 mmr16 = (unsigned short *)buf;
612 *(unsigned short *)mem = *mmr16; 614 *(unsigned short *)mem = *mmr16;
613 } else 615 } else
614 return EFAULT; 616 err = -EFAULT;
615 break; 617 break;
616 case 4: 618 case 4:
617 if ((unsigned int)mem % 4 == 0) { 619 if ((unsigned int)mem % 4 == 0) {
618 mmr32 = (unsigned long *)buf; 620 mmr32 = (unsigned long *)buf;
619 *(unsigned long *)mem = *mmr32; 621 *(unsigned long *)mem = *mmr32;
620 } else 622 } else
621 return EFAULT; 623 err = -EFAULT;
622 break; 624 break;
623 default: 625 default:
624 return EFAULT; 626 err = -EFAULT;
625 } 627 }
626 } else if ((cpu == 0 && IN_MEM(mem, count, L1_CODE_START, L1_CODE_LENGTH)) 628 } else if ((cpu == 0 && IN_MEM(mem, count, L1_CODE_START, L1_CODE_LENGTH))
627#ifdef CONFIG_SMP 629#ifdef CONFIG_SMP
@@ -630,7 +632,7 @@ int kgdb_ebin2mem(char *buf, char *mem, int count)
630 ) { 632 ) {
631 /* access L1 instruction SRAM */ 633 /* access L1 instruction SRAM */
632 if (dma_memcpy(mem, buf, size) == NULL) 634 if (dma_memcpy(mem, buf, size) == NULL)
633 err = EFAULT; 635 err = -EFAULT;
634 } else 636 } else
635 err = probe_kernel_write(mem, buf, size); 637 err = probe_kernel_write(mem, buf, size);
636 638
@@ -648,10 +650,12 @@ int kgdb_hex2mem(char *buf, char *mem, int count)
648 char *tmp_hex; 650 char *tmp_hex;
649 unsigned short *mmr16; 651 unsigned short *mmr16;
650 unsigned long *mmr32; 652 unsigned long *mmr32;
653 int err;
651 int cpu = raw_smp_processor_id(); 654 int cpu = raw_smp_processor_id();
652 655
653 if (validate_memory_access_address((unsigned long)mem, count)) 656 err = validate_memory_access_address((unsigned long)mem, count);
654 return EFAULT; 657 if (err)
658 return err;
655 659
656 /* 660 /*
657 * We use the upper half of buf as an intermediate buffer for the 661 * We use the upper half of buf as an intermediate buffer for the
@@ -673,17 +677,17 @@ int kgdb_hex2mem(char *buf, char *mem, int count)
673 mmr16 = (unsigned short *)tmp_raw; 677 mmr16 = (unsigned short *)tmp_raw;
674 *(unsigned short *)mem = *mmr16; 678 *(unsigned short *)mem = *mmr16;
675 } else 679 } else
676 return EFAULT; 680 err = -EFAULT;
677 break; 681 break;
678 case 4: 682 case 4:
679 if ((unsigned int)mem % 4 == 0) { 683 if ((unsigned int)mem % 4 == 0) {
680 mmr32 = (unsigned long *)tmp_raw; 684 mmr32 = (unsigned long *)tmp_raw;
681 *(unsigned long *)mem = *mmr32; 685 *(unsigned long *)mem = *mmr32;
682 } else 686 } else
683 return EFAULT; 687 err = -EFAULT;
684 break; 688 break;
685 default: 689 default:
686 return EFAULT; 690 err = -EFAULT;
687 } 691 }
688 } else if ((cpu == 0 && IN_MEM(mem, count, L1_CODE_START, L1_CODE_LENGTH)) 692 } else if ((cpu == 0 && IN_MEM(mem, count, L1_CODE_START, L1_CODE_LENGTH))
689#ifdef CONFIG_SMP 693#ifdef CONFIG_SMP
@@ -692,10 +696,11 @@ int kgdb_hex2mem(char *buf, char *mem, int count)
692 ) { 696 ) {
693 /* access L1 instruction SRAM */ 697 /* access L1 instruction SRAM */
694 if (dma_memcpy(mem, tmp_raw, count) == NULL) 698 if (dma_memcpy(mem, tmp_raw, count) == NULL)
695 return EFAULT; 699 err = -EFAULT;
696 } else 700 } else
697 return probe_kernel_write(mem, tmp_raw, count); 701 err = probe_kernel_write(mem, tmp_raw, count);
698 return 0; 702
703 return err;
699} 704}
700 705
701int kgdb_validate_break_address(unsigned long addr) 706int kgdb_validate_break_address(unsigned long addr)
@@ -715,7 +720,7 @@ int kgdb_validate_break_address(unsigned long addr)
715 if (IN_MEM(addr, BREAK_INSTR_SIZE, L2_START, L2_LENGTH)) 720 if (IN_MEM(addr, BREAK_INSTR_SIZE, L2_START, L2_LENGTH))
716 return 0; 721 return 0;
717 722
718 return EFAULT; 723 return -EFAULT;
719} 724}
720 725
721int kgdb_arch_set_breakpoint(unsigned long addr, char *saved_instr) 726int kgdb_arch_set_breakpoint(unsigned long addr, char *saved_instr)