Lines Matching defs:rpc
884 struct arpc *rpc;
886 if (size + sizeof(*rpc->req) > ARPC_OUT_SIZE_MAX)
889 rpc = kzalloc(sizeof(*rpc), GFP_KERNEL);
890 if (!rpc)
893 INIT_LIST_HEAD(&rpc->list);
894 rpc->req = kzalloc(sizeof(*rpc->req) + size, GFP_KERNEL);
895 if (!rpc->req)
898 rpc->resp = kzalloc(sizeof(*rpc->resp), GFP_KERNEL);
899 if (!rpc->resp)
902 rpc->req->type = type;
903 rpc->req->size = cpu_to_le16(sizeof(*rpc->req) + size);
904 memcpy(rpc->req->data, payload, size);
906 init_completion(&rpc->response_received);
908 return rpc;
911 kfree(rpc->req);
913 kfree(rpc);
918 static void arpc_free(struct arpc *rpc)
920 kfree(rpc->req);
921 kfree(rpc->resp);
922 kfree(rpc);
927 struct arpc *rpc;
929 list_for_each_entry(rpc, &es2->arpcs, list) {
930 if (rpc->req->id == id)
931 return rpc;
937 static void arpc_add(struct es2_ap_dev *es2, struct arpc *rpc)
939 rpc->active = true;
940 rpc->req->id = cpu_to_le16(es2->arpc_id_cycle++);
941 list_add_tail(&rpc->list, &es2->arpcs);
944 static void arpc_del(struct es2_ap_dev *es2, struct arpc *rpc)
946 if (rpc->active) {
947 rpc->active = false;
948 list_del(&rpc->list);
952 static int arpc_send(struct es2_ap_dev *es2, struct arpc *rpc, int timeout)
962 rpc->req, le16_to_cpu(rpc->req->size),
964 if (retval != le16_to_cpu(rpc->req->size)) {
967 rpc->req->type, retval);
979 struct arpc *rpc;
986 rpc = arpc_alloc(payload, size, type);
987 if (!rpc)
991 arpc_add(es2, rpc);
994 retval = arpc_send(es2, rpc, timeout);
999 &rpc->response_received,
1007 if (rpc->resp->result) {
1010 *result = rpc->resp->result;
1017 arpc_del(es2, rpc);
1019 arpc_free(rpc);
1034 struct arpc *rpc;
1058 rpc = arpc_find(es2, resp->id);
1059 if (!rpc) {
1066 arpc_del(es2, rpc);
1067 memcpy(rpc->resp, resp, sizeof(*resp));
1068 complete(&rpc->response_received);