Re: [PATCH 1/2] staging: media: atomisp: Remove typedefs for basic types in vmem.c

From: Andy Shevchenko
Date: Mon Sep 01 2025 - 08:39:39 EST


On Mon, Sep 01, 2025 at 09:10:49AM +0000, Adrian Barnaś wrote:
> Cleared typedefs hiding unsigned long long type, to align with
> kernel coding style.

...

> -static inline hive_uedge
> -subword(hive_uedge w, unsigned int start, unsigned int end)
> +static inline unsigned long long
> +subword(unsigned long long w, unsigned int start, unsigned int end)
> {
> return (w & (((1ULL << (end - 1)) - 1) << 1 | 1)) >> start;
> }
>
> /* inverse subword bits move like this: MSB[xxxx____xxxx]LSB -> MSB[xxxx0000xxxx]LSB */
> -static inline hive_uedge
> -inv_subword(hive_uedge w, unsigned int start, unsigned int end)
> +static inline unsigned long long
> +inv_subword(unsigned long long w, unsigned int start, unsigned int end)
> {
> return w & (~(((1ULL << (end - 1)) - 1) << 1 | 1) | ((1ULL << start) - 1));
> }

Also consider to simplify the above (in a separate change).

static inline unsigned long long
subword(unsigned long long w, unsigned int start, unsigned int end)
{
return (w & GENMASK_ULL(end, 0)) >> start;
}

static inline unsigned long long
inv_subword(unsigned long long w, unsigned int start, unsigned int end)
{
return w & (~GENMASK_ULL(end, 0) | GENMASK_ULL(start, 0));
}

...if I'm not mistaken, so double check all these.

At least in my case the end == 64 is not allowed while it seems the original
code allows it to be equal to the end == 63 case. Needs testing anyway...

--
With Best Regards,
Andy Shevchenko