3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 return (v
< 10 ? '0' : 'a' - 10) + v
;
30 static char hex_print(u8 c
)
32 return (0x20 <= c
&& c
< 0x7f) ? c
: '.';
35 static void dump_line(const u8
*bytes
, size_t size
)
40 size
= size
<= 8 ? size
: 8;
41 printk(KERN_DEBUG
"zd1211 %p ", bytes
);
42 for (i
= 0; i
< 8; i
++) {
55 printk("%c%c%c", hex(bytes
[i
] >> 4), hex(bytes
[i
]), c
);
61 for (i
= 0; i
< size
; i
++)
62 printk("%c", hex_print(bytes
[i
]));
66 void zd_hexdump(const void *bytes
, size_t size
)
71 dump_line((u8
*)bytes
+ i
, size
-i
);
77 void *zd_tail(const void *buffer
, size_t buffer_size
, size_t tail_size
)
79 if (buffer_size
< tail_size
)
81 return (u8
*)buffer
+ (buffer_size
- tail_size
);