|
49 | 49 |
|
50 | 50 | #include <asm/page.h> /* for PAGE_SIZE */ |
51 | 51 | #include <asm/byteorder.h> /* cpu_to_le16 */ |
| 52 | +#include <asm/unaligned.h> |
52 | 53 |
|
53 | 54 | #include <linux/string_helpers.h> |
54 | 55 | #include "kstrtox.h" |
@@ -1788,29 +1789,31 @@ char *fourcc_string(char *buf, char *end, const u32 *fourcc, |
1788 | 1789 | char output[sizeof("0123 little-endian (0x01234567)")]; |
1789 | 1790 | char *p = output; |
1790 | 1791 | unsigned int i; |
1791 | | - u32 val; |
| 1792 | + u32 orig, val; |
1792 | 1793 |
|
1793 | 1794 | if (fmt[1] != 'c' || fmt[2] != 'c') |
1794 | 1795 | return error_string(buf, end, "(%p4?)", spec); |
1795 | 1796 |
|
1796 | 1797 | if (check_pointer(&buf, end, fourcc, spec)) |
1797 | 1798 | return buf; |
1798 | 1799 |
|
1799 | | - val = *fourcc & ~BIT(31); |
| 1800 | + orig = get_unaligned(fourcc); |
| 1801 | + val = orig & ~BIT(31); |
1800 | 1802 |
|
1801 | | - for (i = 0; i < sizeof(*fourcc); i++) { |
| 1803 | + for (i = 0; i < sizeof(u32); i++) { |
1802 | 1804 | unsigned char c = val >> (i * 8); |
1803 | 1805 |
|
1804 | 1806 | /* Print non-control ASCII characters as-is, dot otherwise */ |
1805 | 1807 | *p++ = isascii(c) && isprint(c) ? c : '.'; |
1806 | 1808 | } |
1807 | 1809 |
|
1808 | | - strcpy(p, *fourcc & BIT(31) ? " big-endian" : " little-endian"); |
| 1810 | + *p++ = ' '; |
| 1811 | + strcpy(p, orig & BIT(31) ? "big-endian" : "little-endian"); |
1809 | 1812 | p += strlen(p); |
1810 | 1813 |
|
1811 | 1814 | *p++ = ' '; |
1812 | 1815 | *p++ = '('; |
1813 | | - p = special_hex_number(p, output + sizeof(output) - 2, *fourcc, sizeof(u32)); |
| 1816 | + p = special_hex_number(p, output + sizeof(output) - 2, orig, sizeof(u32)); |
1814 | 1817 | *p++ = ')'; |
1815 | 1818 | *p = '\0'; |
1816 | 1819 |
|
|
0 commit comments