|
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"
|
@@ -1771,29 +1772,30 @@ char *fourcc_string(char *buf, char *end, const u32 *fourcc,
|
1771 | 1772 | char output[sizeof("0123 little-endian (0x01234567)")];
|
1772 | 1773 | char *p = output;
|
1773 | 1774 | unsigned int i;
|
1774 |
| - u32 val; |
| 1775 | + u32 orig, val; |
1775 | 1776 |
|
1776 | 1777 | if (fmt[1] != 'c' || fmt[2] != 'c')
|
1777 | 1778 | return error_string(buf, end, "(%p4?)", spec);
|
1778 | 1779 |
|
1779 | 1780 | if (check_pointer(&buf, end, fourcc, spec))
|
1780 | 1781 | return buf;
|
1781 | 1782 |
|
1782 |
| - val = *fourcc & ~BIT(31); |
| 1783 | + orig = get_unaligned(fourcc); |
| 1784 | + val = orig & ~BIT(31); |
1783 | 1785 |
|
1784 |
| - for (i = 0; i < sizeof(*fourcc); i++) { |
| 1786 | + for (i = 0; i < sizeof(u32); i++) { |
1785 | 1787 | unsigned char c = val >> (i * 8);
|
1786 | 1788 |
|
1787 | 1789 | /* Print non-control ASCII characters as-is, dot otherwise */
|
1788 | 1790 | *p++ = isascii(c) && isprint(c) ? c : '.';
|
1789 | 1791 | }
|
1790 | 1792 |
|
1791 |
| - strcpy(p, *fourcc & BIT(31) ? " big-endian" : " little-endian"); |
| 1793 | + strcpy(p, orig & BIT(31) ? " big-endian" : " little-endian"); |
1792 | 1794 | p += strlen(p);
|
1793 | 1795 |
|
1794 | 1796 | *p++ = ' ';
|
1795 | 1797 | *p++ = '(';
|
1796 |
| - p = special_hex_number(p, output + sizeof(output) - 2, *fourcc, sizeof(u32)); |
| 1798 | + p = special_hex_number(p, output + sizeof(output) - 2, orig, sizeof(u32)); |
1797 | 1799 | *p++ = ')';
|
1798 | 1800 | *p = '\0';
|
1799 | 1801 |
|
|
0 commit comments