static int npa_remote_cb(struct msm_rpc_client *client, struct msm_rpc_xdr *xdr) { int err = 0; int array_length = 0; unsigned int status = RPC_ACCEPTSTAT_SYSTEM_ERR; struct npa_remote_cb_data arg; npa_remote_callback cb_fn = NULL; xdr_recv_uint32(xdr, &arg.cb_id); xdr_recv_uint32(xdr, &arg.context); xdr_recv_uint32(xdr, &arg.type); xdr_recv_array(xdr, (void **)&arg.buffer, &array_length, INT_MAX, sizeof(int32_t), (void *)xdr_recv_int32); xdr_recv_uint32(xdr, &arg.size); cb_fn = (npa_remote_callback) msm_rpc_get_cb_func(client, arg.cb_id); if (cb_fn) { cb_fn((void *)arg.context, arg.type, arg.buffer, arg.size); status = RPC_ACCEPTSTAT_SUCCESS; } xdr_start_accepted_reply(xdr, status); err = xdr_send_msg(xdr); if (err) { pr_err("NPA Remote callback %s: send accepted reply failed: " "%d\n", __func__, err); BUG(); } kfree(arg.buffer); return 0; }
static int dog_keepalive_cb(struct msm_rpc_client *client, struct msm_rpc_xdr *xdr) { int rc; void *cb_func; uint32_t accept_status; struct dog_keepalive_cb_arg arg; struct dog_keepalive_cb_ret ret; xdr_recv_uint32(xdr, &arg.cb_id); cb_func = msm_rpc_get_cb_func(client, arg.cb_id); if (cb_func) { rc = ((int (*) (struct dog_keepalive_cb_arg *, struct dog_keepalive_cb_ret *)) cb_func)(&arg, &ret); if (rc) accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; else accept_status = RPC_ACCEPTSTAT_SUCCESS; } else accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; xdr_start_accepted_reply(xdr, accept_status); if (accept_status == RPC_ACCEPTSTAT_SUCCESS) xdr_send_uint32(xdr, &ret.result); rc = xdr_send_msg(xdr); if (rc) pr_err("%s: send accepted reply failed: %d\n", __func__, rc); return rc; }
static int ping_mdm_register_cb(struct msm_rpc_client *client, struct msm_rpc_xdr *xdr) { int rc; uint32_t accept_status; struct ping_mdm_register_cb_arg arg; void *cb_func; xdr_recv_uint32(xdr, &arg.cb_id); /* cb_id */ xdr_recv_int32(xdr, &arg.val); /* val */ cb_func = msm_rpc_get_cb_func(client, arg.cb_id); if (cb_func) { rc = ((int (*)(struct ping_mdm_register_cb_arg *, void *)) cb_func)(&arg, NULL); if (rc) accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; else accept_status = RPC_ACCEPTSTAT_SUCCESS; } else accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; xdr_start_accepted_reply(xdr, accept_status); rc = xdr_send_msg(xdr); if (rc) pr_err("%s: send accepted reply failed: %d\n", __func__, rc); return rc; }
static int ping_mdm_data_cb(struct msm_rpc_client *client, struct msm_rpc_xdr *xdr) { int rc; void *cb_func; uint32_t size, accept_status; struct ping_mdm_register_data_cb_cb_arg arg; struct ping_mdm_register_data_cb_cb_ret ret; xdr_recv_uint32(xdr, &arg.cb_id); /* cb_id */ /* data */ xdr_recv_array(xdr, (void **)(&(arg.data)), &size, 64, sizeof(uint32_t), (void *)xdr_recv_uint32); xdr_recv_uint32(xdr, &arg.size); /* size */ xdr_recv_uint32(xdr, &arg.sum); /* sum */ cb_func = msm_rpc_get_cb_func(client, arg.cb_id); if (cb_func) { rc = ((int (*) (struct ping_mdm_register_data_cb_cb_arg *, struct ping_mdm_register_data_cb_cb_ret *)) cb_func)(&arg, &ret); if (rc) accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; else accept_status = RPC_ACCEPTSTAT_SUCCESS; } else accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; xdr_start_accepted_reply(xdr, accept_status); if (accept_status == RPC_ACCEPTSTAT_SUCCESS) xdr_send_uint32(xdr, &ret.result); /* result */ rc = xdr_send_msg(xdr); if (rc) pr_err("%s: send accepted reply failed: %d\n", __func__, rc); kfree(arg.data); return rc; }
static int dog_keepalive_cb_func(struct msm_rpc_client *client, struct rpc_request_hdr *req, struct msm_rpc_xdr *xdr) { int rc = 0; switch (req->procedure) { case DOG_KEEPALIVE_CB_PROC: rc = dog_keepalive_cb(client, xdr); break; default: pr_err("%s: procedure not supported %d\n", __func__, req->procedure); xdr_start_accepted_reply(xdr, RPC_ACCEPTSTAT_PROC_UNAVAIL); rc = xdr_send_msg(xdr); if (rc) pr_err("%s: sending reply failed: %d\n", __func__, rc); break; } return rc; }
static int handle_lg_fw_helper_misc_blk_write(struct msm_rpc_xdr *xdr) { int ret; struct lg_fw_helper_misc_blk_rpc arg; // get block number ret = xdr_recv_uint32(xdr, &arg.block_no); if (ret != 0) return ret; // get block data ret = xdr_recv_array(xdr, (void **)&arg.data, &arg.size, 128, sizeof(uint32_t), (void *)xdr_recv_uint32); if (ret != 0) return ret; // write block data print_hex_dump(KERN_INFO, "data: ", DUMP_PREFIX_OFFSET, 16, 1, arg.data, 512, true); printk(KERN_ERR "[sunny] block num = %d \n", arg.block_no); ret = lge_emmc_wallpaper_write(arg.block_no, (unsigned char*) arg.data, 512); ret = xdr_start_accepted_reply(xdr, RPC_ACCEPTSTAT_SUCCESS); if (ret != 0) goto handle_lg_fw_helper_misc_blk_write_exit; ret = 0xabcdef12; // for debugging ret = xdr_send_uint32(xdr, &ret); if (ret != 0) goto handle_lg_fw_helper_misc_blk_write_exit; ret = xdr_send_msg(xdr); if (ret < 0) pr_err("%s: sending reply failed\n", __func__); handle_lg_fw_helper_misc_blk_write_exit: if (arg.data) kfree(arg.data); return 0; }
static int npa_remote_cb_fn(struct msm_rpc_client *client, struct rpc_request_hdr *req, struct msm_rpc_xdr *xdr) { int ret = 0; switch (req->procedure) { case NPA_REMOTE_CALLBACK_TYPE_PROC: ret = npa_remote_cb(client, xdr); break; default: pr_err("NPA RPC: callback procedure not supported %d\n", req->procedure); xdr_start_accepted_reply(xdr, RPC_ACCEPTSTAT_PROC_UNAVAIL); ret = xdr_send_msg(xdr); if (ret) pr_err("NPA RPC: %s error sending reply %d\n", __func__, ret); break; } return ret; }
static int ping_mdm_cb_func(struct msm_rpc_client *client, struct rpc_request_hdr *req, struct msm_rpc_xdr *xdr) { int rc = 0; switch (req->procedure) { case PING_MDM_CB_PROC: rc = ping_mdm_register_cb(client, xdr); break; case PING_MDM_DATA_CB_PROC: rc = ping_mdm_data_cb(client, xdr); break; default: pr_err("%s: procedure not supported %d\n", __func__, req->procedure); xdr_start_accepted_reply(xdr, RPC_ACCEPTSTAT_PROC_UNAVAIL); rc = xdr_send_msg(xdr); if (rc) pr_err("%s: sending reply failed: %d\n", __func__, rc); break; } return rc; }
/* TODO: check where to allocate memory for return */ static int oem_rapi_client_cb(struct msm_rpc_client *client, struct rpc_request_hdr *req, struct msm_rpc_xdr *xdr) { uint32_t cb_id, accept_status; int rc; void *cb_func; uint32_t temp; struct oem_rapi_client_streaming_func_cb_arg arg; struct oem_rapi_client_streaming_func_cb_ret ret; arg.input = NULL; ret.out_len = NULL; ret.output = NULL; xdr_recv_uint32(xdr, &cb_id); /* cb_id */ xdr_recv_uint32(xdr, &arg.event); /* enum */ xdr_recv_uint32(xdr, (uint32_t *)(&arg.handle)); /* handle */ xdr_recv_uint32(xdr, &arg.in_len); /* in_len */ xdr_recv_bytes(xdr, (void **)&arg.input, &temp); /* input */ xdr_recv_uint32(xdr, &arg.out_len_valid); /* out_len */ if (arg.out_len_valid) { ret.out_len = kmalloc(sizeof(*ret.out_len), GFP_KERNEL); if (!ret.out_len) { accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; goto oem_rapi_send_ack; } } xdr_recv_uint32(xdr, &arg.output_valid); /* out */ if (arg.output_valid) { xdr_recv_uint32(xdr, &arg.output_size); /* ouput_size */ ret.output = kmalloc(arg.output_size, GFP_KERNEL); if (!ret.output) { accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; goto oem_rapi_send_ack; } } cb_func = msm_rpc_get_cb_func(client, cb_id); if (cb_func) { rc = ((int (*)(struct oem_rapi_client_streaming_func_cb_arg *, struct oem_rapi_client_streaming_func_cb_ret *)) cb_func)(&arg, &ret); if (rc) accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; else accept_status = RPC_ACCEPTSTAT_SUCCESS; } else accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; oem_rapi_send_ack: xdr_start_accepted_reply(xdr, accept_status); if (accept_status == RPC_ACCEPTSTAT_SUCCESS) { uint32_t temp = sizeof(uint32_t); xdr_send_pointer(xdr, (void **)&(ret.out_len), temp, xdr_send_uint32); /* output */ if (ret.output && ret.out_len) xdr_send_bytes(xdr, (const void **)&ret.output, ret.out_len); else { temp = 0; xdr_send_uint32(xdr, &temp); } } rc = xdr_send_msg(xdr); if (rc) pr_err("%s: sending reply failed: %d\n", __func__, rc); kfree(arg.input); kfree(ret.out_len); kfree(ret.output); return 0; }