Files
android_kernel_samsung_sm8750/arch/arm64/gunyah/reset.c
2025-08-11 14:29:00 +02:00

49 lines
1.5 KiB
C

// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*
*/
#include <linux/gunyah/gh_rm_drv.h>
#include "reset.h"
/**
* gh_arch_validate_vm_exited_notif: Validate the arch specific exit
* reason and provide a generic reason for further use.
* @buff_size: Size of the buffer containing the exit reason
* @hdr_size: Size of the header
* @vm_exited_payload: Struct of exit_reason
*
* If the exit reason is not valid or has an incorrect size, -EINVAL is
* returned, 0 otherwise and also provides a generic reason for exit
* which can be used by drivers.
*/
int gh_arch_validate_vm_exited_notif(size_t payload_size,
struct gh_rm_notif_vm_exited_payload *vm_exited_payload)
{
switch (vm_exited_payload->exit_type) {
case GH_RM_VM_EXIT_TYPE_PSCI_SYSTEM_RESET2:
if (payload_size !=
sizeof(*vm_exited_payload) + sizeof(struct gh_vm_exit_reason_psci_sys_reset2)) {
pr_err("%s: Invalid size for type PSCI_SYSTEM_RESET2: %lu\n",
__func__, payload_size);
return -EINVAL;
}
vm_exited_payload->exit_type = GH_RM_VM_EXIT_TYPE_SYSTEM_RESET;
fallthrough;
case GH_RM_VM_EXIT_TYPE_PSCI_SYSTEM_RESET:
vm_exited_payload->exit_type = GH_RM_VM_EXIT_TYPE_SYSTEM_RESET;
break;
case GH_RM_VM_EXIT_TYPE_PSCI_SYSTEM_OFF:
vm_exited_payload->exit_type = GH_RM_VM_EXIT_TYPE_SYSTEM_OFF;
break;
default:
return -EINVAL;
}
return 0;
}
EXPORT_SYMBOL_GPL(gh_arch_validate_vm_exited_notif);