static int vbus_notification_cb(struct msm_rpc_client *client, void *buffer, int in_size) { struct vbus_sn_notification_args *args; struct rpc_request_hdr *req = buffer; int rc; uint32_t accept_status; void (*cb_func)(int); uint32_t cb_id; int vbus; args = (struct vbus_sn_notification_args *) (req + 1); cb_id = be32_to_cpu(args->cb_id); vbus = be32_to_cpu(args->vbus); cb_func = msm_rpc_get_cb_func(client, cb_id); if (cb_func) { cb_func(!vbus); accept_status = RPC_ACCEPTSTAT_SUCCESS; } else accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid), accept_status); rc = msm_rpc_send_accepted_reply(client, 0); 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, void *buffer, int in_size) { int rc; uint32_t accept_status; struct rpc_request_hdr *req; struct ping_mdm_register_cb_arg arg, *buf_ptr; void *cb_func; req = (struct rpc_request_hdr *)buffer; buf_ptr = (struct ping_mdm_register_cb_arg *)(req + 1); arg.cb_id = be32_to_cpu(buf_ptr->cb_id); arg.val = be32_to_cpu(buf_ptr->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; msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid), accept_status); rc = msm_rpc_send_accepted_reply(client, 0); if (rc) pr_err("%s: send accepted reply failed: %d\n", __func__, rc); return rc; }
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, void *buffer, int in_size) { struct rpc_request_hdr *req; int rc, i; void *buf, *cb_func, *reply; uint32_t size, accept_status; struct ping_mdm_register_data_cb_cb_arg arg; struct ping_mdm_register_data_cb_cb_ret ret; req = (struct rpc_request_hdr *)buffer; buf = (void *)(req + 1); arg.cb_id = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); size = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); if (size) { arg.data = kmalloc((size * sizeof(*arg.data)), GFP_KERNEL); if (arg.data) for (i = 0; i < size; i++) arg.data[i] = be32_to_cpu(*((uint32_t *)buf + i)); } buf += sizeof(uint32_t) * size; arg.size = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); arg.sum = be32_to_cpu(*(uint32_t *)buf); 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; reply = msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid), accept_status); size = 0; if (accept_status == RPC_ACCEPTSTAT_SUCCESS) { *(uint32_t *)reply = cpu_to_be32(ret.result); size = sizeof(uint32_t); } rc = msm_rpc_send_accepted_reply(client, size); 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; }
/* 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; }
static int oem_rapi_client_cb(struct msm_rpc_client *client, void *buffer, int in_size) { struct rpc_request_hdr *req; void *buf, *cb_func, *reply; uint32_t cb_id, accept_status, size; int rc; 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; req = (struct rpc_request_hdr *)buffer; buf = (void *)(req + 1); /* cb_id */ cb_id = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); /* enum */ arg.event = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); /* handle */ arg.handle = (void *)be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); /* in_len */ arg.in_len = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); /* input */ size = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); if (size) { arg.input = kmalloc(size, GFP_KERNEL); if (arg.input) memcpy(arg.input, buf, size); else { accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; goto oem_rapi_send_ack; } } buf += size; if (size & 0x3) buf += 4 - (size & 0x3); /* out_len */ arg.out_len_valid = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); 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; } } /* out */ arg.output_valid = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); if (arg.output_valid) { arg.output_size = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); 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: reply = msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid), accept_status); size = 0; if (accept_status == RPC_ACCEPTSTAT_SUCCESS) { *(uint32_t *)reply = cpu_to_be32((uint32_t)(ret.out_len != 0)); reply += sizeof(uint32_t); size += sizeof(uint32_t); if (ret.out_len) { *(uint32_t *)reply = cpu_to_be32(*ret.out_len); reply += sizeof(uint32_t); size += sizeof(uint32_t); } if (ret.output && ret.out_len) { *(uint32_t *)reply = cpu_to_be32((uint32_t)(*ret.out_len)); reply += sizeof(uint32_t); size += sizeof(uint32_t); memcpy(reply, ret.output, *ret.out_len); reply += *ret.out_len; size += *ret.out_len; if (*ret.out_len & 0x3) { memset(reply, 0, 4 - (*ret.out_len & 0x3)); reply += 4 - (*ret.out_len & 0x3); size += 4 - (*ret.out_len & 0x3); } } else { *(uint32_t *)reply = cpu_to_be32(0); reply += sizeof(uint32_t); size += sizeof(uint32_t); } } rc = msm_rpc_send_accepted_reply(client, size); if (rc) pr_err("%s: sending reply failed: %d\n", __func__, rc); kfree(arg.input); kfree(ret.out_len); kfree(ret.output); return 0; }