diff --git a/lib/psci/psci_mem_protect.c b/lib/psci/psci_mem_protect.c index fca84e9..857146b 100644 --- a/lib/psci/psci_mem_protect.c +++ b/lib/psci/psci_mem_protect.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -9,30 +9,31 @@ #include #include "psci_private.h" -int psci_mem_protect(unsigned int enable) +u_register_t psci_mem_protect(unsigned int enable) { int val; - assert(psci_plat_pm_ops->read_mem_protect); - assert(psci_plat_pm_ops->write_mem_protect); + assert(psci_plat_pm_ops->read_mem_protect != NULL); + assert(psci_plat_pm_ops->write_mem_protect != NULL); if (psci_plat_pm_ops->read_mem_protect(&val) < 0) - return PSCI_E_NOT_SUPPORTED; + return (u_register_t) PSCI_E_NOT_SUPPORTED; if (psci_plat_pm_ops->write_mem_protect(enable) < 0) - return PSCI_E_NOT_SUPPORTED; + return (u_register_t) PSCI_E_NOT_SUPPORTED; - return val != 0; + return (val != 0) ? 1U : 0U; } -int psci_mem_chk_range(uintptr_t base, u_register_t length) +u_register_t psci_mem_chk_range(uintptr_t base, u_register_t length) { int ret; - assert(psci_plat_pm_ops->mem_protect_chk); + assert(psci_plat_pm_ops->mem_protect_chk != NULL); - if (length == 0 || check_uptr_overflow(base, length-1)) - return PSCI_E_DENIED; + if ((length == 0U) || check_uptr_overflow(base, length - 1U)) + return (u_register_t) PSCI_E_DENIED; ret = psci_plat_pm_ops->mem_protect_chk(base, length); - return (ret < 0) ? PSCI_E_DENIED : PSCI_E_SUCCESS; + return (ret < 0) ? + (u_register_t) PSCI_E_DENIED : (u_register_t) PSCI_E_SUCCESS; } diff --git a/lib/psci/psci_private.h b/lib/psci/psci_private.h index ac99876..75f7d45 100644 --- a/lib/psci/psci_private.h +++ b/lib/psci/psci_private.h @@ -330,7 +330,7 @@ unsigned int power_state); /* Private exported functions from psci_mem_protect.c */ -int psci_mem_protect(unsigned int enable); -int psci_mem_chk_range(uintptr_t base, u_register_t length); +u_register_t psci_mem_protect(unsigned int enable); +u_register_t psci_mem_chk_range(uintptr_t base, u_register_t length); #endif /* PSCI_PRIVATE_H */