[PATCH v2 07/12] staging: ks7010: replace PutUInt32 macro with an inline function
Greg KH
gregkh at linuxfoundation.org
Wed Mar 28 11:45:27 UTC 2018
On Fri, Mar 23, 2018 at 02:05:15PM +0100, Sergio Paracuellos wrote:
> This commit replaces PutUInt32 macro in favour of inline function
> renaming it to put_uint32.
>
> Signed-off-by: Sergio Paracuellos <sergio.paracuellos at gmail.com>
> ---
> drivers/staging/ks7010/michael_mic.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c
> index 82ac122..9de31b4 100644
> --- a/drivers/staging/ks7010/michael_mic.c
> +++ b/drivers/staging/ks7010/michael_mic.c
> @@ -19,13 +19,13 @@
> + (A[B + 1] << 8) + (A[B + 2] << 16) + (A[B + 3] << 24))
>
> // Convert from UInt32 to Byte[] in a portable way
> -#define putUInt32(A, B, C) \
> -do { \
> - A[B + 0] = (uint8_t)(C & 0xff); \
> - A[B + 1] = (uint8_t)((C >> 8) & 0xff); \
> - A[B + 2] = (uint8_t)((C >> 16) & 0xff); \
> - A[B + 3] = (uint8_t)((C >> 24) & 0xff); \
> -} while (0)
> +static inline void put_uint32(u8 *dst, u8 pos, u32 orig)
> +{
> + dst[pos] = (u8)(orig & 0xff);
> + dst[pos + 1] = (u8)((orig >> 8) & 0xff);
> + dst[pos + 2] = (u8)((orig >> 16) & 0xff);
> + dst[pos + 3] = (u8)((orig >> 24) & 0xff);
> +}
Why reinvent put_unaligned_le32()?
thanks,
greg k-h
More information about the devel
mailing list