Lines Matching defs:req
88 struct tb_cfg_request *req;
90 req = kzalloc(sizeof(*req), GFP_KERNEL);
91 if (!req)
94 kref_init(&req->kref);
96 return req;
101 * @req: Request whose refcount is increased
103 void tb_cfg_request_get(struct tb_cfg_request *req)
106 kref_get(&req->kref);
112 struct tb_cfg_request *req = container_of(kref, typeof(*req), kref);
114 kfree(req);
119 * @req: Request whose refcount is decreased
124 void tb_cfg_request_put(struct tb_cfg_request *req)
127 kref_put(&req->kref, tb_cfg_request_destroy);
132 struct tb_cfg_request *req)
134 WARN_ON(test_bit(TB_CFG_REQUEST_ACTIVE, &req->flags));
135 WARN_ON(req->ctl);
142 req->ctl = ctl;
143 list_add_tail(&req->list, &ctl->request_queue);
144 set_bit(TB_CFG_REQUEST_ACTIVE, &req->flags);
149 static void tb_cfg_request_dequeue(struct tb_cfg_request *req)
151 struct tb_ctl *ctl = req->ctl;
154 if (!test_bit(TB_CFG_REQUEST_ACTIVE, &req->flags)) {
159 list_del(&req->list);
160 clear_bit(TB_CFG_REQUEST_ACTIVE, &req->flags);
161 if (test_bit(TB_CFG_REQUEST_CANCELED, &req->flags))
166 static bool tb_cfg_request_is_active(struct tb_cfg_request *req)
168 return test_bit(TB_CFG_REQUEST_ACTIVE, &req->flags);
174 struct tb_cfg_request *req = NULL, *iter;
180 req = iter;
187 return req;
447 struct tb_cfg_request *req;
508 req = tb_cfg_request_find(pkg->ctl, pkg);
510 trace_tb_rx(pkg->ctl->index, frame->eof, pkg->buffer, frame->size, !req);
512 if (req) {
513 if (req->copy(req, pkg))
514 schedule_work(&req->work);
515 tb_cfg_request_put(req);
524 struct tb_cfg_request *req = container_of(work, typeof(*req), work);
526 if (!test_bit(TB_CFG_REQUEST_CANCELED, &req->flags))
527 req->callback(req->callback_data);
529 tb_cfg_request_dequeue(req);
530 tb_cfg_request_put(req);
536 * @req: Request to start
540 * This queues @req on the given control channel without waiting for it
543 int tb_cfg_request(struct tb_ctl *ctl, struct tb_cfg_request *req,
548 req->flags = 0;
549 req->callback = callback;
550 req->callback_data = callback_data;
551 INIT_WORK(&req->work, tb_cfg_request_work);
552 INIT_LIST_HEAD(&req->list);
554 tb_cfg_request_get(req);
555 ret = tb_cfg_request_enqueue(ctl, req);
559 ret = tb_ctl_tx(ctl, req->request, req->request_size,
560 req->request_type);
564 if (!req->response)
565 schedule_work(&req->work);
570 tb_cfg_request_dequeue(req);
572 tb_cfg_request_put(req);
579 * @req: Request to cancel
585 void tb_cfg_request_cancel(struct tb_cfg_request *req, int err)
587 set_bit(TB_CFG_REQUEST_CANCELED, &req->flags);
588 schedule_work(&req->work);
589 wait_event(tb_cfg_request_cancel_queue, !tb_cfg_request_is_active(req));
590 req->result.err = err;
601 * @req: Request to start
602 * @timeout_msec: Timeout how long to wait @req to complete
610 struct tb_cfg_request *req,
618 ret = tb_cfg_request(ctl, req, tb_cfg_request_complete, &done);
625 tb_cfg_request_cancel(req, -ETIMEDOUT);
627 flush_work(&req->work);
629 return req->result;
847 static bool tb_cfg_match(const struct tb_cfg_request *req,
855 if (pkg->frame.eof != req->response_type)
857 if (route != tb_cfg_get_route(req->request))
859 if (pkg->frame.size != req->response_size)
864 const struct cfg_read_pkg *req_hdr = req->request;
874 static bool tb_cfg_copy(struct tb_cfg_request *req, const struct ctl_pkg *pkg)
879 res = parse_header(pkg, req->response_size, req->response_type,
880 tb_cfg_get_route(req->request));
882 memcpy(req->response, pkg->buffer, req->response_size);
884 req->result = res;
904 struct tb_cfg_request *req;
906 req = tb_cfg_request_alloc();
907 if (!req) {
912 req->match = tb_cfg_match;
913 req->copy = tb_cfg_copy;
914 req->request = &request;
915 req->request_size = sizeof(request);
916 req->request_type = TB_CFG_PKG_RESET;
917 req->response = &reply;
918 req->response_size = sizeof(reply);
919 req->response_type = TB_CFG_PKG_RESET;
921 res = tb_cfg_request_sync(ctl, req, ctl->timeout_msec);
923 tb_cfg_request_put(req);
959 struct tb_cfg_request *req;
961 req = tb_cfg_request_alloc();
962 if (!req) {
969 req->match = tb_cfg_match;
970 req->copy = tb_cfg_copy;
971 req->request = &request;
972 req->request_size = sizeof(request);
973 req->request_type = TB_CFG_PKG_READ;
974 req->response = &reply;
975 req->response_size = 12 + 4 * length;
976 req->response_type = TB_CFG_PKG_READ;
978 res = tb_cfg_request_sync(ctl, req, timeout_msec);
980 tb_cfg_request_put(req);
1032 struct tb_cfg_request *req;
1034 req = tb_cfg_request_alloc();
1035 if (!req) {
1042 req->match = tb_cfg_match;
1043 req->copy = tb_cfg_copy;
1044 req->request = &request;
1045 req->request_size = 12 + 4 * length;
1046 req->request_type = TB_CFG_PKG_WRITE;
1047 req->response = &reply;
1048 req->response_size = sizeof(reply);
1049 req->response_type = TB_CFG_PKG_WRITE;
1051 res = tb_cfg_request_sync(ctl, req, timeout_msec);
1053 tb_cfg_request_put(req);