Lines Matching refs:msg

129 static void hsc_add_tail(struct hsc_channel *channel, struct hsi_msg *msg,  in hsc_add_tail()  argument
135 list_add_tail(&msg->link, queue); in hsc_add_tail()
142 struct hsi_msg *msg = NULL; in hsc_get_first_msg() local
150 msg = list_first_entry(queue, struct hsi_msg, link); in hsc_get_first_msg()
151 list_del(&msg->link); in hsc_get_first_msg()
155 return msg; in hsc_get_first_msg()
158 static inline void hsc_msg_free(struct hsi_msg *msg) in hsc_msg_free() argument
160 kfree(sg_virt(msg->sgt.sgl)); in hsc_msg_free()
161 hsi_free_msg(msg); in hsc_msg_free()
166 struct hsi_msg *msg, *tmp; in hsc_free_list() local
168 list_for_each_entry_safe(msg, tmp, list, link) { in hsc_free_list()
169 list_del(&msg->link); in hsc_free_list()
170 hsc_msg_free(msg); in hsc_free_list()
188 struct hsi_msg *msg; in hsc_msg_alloc() local
191 msg = hsi_alloc_msg(1, GFP_KERNEL); in hsc_msg_alloc()
192 if (!msg) in hsc_msg_alloc()
196 hsi_free_msg(msg); in hsc_msg_alloc()
199 sg_init_one(msg->sgt.sgl, buf, alloc_size); in hsc_msg_alloc()
203 return msg; in hsc_msg_alloc()
210 struct hsi_msg *msg; in hsc_msgs_alloc() local
214 msg = hsc_msg_alloc(max_data_size); in hsc_msgs_alloc()
215 if (!msg) in hsc_msgs_alloc()
217 msg->channel = channel->ch; in hsc_msgs_alloc()
218 list_add_tail(&msg->link, &channel->free_msgs_list); in hsc_msgs_alloc()
228 static inline unsigned int hsc_msg_len_get(struct hsi_msg *msg) in hsc_msg_len_get() argument
230 return msg->sgt.sgl->length; in hsc_msg_len_get()
233 static inline void hsc_msg_len_set(struct hsi_msg *msg, unsigned int len) in hsc_msg_len_set() argument
235 msg->sgt.sgl->length = len; in hsc_msg_len_set()
238 static void hsc_rx_completed(struct hsi_msg *msg) in hsc_rx_completed() argument
240 struct hsc_client_data *cl_data = hsi_client_drvdata(msg->cl); in hsc_rx_completed()
241 struct hsc_channel *channel = cl_data->channels + msg->channel; in hsc_rx_completed()
244 hsc_add_tail(channel, msg, &channel->rx_msgs_queue); in hsc_rx_completed()
247 hsc_add_tail(channel, msg, &channel->free_msgs_list); in hsc_rx_completed()
251 static void hsc_rx_msg_destructor(struct hsi_msg *msg) in hsc_rx_msg_destructor() argument
253 msg->status = HSI_STATUS_ERROR; in hsc_rx_msg_destructor()
254 hsc_msg_len_set(msg, 0); in hsc_rx_msg_destructor()
255 hsc_rx_completed(msg); in hsc_rx_msg_destructor()
258 static void hsc_tx_completed(struct hsi_msg *msg) in hsc_tx_completed() argument
260 struct hsc_client_data *cl_data = hsi_client_drvdata(msg->cl); in hsc_tx_completed()
261 struct hsc_channel *channel = cl_data->channels + msg->channel; in hsc_tx_completed()
264 hsc_add_tail(channel, msg, &channel->tx_msgs_queue); in hsc_tx_completed()
267 hsc_add_tail(channel, msg, &channel->free_msgs_list); in hsc_tx_completed()
271 static void hsc_tx_msg_destructor(struct hsi_msg *msg) in hsc_tx_msg_destructor() argument
273 msg->status = HSI_STATUS_ERROR; in hsc_tx_msg_destructor()
274 hsc_msg_len_set(msg, 0); in hsc_tx_msg_destructor()
275 hsc_tx_completed(msg); in hsc_tx_msg_destructor()
278 static void hsc_break_req_destructor(struct hsi_msg *msg) in hsc_break_req_destructor() argument
280 struct hsc_client_data *cl_data = hsi_client_drvdata(msg->cl); in hsc_break_req_destructor()
282 hsi_free_msg(msg); in hsc_break_req_destructor()
286 static void hsc_break_received(struct hsi_msg *msg) in hsc_break_received() argument
288 struct hsc_client_data *cl_data = hsi_client_drvdata(msg->cl); in hsc_break_received()
307 hsi_flush(msg->cl); in hsc_break_received()
308 ret = hsi_async_read(msg->cl, msg); in hsc_break_received()
310 hsc_break_req_destructor(msg); in hsc_break_received()
316 struct hsi_msg *msg; in hsc_break_request() local
322 msg = hsi_alloc_msg(0, GFP_KERNEL); in hsc_break_request()
323 if (!msg) { in hsc_break_request()
327 msg->break_frame = 1; in hsc_break_request()
328 msg->complete = hsc_break_received; in hsc_break_request()
329 msg->destructor = hsc_break_req_destructor; in hsc_break_request()
330 ret = hsi_async_read(cl, msg); in hsc_break_request()
332 hsc_break_req_destructor(msg); in hsc_break_request()
339 struct hsi_msg *msg; in hsc_break_send() local
342 msg = hsi_alloc_msg(0, GFP_ATOMIC); in hsc_break_send()
343 if (!msg) in hsc_break_send()
345 msg->break_frame = 1; in hsc_break_send()
346 msg->complete = hsi_free_msg; in hsc_break_send()
347 msg->destructor = hsi_free_msg; in hsc_break_send()
348 ret = hsi_async_write(cl, msg); in hsc_break_send()
350 hsi_free_msg(msg); in hsc_break_send()
429 struct hsi_msg *msg; in hsc_read() local
442 msg = hsc_get_first_msg(channel, &channel->free_msgs_list); in hsc_read()
443 if (!msg) { in hsc_read()
447 hsc_msg_len_set(msg, len); in hsc_read()
448 msg->complete = hsc_rx_completed; in hsc_read()
449 msg->destructor = hsc_rx_msg_destructor; in hsc_read()
450 ret = hsi_async_read(channel->cl, msg); in hsc_read()
452 hsc_add_tail(channel, msg, &channel->free_msgs_list); in hsc_read()
464 msg = hsc_get_first_msg(channel, &channel->rx_msgs_queue); in hsc_read()
465 if (msg) { in hsc_read()
466 if (msg->status != HSI_STATUS_ERROR) { in hsc_read()
468 sg_virt(msg->sgt.sgl), hsc_msg_len_get(msg)); in hsc_read()
472 ret = hsc_msg_len_get(msg); in hsc_read()
476 hsc_add_tail(channel, msg, &channel->free_msgs_list); in hsc_read()
488 struct hsi_msg *msg; in hsc_write() local
499 msg = hsc_get_first_msg(channel, &channel->free_msgs_list); in hsc_write()
500 if (!msg) { in hsc_write()
504 if (copy_from_user(sg_virt(msg->sgt.sgl), (void __user *)buf, len)) { in hsc_write()
508 hsc_msg_len_set(msg, len); in hsc_write()
509 msg->complete = hsc_tx_completed; in hsc_write()
510 msg->destructor = hsc_tx_msg_destructor; in hsc_write()
511 ret = hsi_async_write(channel->cl, msg); in hsc_write()
523 msg = hsc_get_first_msg(channel, &channel->tx_msgs_queue); in hsc_write()
524 if (msg) { in hsc_write()
525 if (msg->status == HSI_STATUS_ERROR) in hsc_write()
528 ret = hsc_msg_len_get(msg); in hsc_write()
530 hsc_add_tail(channel, msg, &channel->free_msgs_list); in hsc_write()