Lines Matching refs:chan
31 struct rt_mbox_chan *chan; in rt_mbox_controller_register() local
51 chan = &ctrl->chans[0]; in rt_mbox_controller_register()
53 for (int i = 0; i < ctrl->num_chans; ++i, ++chan) in rt_mbox_controller_register()
55 chan->ctrl = ctrl; in rt_mbox_controller_register()
56 rt_spin_lock_init(&chan->lock); in rt_mbox_controller_register()
59 rt_timer_init(&chan->timer, timer_name, mbox_chan_timeout, chan, in rt_mbox_controller_register()
77 struct rt_mbox_chan *chan; in rt_mbox_controller_unregister() local
91 chan = &ctrl->chans[0]; in rt_mbox_controller_unregister()
93 for (int i = ctrl->num_chans - 1; i >= 0; --i, ++chan) in rt_mbox_controller_unregister()
103 rt_err_t rt_mbox_send(struct rt_mbox_chan *chan, const void *data, in rt_mbox_send() argument
112 if (!chan || !data) in rt_mbox_send()
117 ctrl = chan->ctrl; in rt_mbox_send()
118 client = chan->client; in rt_mbox_send()
120 level = rt_spin_lock_irqsave(&chan->lock); in rt_mbox_send()
127 chan->complete = RT_FALSE; in rt_mbox_send()
128 err = ctrl->ops->send(chan, data); in rt_mbox_send()
132 chan->data = (void *)data; in rt_mbox_send()
138 rt_timer_control(&chan->timer, RT_TIMER_CTRL_SET_TIME, &tick); in rt_mbox_send()
145 chan->complete = RT_TRUE; in rt_mbox_send()
148 rt_spin_unlock_irqrestore(&chan->lock, level); in rt_mbox_send()
152 rt_timer_start(&chan->timer); in rt_mbox_send()
158 void rt_mbox_send_done(struct rt_mbox_chan *chan, rt_err_t err) in rt_mbox_send_done() argument
163 level = rt_spin_lock_irqsave(&chan->lock); in rt_mbox_send_done()
165 data = chan->data; in rt_mbox_send_done()
166 chan->data = RT_NULL; in rt_mbox_send_done()
168 rt_spin_unlock_irqrestore(&chan->lock, level); in rt_mbox_send_done()
170 if (chan->client->tx_done) in rt_mbox_send_done()
172 chan->client->tx_done(chan->client, data, err); in rt_mbox_send_done()
175 chan->complete = RT_TRUE; in rt_mbox_send_done()
181 struct rt_mbox_chan *chan = param; in mbox_chan_timeout() local
183 if (!chan->complete) in mbox_chan_timeout()
188 rt_mbox_send_done(chan, err); in mbox_chan_timeout()
191 rt_bool_t rt_mbox_peek(struct rt_mbox_chan *chan) in rt_mbox_peek() argument
193 if (chan && chan->ctrl->ops->peek) in rt_mbox_peek()
195 return chan->ctrl->ops->peek(chan); in rt_mbox_peek()
201 rt_err_t rt_mbox_recv(struct rt_mbox_chan *chan, void *data) in rt_mbox_recv() argument
203 if (!chan || !data) in rt_mbox_recv()
208 if (chan->client->rx_callback) in rt_mbox_recv()
210 chan->client->rx_callback(chan->client, data); in rt_mbox_recv()
233 struct rt_mbox_chan *chan = RT_NULL; in rt_mbox_request_by_index() local
248 chan = rt_err_ptr(err); in rt_mbox_request_by_index()
281 chan = &ctrl->chans[index]; in rt_mbox_request_by_index()
288 chan = rt_err_ptr(index); in rt_mbox_request_by_index()
294 rt_err_t err = ctrl->ops->request(chan); in rt_mbox_request_by_index()
301 rt_mbox_release(chan); in rt_mbox_request_by_index()
302 chan = rt_err_ptr(err); in rt_mbox_request_by_index()
306 chan->client = client; in rt_mbox_request_by_index()
310 chan = rt_err_ptr(-RT_ENOSYS); in rt_mbox_request_by_index()
316 return chan; in rt_mbox_request_by_index()
340 rt_err_t rt_mbox_release(struct rt_mbox_chan *chan) in rt_mbox_release() argument
342 if (chan) in rt_mbox_release()
344 chan->ctrl->ops->release(chan); in rt_mbox_release()