diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2016-05-06 13:19:42 -0400 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2016-05-13 19:40:01 -0400 |
commit | faca88273b68b71a15749e04037a4d7ee98fff2d (patch) | |
tree | 16ed1f6fc803daeb692929b1c1db4dd2e4f388be /drivers/infiniband/hw/nes/nes_utils.c | |
parent | aa70345369e251779c0372ef6dd2bd6325a3350c (diff) |
RDMA/nes: replace custom print_hex_dump()
There is no need to duplicate a lot of code that is in the kernel library for ages.
Replace duplicating code by calling to print_hex_dump() directly.
Note that output is slightly changed:
- hex and ascii parts have just two spaces delimeter
- there is no delimeter for ascii portions
- file and line removed from prefix (they were redundant anyway since previous
output shows same closer enough)
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/hw/nes/nes_utils.c')
-rw-r--r-- | drivers/infiniband/hw/nes/nes_utils.c | 60 |
1 files changed, 3 insertions, 57 deletions
diff --git a/drivers/infiniband/hw/nes/nes_utils.c b/drivers/infiniband/hw/nes/nes_utils.c index 6d3a169c049b..37331e2fdc5f 100644 --- a/drivers/infiniband/hw/nes/nes_utils.c +++ b/drivers/infiniband/hw/nes/nes_utils.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/ip.h> | 44 | #include <linux/ip.h> |
45 | #include <linux/tcp.h> | 45 | #include <linux/tcp.h> |
46 | #include <linux/init.h> | 46 | #include <linux/init.h> |
47 | #include <linux/kernel.h> | ||
47 | 48 | ||
48 | #include <asm/io.h> | 49 | #include <asm/io.h> |
49 | #include <asm/irq.h> | 50 | #include <asm/irq.h> |
@@ -903,70 +904,15 @@ void nes_clc(unsigned long parm) | |||
903 | */ | 904 | */ |
904 | void nes_dump_mem(unsigned int dump_debug_level, void *addr, int length) | 905 | void nes_dump_mem(unsigned int dump_debug_level, void *addr, int length) |
905 | { | 906 | { |
906 | char xlate[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', | ||
907 | 'a', 'b', 'c', 'd', 'e', 'f'}; | ||
908 | char *ptr; | ||
909 | char hex_buf[80]; | ||
910 | char ascii_buf[20]; | ||
911 | int num_char; | ||
912 | int num_ascii; | ||
913 | int num_hex; | ||
914 | |||
915 | if (!(nes_debug_level & dump_debug_level)) { | 907 | if (!(nes_debug_level & dump_debug_level)) { |
916 | return; | 908 | return; |
917 | } | 909 | } |
918 | 910 | ||
919 | ptr = addr; | ||
920 | if (length > 0x100) { | 911 | if (length > 0x100) { |
921 | nes_debug(dump_debug_level, "Length truncated from %x to %x\n", length, 0x100); | 912 | nes_debug(dump_debug_level, "Length truncated from %x to %x\n", length, 0x100); |
922 | length = 0x100; | 913 | length = 0x100; |
923 | } | 914 | } |
924 | nes_debug(dump_debug_level, "Address=0x%p, length=0x%x (%d)\n", ptr, length, length); | 915 | nes_debug(dump_debug_level, "Address=0x%p, length=0x%x (%d)\n", addr, length, length); |
925 | |||
926 | memset(ascii_buf, 0, 20); | ||
927 | memset(hex_buf, 0, 80); | ||
928 | |||
929 | num_ascii = 0; | ||
930 | num_hex = 0; | ||
931 | for (num_char = 0; num_char < length; num_char++) { | ||
932 | if (num_ascii == 8) { | ||
933 | ascii_buf[num_ascii++] = ' '; | ||
934 | hex_buf[num_hex++] = '-'; | ||
935 | hex_buf[num_hex++] = ' '; | ||
936 | } | ||
937 | |||
938 | if (*ptr < 0x20 || *ptr > 0x7e) | ||
939 | ascii_buf[num_ascii++] = '.'; | ||
940 | else | ||
941 | ascii_buf[num_ascii++] = *ptr; | ||
942 | hex_buf[num_hex++] = xlate[((*ptr & 0xf0) >> 4)]; | ||
943 | hex_buf[num_hex++] = xlate[*ptr & 0x0f]; | ||
944 | hex_buf[num_hex++] = ' '; | ||
945 | ptr++; | ||
946 | |||
947 | if (num_ascii >= 17) { | ||
948 | /* output line and reset */ | ||
949 | nes_debug(dump_debug_level, " %s | %s\n", hex_buf, ascii_buf); | ||
950 | memset(ascii_buf, 0, 20); | ||
951 | memset(hex_buf, 0, 80); | ||
952 | num_ascii = 0; | ||
953 | num_hex = 0; | ||
954 | } | ||
955 | } | ||
956 | 916 | ||
957 | /* output the rest */ | 917 | print_hex_dump(KERN_ERR, PFX, DUMP_PREFIX_NONE, 16, 1, addr, length, true); |
958 | if (num_ascii) { | ||
959 | while (num_ascii < 17) { | ||
960 | if (num_ascii == 8) { | ||
961 | hex_buf[num_hex++] = ' '; | ||
962 | hex_buf[num_hex++] = ' '; | ||
963 | } | ||
964 | hex_buf[num_hex++] = ' '; | ||
965 | hex_buf[num_hex++] = ' '; | ||
966 | hex_buf[num_hex++] = ' '; | ||
967 | num_ascii++; | ||
968 | } | ||
969 | |||
970 | nes_debug(dump_debug_level, " %s | %s\n", hex_buf, ascii_buf); | ||
971 | } | ||
972 | } | 918 | } |