Lines Matching +full:8 +full:- +full:ch
1 // SPDX-License-Identifier: GPL-2.0-only
20 * hex_to_bin - convert a hex digit to its real value
21 * @ch: ascii character represents hex digit
23 * hex_to_bin() converts one hex digit to its actual value or -1 in case of bad
30 * (ch - '9' - 1) is negative if ch <= '9'
31 * ('0' - 1 - ch) is negative if ch >= '0'
32 * we "and" these two values, so the result is negative if ch is in the range
34 * we are only interested in the sign, so we do a shift ">> 8"; note that right
35 * shift of a negative value is implementation-defined, so we cast the
36 * value to (unsigned) before the shift --- we have 0xffffff if ch is in
38 * we "and" this value with (ch - '0' + 1) --- we have a value 1 ... 10 if ch is
40 * we add this value to -1 --- we have a value 0 ... 9 if ch is in the range '0'
41 * ... '9', -1 otherwise
43 * uppercase and lowercase letters, so we use (ch & 0xdf), which converts
46 int hex_to_bin(unsigned char ch) in hex_to_bin() argument
48 unsigned char cu = ch & 0xdf; in hex_to_bin()
49 return -1 + in hex_to_bin()
50 ((ch - '0' + 1) & (unsigned)((ch - '9' - 1) & ('0' - 1 - ch)) >> 8) + in hex_to_bin()
51 ((cu - 'A' + 11) & (unsigned)((cu - 'F' - 1) & ('A' - 1 - cu)) >> 8); in hex_to_bin()
56 * hex2bin - convert an ascii hexadecimal string to its binary representation
61 * Return 0 on success, -EINVAL in case of bad input.
65 while (count--) { in hex2bin()
70 return -EINVAL; in hex2bin()
73 return -EINVAL; in hex2bin()
82 * bin2hex - convert binary data to an ascii hexadecimal string
91 while (count--) in bin2hex()
98 * hex_dump_to_buffer - convert a blob of data to "hex ASCII" in memory
102 * @groupsize: number of bytes to print at a time (1, 2, 4, 8; default = 1)
112 * The converted output is always NUL-terminated.
115 * hex_dump_to_buffer(frame->data, frame->len, 16, 1,
132 u8 ch; in hex_dump_to_buffer() local
142 if (!is_power_of_2(groupsize) || groupsize > 8) in hex_dump_to_buffer()
156 if (groupsize == 8) { in hex_dump_to_buffer()
160 ret = snprintf(linebuf + lx, linebuflen - lx, in hex_dump_to_buffer()
163 if (ret >= linebuflen - lx) in hex_dump_to_buffer()
171 ret = snprintf(linebuf + lx, linebuflen - lx, in hex_dump_to_buffer()
174 if (ret >= linebuflen - lx) in hex_dump_to_buffer()
182 ret = snprintf(linebuf + lx, linebuflen - lx, in hex_dump_to_buffer()
185 if (ret >= linebuflen - lx) in hex_dump_to_buffer()
193 ch = ptr[j]; in hex_dump_to_buffer()
194 linebuf[lx++] = hex_asc_hi(ch); in hex_dump_to_buffer()
197 linebuf[lx++] = hex_asc_lo(ch); in hex_dump_to_buffer()
203 lx--; in hex_dump_to_buffer()
216 ch = ptr[j]; in hex_dump_to_buffer()
217 linebuf[lx++] = (isascii(ch) && isprint(ch)) ? ch : '.'; in hex_dump_to_buffer()
225 return ascii ? ascii_column + len : (groupsize * 2 + 1) * ngroups - 1; in hex_dump_to_buffer()
231 * print_hex_dump - print a text hex dump to syslog for a binary blob of data
238 * @groupsize: number of bytes to print at a time (1, 2, 4, 8; default = 1)
254 * 16, 1, frame->data, frame->len, true);
256 * Example output using %DUMP_PREFIX_OFFSET and 1-byte mode:
258 * Example output using %DUMP_PREFIX_ADDRESS and 4-byte mode:
274 remaining -= rowsize; in print_hex_dump()
285 printk("%s%s%.8x: %s\n", level, prefix_str, i, linebuf); in print_hex_dump()