diff options
| author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2013-03-27 01:54:14 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2013-03-27 12:48:33 -0400 |
| commit | 167bfa71844a7a7415da0fa8c75e672f3bd438c8 (patch) | |
| tree | 20d492fd7588c78f3f870336bb7f8c7c9905554a /drivers/net/ppp | |
| parent | 5a048e3b59fb4211b7978f78217878071c344379 (diff) | |
ppp: reuse print_hex_dump_bytes
There is a native function to dump hex buffers.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ppp')
| -rw-r--r-- | drivers/net/ppp/ppp_synctty.c | 53 |
1 files changed, 2 insertions, 51 deletions
diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c index 1a12033d2efa..090c834d7dbd 100644 --- a/drivers/net/ppp/ppp_synctty.c +++ b/drivers/net/ppp/ppp_synctty.c | |||
| @@ -105,64 +105,15 @@ static const struct ppp_channel_ops sync_ops = { | |||
| 105 | }; | 105 | }; |
| 106 | 106 | ||
| 107 | /* | 107 | /* |
| 108 | * Utility procedures to print a buffer in hex/ascii | 108 | * Utility procedure to print a buffer in hex/ascii |
| 109 | */ | 109 | */ |
| 110 | static void | 110 | static void |
| 111 | ppp_print_hex (register __u8 * out, const __u8 * in, int count) | ||
| 112 | { | ||
| 113 | register __u8 next_ch; | ||
| 114 | static const char hex[] = "0123456789ABCDEF"; | ||
| 115 | |||
| 116 | while (count-- > 0) { | ||
| 117 | next_ch = *in++; | ||
| 118 | *out++ = hex[(next_ch >> 4) & 0x0F]; | ||
| 119 | *out++ = hex[next_ch & 0x0F]; | ||
| 120 | ++out; | ||
| 121 | } | ||
| 122 | } | ||
| 123 | |||
| 124 | static void | ||
| 125 | ppp_print_char (register __u8 * out, const __u8 * in, int count) | ||
| 126 | { | ||
| 127 | register __u8 next_ch; | ||
| 128 | |||
| 129 | while (count-- > 0) { | ||
| 130 | next_ch = *in++; | ||
| 131 | |||
| 132 | if (next_ch < 0x20 || next_ch > 0x7e) | ||
| 133 | *out++ = '.'; | ||
| 134 | else { | ||
| 135 | *out++ = next_ch; | ||
| 136 | if (next_ch == '%') /* printk/syslogd has a bug !! */ | ||
| 137 | *out++ = '%'; | ||
| 138 | } | ||
| 139 | } | ||
| 140 | *out = '\0'; | ||
| 141 | } | ||
| 142 | |||
| 143 | static void | ||
| 144 | ppp_print_buffer (const char *name, const __u8 *buf, int count) | 111 | ppp_print_buffer (const char *name, const __u8 *buf, int count) |
| 145 | { | 112 | { |
| 146 | __u8 line[44]; | ||
| 147 | |||
| 148 | if (name != NULL) | 113 | if (name != NULL) |
| 149 | printk(KERN_DEBUG "ppp_synctty: %s, count = %d\n", name, count); | 114 | printk(KERN_DEBUG "ppp_synctty: %s, count = %d\n", name, count); |
| 150 | 115 | ||
| 151 | while (count > 8) { | 116 | print_hex_dump_bytes("", DUMP_PREFIX_NONE, buf, count); |
| 152 | memset (line, 32, 44); | ||
| 153 | ppp_print_hex (line, buf, 8); | ||
| 154 | ppp_print_char (&line[8 * 3], buf, 8); | ||
| 155 | printk(KERN_DEBUG "%s\n", line); | ||
| 156 | count -= 8; | ||
| 157 | buf += 8; | ||
| 158 | } | ||
| 159 | |||
| 160 | if (count > 0) { | ||
| 161 | memset (line, 32, 44); | ||
| 162 | ppp_print_hex (line, buf, count); | ||
| 163 | ppp_print_char (&line[8 * 3], buf, count); | ||
| 164 | printk(KERN_DEBUG "%s\n", line); | ||
| 165 | } | ||
| 166 | } | 117 | } |
| 167 | 118 | ||
| 168 | 119 | ||
