Lines Matching refs:channel
129 static void hsc_add_tail(struct hsc_channel *channel, struct hsi_msg *msg, in hsc_add_tail() argument
134 spin_lock_irqsave(&channel->lock, flags); in hsc_add_tail()
136 spin_unlock_irqrestore(&channel->lock, flags); in hsc_add_tail()
139 static struct hsi_msg *hsc_get_first_msg(struct hsc_channel *channel, in hsc_get_first_msg() argument
145 spin_lock_irqsave(&channel->lock, flags); in hsc_get_first_msg()
153 spin_unlock_irqrestore(&channel->lock, flags); in hsc_get_first_msg()
174 static void hsc_reset_list(struct hsc_channel *channel, struct list_head *l) in hsc_reset_list() argument
179 spin_lock_irqsave(&channel->lock, flags); in hsc_reset_list()
181 spin_unlock_irqrestore(&channel->lock, flags); in hsc_reset_list()
208 static inline int hsc_msgs_alloc(struct hsc_channel *channel) in hsc_msgs_alloc() argument
217 msg->channel = channel->ch; in hsc_msgs_alloc()
218 list_add_tail(&msg->link, &channel->free_msgs_list); in hsc_msgs_alloc()
223 hsc_free_list(&channel->free_msgs_list); in hsc_msgs_alloc()
241 struct hsc_channel *channel = cl_data->channels + msg->channel; in hsc_rx_completed() local
243 if (test_bit(HSC_CH_READ, &channel->flags)) { in hsc_rx_completed()
244 hsc_add_tail(channel, msg, &channel->rx_msgs_queue); in hsc_rx_completed()
245 wake_up(&channel->rx_wait); in hsc_rx_completed()
247 hsc_add_tail(channel, msg, &channel->free_msgs_list); in hsc_rx_completed()
261 struct hsc_channel *channel = cl_data->channels + msg->channel; in hsc_tx_completed() local
263 if (test_bit(HSC_CH_WRITE, &channel->flags)) { in hsc_tx_completed()
264 hsc_add_tail(channel, msg, &channel->tx_msgs_queue); in hsc_tx_completed()
265 wake_up(&channel->tx_wait); in hsc_tx_completed()
267 hsc_add_tail(channel, msg, &channel->free_msgs_list); in hsc_tx_completed()
289 struct hsc_channel *channel = cl_data->channels; in hsc_break_received() local
293 for (i = 0; i < HSC_DEVS; i++, channel++) { in hsc_break_received()
296 if (!test_bit(HSC_CH_READ, &channel->flags)) in hsc_break_received()
298 msg2 = hsc_get_first_msg(channel, &channel->free_msgs_list); in hsc_break_received()
301 clear_bit(HSC_CH_READ, &channel->flags); in hsc_break_received()
304 hsc_add_tail(channel, msg2, &channel->rx_msgs_queue); in hsc_break_received()
305 wake_up(&channel->rx_wait); in hsc_break_received()
428 struct hsc_channel *channel = file->private_data; in hsc_read() local
438 if (channel->ch >= channel->cl->rx_cfg.channels) in hsc_read()
440 if (test_and_set_bit(HSC_CH_READ, &channel->flags)) in hsc_read()
442 msg = hsc_get_first_msg(channel, &channel->free_msgs_list); 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()
456 ret = wait_event_interruptible(channel->rx_wait, in hsc_read()
457 !list_empty(&channel->rx_msgs_queue)); in hsc_read()
459 clear_bit(HSC_CH_READ, &channel->flags); in hsc_read()
460 hsi_flush(channel->cl); in hsc_read()
464 msg = hsc_get_first_msg(channel, &channel->rx_msgs_queue); in hsc_read()
476 hsc_add_tail(channel, msg, &channel->free_msgs_list); in hsc_read()
479 clear_bit(HSC_CH_READ, &channel->flags); in hsc_read()
487 struct hsc_channel *channel = file->private_data; in hsc_write() local
495 if (channel->ch >= channel->cl->tx_cfg.channels) in hsc_write()
497 if (test_and_set_bit(HSC_CH_WRITE, &channel->flags)) in hsc_write()
499 msg = hsc_get_first_msg(channel, &channel->free_msgs_list); in hsc_write()
501 clear_bit(HSC_CH_WRITE, &channel->flags); in hsc_write()
511 ret = hsi_async_write(channel->cl, msg); in hsc_write()
515 ret = wait_event_interruptible(channel->tx_wait, in hsc_write()
516 !list_empty(&channel->tx_msgs_queue)); in hsc_write()
518 clear_bit(HSC_CH_WRITE, &channel->flags); in hsc_write()
519 hsi_flush(channel->cl); in hsc_write()
523 msg = hsc_get_first_msg(channel, &channel->tx_msgs_queue); in hsc_write()
530 hsc_add_tail(channel, msg, &channel->free_msgs_list); in hsc_write()
533 clear_bit(HSC_CH_WRITE, &channel->flags); in hsc_write()
540 struct hsc_channel *channel = file->private_data; in hsc_ioctl() local
548 hsi_flush(channel->cl); in hsc_ioctl()
554 if (test_and_set_bit(HSC_CH_WLINE, &channel->flags)) in hsc_ioctl()
556 ret = hsi_start_tx(channel->cl); in hsc_ioctl()
558 if (!test_and_clear_bit(HSC_CH_WLINE, &channel->flags)) in hsc_ioctl()
560 ret = hsi_stop_tx(channel->cl); in hsc_ioctl()
566 return hsc_break_send(channel->cl); in hsc_ioctl()
570 return hsc_rx_set(channel->cl, &rxc); in hsc_ioctl()
572 hsc_rx_get(channel->cl, &rxc); in hsc_ioctl()
579 return hsc_tx_set(channel->cl, &txc); in hsc_ioctl()
581 hsc_tx_get(channel->cl, &txc); in hsc_ioctl()
605 struct hsc_channel *channel; in hsc_open() local
612 channel = cl_data->channels + (iminor(inode) & HSC_CH_MASK); in hsc_open()
614 if (test_and_set_bit(HSC_CH_OPEN, &channel->flags)) { in hsc_open()
630 ret = hsc_msgs_alloc(channel); in hsc_open()
636 file->private_data = channel; in hsc_open()
648 struct hsc_channel *channel = file->private_data; in hsc_release() local
649 struct hsc_client_data *cl_data = channel->cl_data; in hsc_release()
653 if (test_and_clear_bit(HSC_CH_WLINE, &channel->flags)) in hsc_release()
654 hsi_stop_tx(channel->cl); in hsc_release()
656 hsc_reset_list(channel, &channel->rx_msgs_queue); in hsc_release()
657 hsc_reset_list(channel, &channel->tx_msgs_queue); in hsc_release()
658 hsc_reset_list(channel, &channel->free_msgs_list); in hsc_release()
659 clear_bit(HSC_CH_READ, &channel->flags); in hsc_release()
660 clear_bit(HSC_CH_WRITE, &channel->flags); in hsc_release()
661 clear_bit(HSC_CH_OPEN, &channel->flags); in hsc_release()
662 wake_up(&channel->rx_wait); in hsc_release()
663 wake_up(&channel->tx_wait); in hsc_release()
678 static void hsc_channel_init(struct hsc_channel *channel) in hsc_channel_init() argument
680 init_waitqueue_head(&channel->rx_wait); in hsc_channel_init()
681 init_waitqueue_head(&channel->tx_wait); in hsc_channel_init()
682 spin_lock_init(&channel->lock); in hsc_channel_init()
683 INIT_LIST_HEAD(&channel->free_msgs_list); in hsc_channel_init()
684 INIT_LIST_HEAD(&channel->rx_msgs_queue); in hsc_channel_init()
685 INIT_LIST_HEAD(&channel->tx_msgs_queue); in hsc_channel_init()
692 struct hsc_channel *channel; in hsc_probe() local
724 for (i = 0, channel = cl_data->channels; i < HSC_DEVS; i++, channel++) { in hsc_probe()
725 hsc_channel_init(channel); in hsc_probe()
726 channel->ch = i; in hsc_probe()
727 channel->cl = cl; in hsc_probe()
728 channel->cl_data = cl_data; in hsc_probe()