Lines Matching full:channel

66  * struct hsc_channel - hsi_char internal channel data
67 * @ch: channel number
68 * @flags: Keeps state of the channel (open/close, reading, writing)
116 static void hsc_add_tail(struct hsc_channel *channel, struct hsi_msg *msg, in hsc_add_tail() argument
121 spin_lock_irqsave(&channel->lock, flags); in hsc_add_tail()
123 spin_unlock_irqrestore(&channel->lock, flags); in hsc_add_tail()
126 static struct hsi_msg *hsc_get_first_msg(struct hsc_channel *channel, in hsc_get_first_msg() argument
132 spin_lock_irqsave(&channel->lock, flags); in hsc_get_first_msg()
140 spin_unlock_irqrestore(&channel->lock, flags); in hsc_get_first_msg()
161 static void hsc_reset_list(struct hsc_channel *channel, struct list_head *l) in hsc_reset_list() argument
166 spin_lock_irqsave(&channel->lock, flags); in hsc_reset_list()
168 spin_unlock_irqrestore(&channel->lock, flags); in hsc_reset_list()
195 static inline int hsc_msgs_alloc(struct hsc_channel *channel) in hsc_msgs_alloc() argument
204 msg->channel = channel->ch; in hsc_msgs_alloc()
205 list_add_tail(&msg->link, &channel->free_msgs_list); in hsc_msgs_alloc()
210 hsc_free_list(&channel->free_msgs_list); in hsc_msgs_alloc()
228 struct hsc_channel *channel = cl_data->channels + msg->channel; in hsc_rx_completed() local
230 if (test_bit(HSC_CH_READ, &channel->flags)) { in hsc_rx_completed()
231 hsc_add_tail(channel, msg, &channel->rx_msgs_queue); in hsc_rx_completed()
232 wake_up(&channel->rx_wait); in hsc_rx_completed()
234 hsc_add_tail(channel, msg, &channel->free_msgs_list); in hsc_rx_completed()
248 struct hsc_channel *channel = cl_data->channels + msg->channel; in hsc_tx_completed() local
250 if (test_bit(HSC_CH_WRITE, &channel->flags)) { in hsc_tx_completed()
251 hsc_add_tail(channel, msg, &channel->tx_msgs_queue); in hsc_tx_completed()
252 wake_up(&channel->tx_wait); in hsc_tx_completed()
254 hsc_add_tail(channel, msg, &channel->free_msgs_list); in hsc_tx_completed()
276 struct hsc_channel *channel = cl_data->channels; in hsc_break_received() local
280 for (i = 0; i < HSC_DEVS; i++, channel++) { in hsc_break_received()
283 if (!test_bit(HSC_CH_READ, &channel->flags)) in hsc_break_received()
285 msg2 = hsc_get_first_msg(channel, &channel->free_msgs_list); in hsc_break_received()
288 clear_bit(HSC_CH_READ, &channel->flags); in hsc_break_received()
291 hsc_add_tail(channel, msg2, &channel->rx_msgs_queue); in hsc_break_received()
292 wake_up(&channel->rx_wait); in hsc_break_received()
415 struct hsc_channel *channel = file->private_data; in hsc_read() local
425 if (channel->ch >= channel->cl->rx_cfg.num_hw_channels) in hsc_read()
427 if (test_and_set_bit(HSC_CH_READ, &channel->flags)) in hsc_read()
429 msg = hsc_get_first_msg(channel, &channel->free_msgs_list); in hsc_read()
437 ret = hsi_async_read(channel->cl, msg); in hsc_read()
439 hsc_add_tail(channel, msg, &channel->free_msgs_list); in hsc_read()
443 ret = wait_event_interruptible(channel->rx_wait, in hsc_read()
444 !list_empty(&channel->rx_msgs_queue)); in hsc_read()
446 clear_bit(HSC_CH_READ, &channel->flags); in hsc_read()
447 hsi_flush(channel->cl); in hsc_read()
451 msg = hsc_get_first_msg(channel, &channel->rx_msgs_queue); in hsc_read()
463 hsc_add_tail(channel, msg, &channel->free_msgs_list); in hsc_read()
466 clear_bit(HSC_CH_READ, &channel->flags); in hsc_read()
474 struct hsc_channel *channel = file->private_data; in hsc_write() local
482 if (channel->ch >= channel->cl->tx_cfg.num_hw_channels) in hsc_write()
484 if (test_and_set_bit(HSC_CH_WRITE, &channel->flags)) in hsc_write()
486 msg = hsc_get_first_msg(channel, &channel->free_msgs_list); in hsc_write()
488 clear_bit(HSC_CH_WRITE, &channel->flags); in hsc_write()
498 ret = hsi_async_write(channel->cl, msg); in hsc_write()
502 ret = wait_event_interruptible(channel->tx_wait, in hsc_write()
503 !list_empty(&channel->tx_msgs_queue)); in hsc_write()
505 clear_bit(HSC_CH_WRITE, &channel->flags); in hsc_write()
506 hsi_flush(channel->cl); in hsc_write()
510 msg = hsc_get_first_msg(channel, &channel->tx_msgs_queue); in hsc_write()
517 hsc_add_tail(channel, msg, &channel->free_msgs_list); in hsc_write()
520 clear_bit(HSC_CH_WRITE, &channel->flags); in hsc_write()
527 struct hsc_channel *channel = file->private_data; in hsc_ioctl() local
535 hsi_flush(channel->cl); in hsc_ioctl()
541 if (test_and_set_bit(HSC_CH_WLINE, &channel->flags)) in hsc_ioctl()
543 ret = hsi_start_tx(channel->cl); in hsc_ioctl()
545 if (!test_and_clear_bit(HSC_CH_WLINE, &channel->flags)) in hsc_ioctl()
547 ret = hsi_stop_tx(channel->cl); in hsc_ioctl()
553 return hsc_break_send(channel->cl); in hsc_ioctl()
557 return hsc_rx_set(channel->cl, &rxc); in hsc_ioctl()
559 hsc_rx_get(channel->cl, &rxc); in hsc_ioctl()
566 return hsc_tx_set(channel->cl, &txc); in hsc_ioctl()
568 hsc_tx_get(channel->cl, &txc); in hsc_ioctl()
592 struct hsc_channel *channel; in hsc_open() local
599 channel = cl_data->channels + (iminor(inode) & HSC_CH_MASK); in hsc_open()
601 if (test_and_set_bit(HSC_CH_OPEN, &channel->flags)) { in hsc_open()
617 ret = hsc_msgs_alloc(channel); in hsc_open()
623 file->private_data = channel; in hsc_open()
635 struct hsc_channel *channel = file->private_data; in hsc_release() local
636 struct hsc_client_data *cl_data = channel->cl_data; in hsc_release()
640 if (test_and_clear_bit(HSC_CH_WLINE, &channel->flags)) in hsc_release()
641 hsi_stop_tx(channel->cl); in hsc_release()
643 hsc_reset_list(channel, &channel->rx_msgs_queue); in hsc_release()
644 hsc_reset_list(channel, &channel->tx_msgs_queue); in hsc_release()
645 hsc_reset_list(channel, &channel->free_msgs_list); in hsc_release()
646 clear_bit(HSC_CH_READ, &channel->flags); in hsc_release()
647 clear_bit(HSC_CH_WRITE, &channel->flags); in hsc_release()
648 clear_bit(HSC_CH_OPEN, &channel->flags); in hsc_release()
649 wake_up(&channel->rx_wait); in hsc_release()
650 wake_up(&channel->tx_wait); in hsc_release()
665 static void hsc_channel_init(struct hsc_channel *channel) in hsc_channel_init() argument
667 init_waitqueue_head(&channel->rx_wait); in hsc_channel_init()
668 init_waitqueue_head(&channel->tx_wait); in hsc_channel_init()
669 spin_lock_init(&channel->lock); in hsc_channel_init()
670 INIT_LIST_HEAD(&channel->free_msgs_list); in hsc_channel_init()
671 INIT_LIST_HEAD(&channel->rx_msgs_queue); in hsc_channel_init()
672 INIT_LIST_HEAD(&channel->tx_msgs_queue); in hsc_channel_init()
679 struct hsc_channel *channel; in hsc_probe() local
710 for (i = 0, channel = cl_data->channels; i < HSC_DEVS; i++, channel++) { in hsc_probe()
711 hsc_channel_init(channel); in hsc_probe()
712 channel->ch = i; in hsc_probe()
713 channel->cl = cl; in hsc_probe()
714 channel->cl_data = cl_data; in hsc_probe()
717 /* 1 hsi client -> N char devices (one for each channel) */ in hsc_probe()