Re: [PATCH v3 2/2] riscv: introduce asm/swab.h

From: Ignacio Encinas
Date: Fri Apr 04 2025 - 14:14:14 EST




On 4/4/25 17:55, Ben Dooks wrote:
> On 03/04/2025 21:34, Ignacio Encinas wrote:
>> +#ifdef CONFIG_64BIT
>> +ARCH_SWAB(64)
>> +#define __arch_swab64 __arch_swab64
>> +#endif
>
> I suppose if we're 64bit we can't just rely on values being in one
> register so this'd need special casing here?

Oops... I somehow decided that __arch_swab64 wasn't worth having for
CONFIG_32BIT. I can't tell how useful it is to have it, but it is
doable and already present in the codebase (include/uapi/linux/swab.h):

__u32 h = val >> 32;
__u32 l = val & ((1ULL << 32) - 1);
return (((__u64)__fswab32(l)) << 32) | ((__u64)(__fswab32(h)));

I'll excuse myself on this one because I'm not sure I have ever used a
32 bit CPU (other than the very occasional and quick school project)

Thanks for catching this one! I'll make sure to add __arch_swab64 for
the 32BIT version mimicking the snippet from above.