// SPDX-License-Identifier: GPL-2.0-only /* * avm-prom config mrpc server * * Copyright 2017, 2019 AVM GmbH */ #define pr_fmt(fmt) "avmcfg_server: " fmt #include #include /* * Implement the avm-prom config mrpc server functions and map them to * local platform code. The function prototypes are dictated by mrpc's * proc_t type. */ static int mrpc_avmcfg_server_getloc(void *arg, ssize_t arglen, void *rep, ssize_t replen) { struct avmcfg_probe_reply *reply = rep; struct avm_prom_config_packed_locator loc; int ret; ret = avm_prom_config_server_getloc(&loc); if (ret) return ret; avm_prom_config_loc2rloc(&loc, &reply->rloc); return 0; } static int mrpc_avmcfg_server_raw_read(void *arg, ssize_t arglen, void *rep, ssize_t replen) { struct avm_prom_config_device *prom_server = &avm_prom_server_device; struct avmcfg_read_request *req = arg; struct avmcfg_read_reply *reply = rep; u32 offset, len; int ret; offset = be32_to_cpu(req->offset); len = be32_to_cpu(req->len); len = min(len, sizeof(reply->data)); ret = prom_server->ops->read(prom_server, offset, reply->data, len); if (ret < 0) { pr_err("Error reading avm_prom: %d\n", ret); return ret; } reply->result = cpu_to_be32(ret); return 0; } static struct mrpc_procinfo avmcfg_server_procs[] = { /* Request, Handle function, Argument length, Reply length */ MRPC_PROCINFO_ENTRY(MRPC_AVMCFG_PROC_GETLOC, mrpc_avmcfg_server_getloc, 0, sizeof(struct avmcfg_probe_reply)), MRPC_PROCINFO_ENTRY(MRPC_AVMCFG_PROC_RAW_READ, mrpc_avmcfg_server_raw_read, sizeof(struct avmcfg_read_request), sizeof(struct avmcfg_read_reply)), }; static int __init avmcfg_server_init(void) { struct mrpc_server *server; server = mrpc_server_register( MRPC_RESERVED_ID_AVMCFG, "AVM configuration data", avmcfg_server_procs, ARRAY_SIZE(avmcfg_server_procs)); if (!server) return -ENODEV; return 0; } device_initcall(avmcfg_server_init);