Lines Matching full:spec
458 struct printf_spec spec) in number() argument
464 int need_pfx = ((spec.flags & SPECIAL) && spec.base != 10); in number()
467 int field_width = spec.field_width; in number()
468 int precision = spec.precision; in number()
472 locase = (spec.flags & SMALL); in number()
473 if (spec.flags & LEFT) in number()
474 spec.flags &= ~ZEROPAD; in number()
476 if (spec.flags & SIGN) { in number()
481 } else if (spec.flags & PLUS) { in number()
484 } else if (spec.flags & SPACE) { in number()
490 if (spec.base == 16) in number()
498 if (num < spec.base) in number()
500 else if (spec.base != 10) { /* 8 or 16 */ in number()
501 int mask = spec.base - 1; in number()
504 if (spec.base == 16) in number()
519 if (!(spec.flags & (ZEROPAD | LEFT))) { in number()
534 if (spec.base == 16 || !is_zero) { in number()
539 if (spec.base == 16) { in number()
546 if (!(spec.flags & LEFT)) { in number()
547 char c = ' ' + (spec.flags & ZEROPAD); in number()
580 struct printf_spec spec; in special_hex_number() local
582 spec.type = FORMAT_TYPE_PTR; in special_hex_number()
583 spec.field_width = 2 + 2 * size; /* 0x + hex */ in special_hex_number()
584 spec.flags = SPECIAL | SMALL | ZEROPAD; in special_hex_number()
585 spec.base = 16; in special_hex_number()
586 spec.precision = -1; in special_hex_number()
588 return number(buf, end, num, spec); in special_hex_number()
614 * @spec: for field width and flags
618 char *widen_string(char *buf, int n, char *end, struct printf_spec spec) in widen_string() argument
622 if (likely(n >= spec.field_width)) in widen_string()
625 spaces = spec.field_width - n; in widen_string()
626 if (!(spec.flags & LEFT)) { in widen_string()
640 struct printf_spec spec) in string_nocheck() argument
643 int lim = spec.precision; in string_nocheck()
654 return widen_string(buf, len, end, spec); in string_nocheck()
658 struct printf_spec spec) in err_ptr() argument
664 return string_nocheck(buf, end, sym, spec); in err_ptr()
671 spec.flags |= SIGN; in err_ptr()
672 spec.base = 10; in err_ptr()
673 return number(buf, end, err, spec); in err_ptr()
678 struct printf_spec spec) in error_string() argument
685 if (spec.precision == -1) in error_string()
686 spec.precision = 2 * sizeof(void *); in error_string()
688 return string_nocheck(buf, end, s, spec); in error_string()
708 struct printf_spec spec) in check_pointer() argument
714 *buf = error_string(*buf, end, err_msg, spec); in check_pointer()
723 struct printf_spec spec) in string() argument
725 if (check_pointer(&buf, end, s, spec)) in string()
728 return string_nocheck(buf, end, s, spec); in string()
733 struct printf_spec spec) in pointer_string() argument
735 spec.base = 16; in pointer_string()
736 spec.flags |= SMALL; in pointer_string()
737 if (spec.field_width == -1) { in pointer_string()
738 spec.field_width = 2 * sizeof(ptr); in pointer_string()
739 spec.flags |= ZEROPAD; in pointer_string()
742 return number(buf, end, (unsigned long int)ptr, spec); in pointer_string()
808 struct printf_spec spec) in ptr_to_id() argument
819 return pointer_string(buf, end, ptr, spec); in ptr_to_id()
824 return pointer_string(buf, end, (const void *)hashval, spec); in ptr_to_id()
829 spec.field_width = 2 * sizeof(ptr); in ptr_to_id()
831 return error_string(buf, end, str, spec); in ptr_to_id()
834 return pointer_string(buf, end, (const void *)hashval, spec); in ptr_to_id()
838 struct printf_spec spec) in default_pointer() argument
845 return pointer_string(buf, end, ptr, spec); in default_pointer()
847 return ptr_to_id(buf, end, ptr, spec); in default_pointer()
854 struct printf_spec spec) in restricted_pointer() argument
859 return default_pointer(buf, end, ptr, spec); in restricted_pointer()
868 if (spec.field_width == -1) in restricted_pointer()
869 spec.field_width = 2 * sizeof(ptr); in restricted_pointer()
870 return error_string(buf, end, "pK-error", spec); in restricted_pointer()
896 return pointer_string(buf, end, ptr, spec); in restricted_pointer()
900 char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_spec spec, in dentry_name() argument
918 if (check_pointer(&buf, end, d, spec)) { in dentry_name()
933 for (n = 0; n != spec.precision; n++, buf++) { in dentry_name()
945 return widen_string(buf, n, end, spec); in dentry_name()
950 struct printf_spec spec, const char *fmt) in file_dentry_name() argument
952 if (check_pointer(&buf, end, f, spec)) in file_dentry_name()
955 return dentry_name(buf, end, f->f_path.dentry, spec, fmt); in file_dentry_name()
960 struct printf_spec spec, const char *fmt) in bdev_name() argument
964 if (check_pointer(&buf, end, bdev, spec)) in bdev_name()
968 buf = string(buf, end, hd->disk_name, spec); in bdev_name()
975 buf = number(buf, end, bdev->bd_partno, spec); in bdev_name()
983 struct printf_spec spec, const char *fmt) in symbol_string() argument
1006 return string_nocheck(buf, end, sym, spec); in symbol_string()
1044 struct printf_spec spec, const char *fmt) in resource_string() argument
1090 if (check_pointer(&buf, end, res, spec)) in resource_string()
1140 return string_nocheck(buf, end, sym, spec); in resource_string()
1144 char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec, in hex_string() argument
1151 if (spec.field_width == 0) in hex_string()
1155 if (check_pointer(&buf, end, addr, spec)) in hex_string()
1173 if (spec.field_width > 0) in hex_string()
1174 len = min_t(int, spec.field_width, 64); in hex_string()
1196 struct printf_spec spec, const char *fmt) in bitmap_string() argument
1199 int nr_bits = max_t(int, spec.field_width, 0); in bitmap_string()
1203 if (check_pointer(&buf, end, bitmap, spec)) in bitmap_string()
1207 spec = (struct printf_spec){ .flags = SMALL | ZEROPAD, .base = 16 }; in bitmap_string()
1230 spec.field_width = DIV_ROUND_UP(chunksz, 4); in bitmap_string()
1231 buf = number(buf, end, val, spec); in bitmap_string()
1240 struct printf_spec spec, const char *fmt) in bitmap_list_string() argument
1242 int nr_bits = max_t(int, spec.field_width, 0); in bitmap_list_string()
1246 if (check_pointer(&buf, end, bitmap, spec)) in bitmap_list_string()
1270 struct printf_spec spec, const char *fmt) in mac_address_string() argument
1278 if (check_pointer(&buf, end, addr, spec)) in mac_address_string()
1306 return string_nocheck(buf, end, mac_addr, spec); in mac_address_string()
1460 struct printf_spec spec, const char *fmt) in ip6_addr_string() argument
1469 return string_nocheck(buf, end, ip6_addr, spec); in ip6_addr_string()
1474 struct printf_spec spec, const char *fmt) in ip4_addr_string() argument
1480 return string_nocheck(buf, end, ip4_addr, spec); in ip4_addr_string()
1485 struct printf_spec spec, const char *fmt) in ip6_addr_string_sa() argument
1529 p = number(p, pend, ntohs(sa->sin6_port), spec); in ip6_addr_string_sa()
1534 IPV6_FLOWINFO_MASK), spec); in ip6_addr_string_sa()
1538 p = number(p, pend, sa->sin6_scope_id, spec); in ip6_addr_string_sa()
1542 return string_nocheck(buf, end, ip6_addr, spec); in ip6_addr_string_sa()
1547 struct printf_spec spec, const char *fmt) in ip4_addr_string_sa() argument
1573 p = number(p, pend, ntohs(sa->sin_port), spec); in ip4_addr_string_sa()
1577 return string_nocheck(buf, end, ip4_addr, spec); in ip4_addr_string_sa()
1582 struct printf_spec spec, const char *fmt) in ip_addr_string() argument
1586 if (check_pointer(&buf, end, ptr, spec)) in ip_addr_string()
1591 return ip6_addr_string(buf, end, ptr, spec, fmt); in ip_addr_string()
1593 return ip4_addr_string(buf, end, ptr, spec, fmt); in ip_addr_string()
1603 return ip4_addr_string_sa(buf, end, &sa->v4, spec, fmt); in ip_addr_string()
1605 return ip6_addr_string_sa(buf, end, &sa->v6, spec, fmt); in ip_addr_string()
1607 return error_string(buf, end, "(einval)", spec); in ip_addr_string()
1612 return error_string(buf, end, err_fmt_msg, spec); in ip_addr_string()
1616 char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, in escaped_string() argument
1624 if (spec.field_width == 0) in escaped_string()
1627 if (check_pointer(&buf, end, addr, spec)) in escaped_string()
1662 len = spec.field_width < 0 ? 1 : spec.field_width; in escaped_string()
1675 struct printf_spec spec, const char *fmt) in va_format() argument
1679 if (check_pointer(&buf, end, va_fmt, spec)) in va_format()
1691 struct printf_spec spec, const char *fmt) in uuid_string() argument
1699 if (check_pointer(&buf, end, addr, spec)) in uuid_string()
1731 return string_nocheck(buf, end, uuid, spec); in uuid_string()
1736 struct printf_spec spec, const char *fmt) in netdev_bits() argument
1741 if (check_pointer(&buf, end, addr, spec)) in netdev_bits()
1750 return error_string(buf, end, "(%pN?)", spec); in netdev_bits()
1758 struct printf_spec spec, const char *fmt) in fourcc_string() argument
1766 return error_string(buf, end, "(%p4?)", spec); in fourcc_string()
1768 if (check_pointer(&buf, end, fourcc, spec)) in fourcc_string()
1791 return string(buf, end, output, spec); in fourcc_string()
1796 struct printf_spec spec, const char *fmt) in address_val() argument
1801 if (check_pointer(&buf, end, addr, spec)) in address_val()
1856 struct printf_spec spec, const char *fmt) in rtc_str() argument
1863 if (check_pointer(&buf, end, tm, spec)) in rtc_str()
1906 struct printf_spec spec, const char *fmt) in time64_str() argument
1924 return rtc_str(buf, end, &rtc_time, spec, fmt); in time64_str()
1928 char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec, in time_and_date() argument
1933 return rtc_str(buf, end, (const struct rtc_time *)ptr, spec, fmt); in time_and_date()
1935 return time64_str(buf, end, *(const time64_t *)ptr, spec, fmt); in time_and_date()
1937 return error_string(buf, end, "(%pt?)", spec); in time_and_date()
1942 char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec, in clock() argument
1946 return error_string(buf, end, "(%pC?)", spec); in clock()
1948 if (check_pointer(&buf, end, clk, spec)) in clock()
1955 return string(buf, end, __clk_get_name(clk), spec); in clock()
1957 return ptr_to_id(buf, end, clk, spec); in clock()
1993 const struct printf_spec *spec; member
2046 *pff[i].spec); in format_page_flags()
2078 struct printf_spec spec, const char *fmt) in flags_string() argument
2083 if (check_pointer(&buf, end, flags_ptr, spec)) in flags_string()
2100 return error_string(buf, end, "(%pG?)", spec); in flags_string()
2135 struct printf_spec spec, const char *fmt) in device_node_string() argument
2144 struct printf_spec str_spec = spec; in device_node_string()
2148 return error_string(buf, end, "(%pO?)", spec); in device_node_string()
2151 return error_string(buf, end, "(%pOF?)", spec); in device_node_string()
2153 if (check_pointer(&buf, end, dn, spec)) in device_node_string()
2184 case 'P': /* path-spec */ in device_node_string()
2220 return widen_string(buf, buf - buf_start, end, spec); in device_node_string()
2225 struct printf_spec spec, const char *fmt) in fwnode_string() argument
2227 struct printf_spec str_spec = spec; in fwnode_string()
2233 return error_string(buf, end, "(%pf?)", spec); in fwnode_string()
2235 if (check_pointer(&buf, end, fwnode, spec)) in fwnode_string()
2250 return widen_string(buf, buf - buf_start, end, spec); in fwnode_string()
2387 * P device node path spec (name + @unit)
2414 struct printf_spec spec) in pointer() argument
2422 return symbol_string(buf, end, ptr, spec, fmt); in pointer()
2425 return resource_string(buf, end, ptr, spec, fmt); in pointer()
2427 return hex_string(buf, end, ptr, spec, fmt); in pointer()
2431 return bitmap_list_string(buf, end, ptr, spec, fmt); in pointer()
2433 return bitmap_string(buf, end, ptr, spec, fmt); in pointer()
2439 return mac_address_string(buf, end, ptr, spec, fmt); in pointer()
2449 return ip_addr_string(buf, end, ptr, spec, fmt); in pointer()
2451 return escaped_string(buf, end, ptr, spec, fmt); in pointer()
2453 return uuid_string(buf, end, ptr, spec, fmt); in pointer()
2455 return va_format(buf, end, ptr, spec, fmt); in pointer()
2457 return restricted_pointer(buf, end, ptr, spec); in pointer()
2459 return netdev_bits(buf, end, ptr, spec, fmt); in pointer()
2461 return fourcc_string(buf, end, ptr, spec, fmt); in pointer()
2463 return address_val(buf, end, ptr, spec, fmt); in pointer()
2465 return dentry_name(buf, end, ptr, spec, fmt); in pointer()
2467 return time_and_date(buf, end, ptr, spec, fmt); in pointer()
2469 return clock(buf, end, ptr, spec, fmt); in pointer()
2471 return file_dentry_name(buf, end, ptr, spec, fmt); in pointer()
2474 return bdev_name(buf, end, ptr, spec, fmt); in pointer()
2478 return flags_string(buf, end, ptr, spec, fmt); in pointer()
2480 return device_node_string(buf, end, ptr, spec, fmt + 1); in pointer()
2482 return fwnode_string(buf, end, ptr, spec, fmt + 1); in pointer()
2486 return error_string(buf, end, "(%pA?)", spec); in pointer()
2490 return pointer_string(buf, end, ptr, spec); in pointer()
2494 return default_pointer(buf, end, ptr, spec); in pointer()
2495 return err_ptr(buf, end, ptr, spec); in pointer()
2500 return string(buf, end, ptr, spec); in pointer()
2502 return error_string(buf, end, "(einval)", spec); in pointer()
2505 return default_pointer(buf, end, ptr, spec); in pointer()
2531 int format_decode(const char *fmt, struct printf_spec *spec) in format_decode() argument
2537 if (spec->type == FORMAT_TYPE_WIDTH) { in format_decode()
2538 if (spec->field_width < 0) { in format_decode()
2539 spec->field_width = -spec->field_width; in format_decode()
2540 spec->flags |= LEFT; in format_decode()
2542 spec->type = FORMAT_TYPE_NONE; in format_decode()
2547 if (spec->type == FORMAT_TYPE_PRECISION) { in format_decode()
2548 if (spec->precision < 0) in format_decode()
2549 spec->precision = 0; in format_decode()
2551 spec->type = FORMAT_TYPE_NONE; in format_decode()
2556 spec->type = FORMAT_TYPE_NONE; in format_decode()
2568 spec->flags = 0; in format_decode()
2576 case '-': spec->flags |= LEFT; break; in format_decode()
2577 case '+': spec->flags |= PLUS; break; in format_decode()
2578 case ' ': spec->flags |= SPACE; break; in format_decode()
2579 case '#': spec->flags |= SPECIAL; break; in format_decode()
2580 case '0': spec->flags |= ZEROPAD; break; in format_decode()
2589 spec->field_width = -1; in format_decode()
2592 spec->field_width = skip_atoi(&fmt); in format_decode()
2595 spec->type = FORMAT_TYPE_WIDTH; in format_decode()
2601 spec->precision = -1; in format_decode()
2605 spec->precision = skip_atoi(&fmt); in format_decode()
2606 if (spec->precision < 0) in format_decode()
2607 spec->precision = 0; in format_decode()
2610 spec->type = FORMAT_TYPE_PRECISION; in format_decode()
2633 spec->base = 10; in format_decode()
2636 spec->type = FORMAT_TYPE_CHAR; in format_decode()
2640 spec->type = FORMAT_TYPE_STR; in format_decode()
2644 spec->type = FORMAT_TYPE_PTR; in format_decode()
2648 spec->type = FORMAT_TYPE_PERCENT_CHAR; in format_decode()
2653 spec->base = 8; in format_decode()
2657 spec->flags |= SMALL; in format_decode()
2661 spec->base = 16; in format_decode()
2666 spec->flags |= SIGN; in format_decode()
2681 spec->type = FORMAT_TYPE_INVALID; in format_decode()
2686 spec->type = FORMAT_TYPE_LONG_LONG; in format_decode()
2689 spec->type = FORMAT_TYPE_ULONG + (spec->flags & SIGN); in format_decode()
2691 spec->type = FORMAT_TYPE_SIZE_T; in format_decode()
2693 spec->type = FORMAT_TYPE_PTRDIFF; in format_decode()
2696 spec->type = FORMAT_TYPE_UBYTE + (spec->flags & SIGN); in format_decode()
2699 spec->type = FORMAT_TYPE_USHORT + (spec->flags & SIGN); in format_decode()
2702 spec->type = FORMAT_TYPE_UINT + (spec->flags & SIGN); in format_decode()
2709 set_field_width(struct printf_spec *spec, int width) in set_field_width() argument
2711 spec->field_width = width; in set_field_width()
2712 if (WARN_ONCE(spec->field_width != width, "field width %d too large", width)) { in set_field_width()
2713 spec->field_width = clamp(width, -FIELD_WIDTH_MAX, FIELD_WIDTH_MAX); in set_field_width()
2718 set_precision(struct printf_spec *spec, int prec) in set_precision() argument
2720 spec->precision = prec; in set_precision()
2721 if (WARN_ONCE(spec->precision != prec, "precision %d too large", prec)) { in set_precision()
2722 spec->precision = clamp(prec, 0, PRECISION_MAX); in set_precision()
2758 struct printf_spec spec = {0}; in vsnprintf() local
2776 int read = format_decode(fmt, &spec); in vsnprintf()
2780 switch (spec.type) { in vsnprintf()
2793 set_field_width(&spec, va_arg(args, int)); in vsnprintf()
2797 set_precision(&spec, va_arg(args, int)); in vsnprintf()
2803 if (!(spec.flags & LEFT)) { in vsnprintf()
2804 while (--spec.field_width > 0) { in vsnprintf()
2815 while (--spec.field_width > 0) { in vsnprintf()
2824 str = string(str, end, va_arg(args, char *), spec); in vsnprintf()
2829 spec); in vsnprintf()
2852 switch (spec.type) { in vsnprintf()
2863 if (spec.flags & SIGN) in vsnprintf()
2890 str = number(str, end, num, spec); in vsnprintf()
3061 struct printf_spec spec = {0}; in vbin_printf() local
3093 int read = format_decode(fmt, &spec); in vbin_printf()
3097 switch (spec.type) { in vbin_printf()
3109 set_field_width(&spec, width); in vbin_printf()
3149 spec); in vbin_printf()
3161 switch (spec.type) { in vbin_printf()
3220 struct printf_spec spec = {0}; in bstr_printf() local
3253 int read = format_decode(fmt, &spec); in bstr_printf()
3257 switch (spec.type) { in bstr_printf()
3270 set_field_width(&spec, get_arg(int)); in bstr_printf()
3274 set_precision(&spec, get_arg(int)); in bstr_printf()
3280 if (!(spec.flags & LEFT)) { in bstr_printf()
3281 while (--spec.field_width > 0) { in bstr_printf()
3291 while (--spec.field_width > 0) { in bstr_printf()
3302 str = string(str, end, (char *)str_arg, spec); in bstr_printf()
3334 str = pointer(fmt, str, end, get_arg(void *), spec); in bstr_printf()
3353 switch (spec.type) { in bstr_printf()
3387 str = number(str, end, num, spec); in bstr_printf()
3389 } /* switch(spec.type) */ in bstr_printf()