Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: SOF: use __u32 instead of uint32_t in uapi headers

When CONFIG_UAPI_HEADER_TEST=y, exported headers are compile-tested to
make sure they can be included from user-space.

Currently, header.h and fw.h are excluded from the test coverage.
To make them join the compile-test, we need to fix the build errors
attached below.

For a case like this, we decided to use __u{8,16,32,64} variable types
in this discussion:

https://lkml.org/lkml/2019/6/5/18

Build log:

CC usr/include/sound/sof/header.h.s
CC usr/include/sound/sof/fw.h.s
In file included from <command-line>:32:0:
./usr/include/sound/sof/header.h:19:2: error: unknown type name ‘uint32_t’
uint32_t magic; /**< 'S', 'O', 'F', '\0' */
^~~~~~~~
./usr/include/sound/sof/header.h:20:2: error: unknown type name ‘uint32_t’
uint32_t type; /**< component specific type */
^~~~~~~~
./usr/include/sound/sof/header.h:21:2: error: unknown type name ‘uint32_t’
uint32_t size; /**< size in bytes of data excl. this struct */
^~~~~~~~
./usr/include/sound/sof/header.h:22:2: error: unknown type name ‘uint32_t’
uint32_t abi; /**< SOF ABI version */
^~~~~~~~
./usr/include/sound/sof/header.h:23:2: error: unknown type name ‘uint32_t’
uint32_t reserved[4]; /**< reserved for future use */
^~~~~~~~
./usr/include/sound/sof/header.h:24:2: error: unknown type name ‘uint32_t’
uint32_t data[0]; /**< Component data - opaque to core */
^~~~~~~~
In file included from <command-line>:32:0:
./usr/include/sound/sof/fw.h:49:2: error: unknown type name ‘uint32_t’
uint32_t size; /* bytes minus this header */
^~~~~~~~
./usr/include/sound/sof/fw.h:50:2: error: unknown type name ‘uint32_t’
uint32_t offset; /* offset from base */
^~~~~~~~
./usr/include/sound/sof/fw.h:64:2: error: unknown type name ‘uint32_t’
uint32_t size; /* bytes minus this header */
^~~~~~~~
./usr/include/sound/sof/fw.h:65:2: error: unknown type name ‘uint32_t’
uint32_t num_blocks; /* number of blocks */
^~~~~~~~
./usr/include/sound/sof/fw.h:73:2: error: unknown type name ‘uint32_t’
uint32_t file_size; /* size of file minus this header */
^~~~~~~~
./usr/include/sound/sof/fw.h:74:2: error: unknown type name ‘uint32_t’
uint32_t num_modules; /* number of modules */
^~~~~~~~
./usr/include/sound/sof/fw.h:75:2: error: unknown type name ‘uint32_t’
uint32_t abi; /* version of header format */
^~~~~~~~

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Link: https://lore.kernel.org/r/20190721142308.30306-1-yamada.masahiro@socionext.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Masahiro Yamada and committed by
Mark Brown
62ec3d13 f86621cd

+17 -13
+9 -7
include/uapi/sound/sof/fw.h
··· 13 13 #ifndef __INCLUDE_UAPI_SOF_FW_H__ 14 14 #define __INCLUDE_UAPI_SOF_FW_H__ 15 15 16 + #include <linux/types.h> 17 + 16 18 #define SND_SOF_FW_SIG_SIZE 4 17 19 #define SND_SOF_FW_ABI 1 18 20 #define SND_SOF_FW_SIG "Reef" ··· 48 46 49 47 struct snd_sof_blk_hdr { 50 48 enum snd_sof_fw_blk_type type; 51 - uint32_t size; /* bytes minus this header */ 52 - uint32_t offset; /* offset from base */ 49 + __u32 size; /* bytes minus this header */ 50 + __u32 offset; /* offset from base */ 53 51 } __packed; 54 52 55 53 /* ··· 63 61 64 62 struct snd_sof_mod_hdr { 65 63 enum snd_sof_fw_mod_type type; 66 - uint32_t size; /* bytes minus this header */ 67 - uint32_t num_blocks; /* number of blocks */ 64 + __u32 size; /* bytes minus this header */ 65 + __u32 num_blocks; /* number of blocks */ 68 66 } __packed; 69 67 70 68 /* ··· 72 70 */ 73 71 struct snd_sof_fw_header { 74 72 unsigned char sig[SND_SOF_FW_SIG_SIZE]; /* "Reef" */ 75 - uint32_t file_size; /* size of file minus this header */ 76 - uint32_t num_modules; /* number of modules */ 77 - uint32_t abi; /* version of header format */ 73 + __u32 file_size; /* size of file minus this header */ 74 + __u32 num_modules; /* number of modules */ 75 + __u32 abi; /* version of header format */ 78 76 } __packed; 79 77 80 78 #endif
+8 -6
include/uapi/sound/sof/header.h
··· 9 9 #ifndef __INCLUDE_UAPI_SOUND_SOF_USER_HEADER_H__ 10 10 #define __INCLUDE_UAPI_SOUND_SOF_USER_HEADER_H__ 11 11 12 + #include <linux/types.h> 13 + 12 14 /* 13 15 * Header for all non IPC ABI data. 14 16 * ··· 18 16 * Used by any bespoke component data structures or binary blobs. 19 17 */ 20 18 struct sof_abi_hdr { 21 - uint32_t magic; /**< 'S', 'O', 'F', '\0' */ 22 - uint32_t type; /**< component specific type */ 23 - uint32_t size; /**< size in bytes of data excl. this struct */ 24 - uint32_t abi; /**< SOF ABI version */ 25 - uint32_t reserved[4]; /**< reserved for future use */ 26 - uint32_t data[0]; /**< Component data - opaque to core */ 19 + __u32 magic; /**< 'S', 'O', 'F', '\0' */ 20 + __u32 type; /**< component specific type */ 21 + __u32 size; /**< size in bytes of data excl. this struct */ 22 + __u32 abi; /**< SOF ABI version */ 23 + __u32 reserved[4]; /**< reserved for future use */ 24 + __u32 data[0]; /**< Component data - opaque to core */ 27 25 } __packed; 28 26 29 27 #endif