// SPDX-License-Identifier: GPL-2.0+ /* Copyright (C) 2022 AVM GmbH */ #define pr_fmt(fmt) "mrpc fwinfo server: " fmt #include #include #include "avm_fw_info.h" static struct mrpc_server *server; static int __avm_fwinfo_get_buildinfo(void *arg, ssize_t arglen, void *reply, ssize_t replen) { struct avm_firmware_build_info_be *bibe = reply; BUG_ON(replen < sizeof(*bibe)); strscpy(bibe->buildnumber, avm_fw_build_info->buildnumber, sizeof(bibe->buildnumber)); strscpy(bibe->firmwarestring, avm_fw_build_info->firmwarestring, sizeof(bibe->firmwarestring)); bibe->buildtype = cpu_to_be32(avm_fw_build_info->buildtype); bibe->builddirty = cpu_to_be32(avm_fw_build_info->builddirty); /* This server is one-shot only */ mrpc_server_unregister(server); server = NULL; return 0; } static struct mrpc_procinfo avm_fwinfo_server_procs[] = { MRPC_PROCINFO_ENTRY(MRPC_AVM_FWINFO_GET_BUILDINFO, __avm_fwinfo_get_buildinfo, 0, sizeof(struct avm_firmware_build_info_be)), }; static int __init avm_fwinfo_server_init(void) { server = mrpc_server_register( MRPC_RESERVED_ID_AVM_FWINFO, "AVM fwinfo server", avm_fwinfo_server_procs, ARRAY_SIZE(avm_fwinfo_server_procs)); if (!server) return -ENODEV; return 0; } module_init(avm_fwinfo_server_init);