lib: utils/fdt/fdt_domain: Simplify region access permission check

The region access permission check in __fdt_parse_region() can be
simplified as masking SBI_DOMAIN_MEMREGION_{M,SU}_ACCESS_MASK is
enough.

While we are here, update the confusing comments to match the codes.

Signed-off-by: Bin Meng <bmeng@tinylab.org>
Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Bin Meng 2023-02-24 12:28:26 +08:00 committed by Anup Patel
parent 5a75f5309c
commit bc06ff65bf

View file

@ -244,13 +244,11 @@ static int __fdt_parse_region(void *fdt, int domain_offset,
* access permissions. M-mode regions can only be part of
* root domain.
*
* SU permission bits can't be all zeroes and M-mode permission
* bits must be all set.
* SU permission bits can't be all zeroes when M-mode permission
* bits have at least one bit set.
*/
if (!((region_access & SBI_DOMAIN_MEMREGION_SU_ACCESS_MASK)
& SBI_DOMAIN_MEMREGION_SU_RWX)
&& ((region_access & SBI_DOMAIN_MEMREGION_M_ACCESS_MASK)
& SBI_DOMAIN_MEMREGION_M_RWX))
if (!(region_access & SBI_DOMAIN_MEMREGION_SU_ACCESS_MASK)
&& (region_access & SBI_DOMAIN_MEMREGION_M_ACCESS_MASK))
return SBI_EINVAL;
/* Find next region of the domain */