Lines Matching refs:i2400m
323 size_t __i2400m_tx_tail_room(struct i2400m *i2400m) in __i2400m_tx_tail_room() argument
328 if (unlikely(i2400m->tx_in == 0)) in __i2400m_tx_tail_room()
330 tx_in = i2400m->tx_in % I2400M_TX_BUF_SIZE; in __i2400m_tx_tail_room()
434 void *i2400m_tx_fifo_push(struct i2400m *i2400m, size_t size, in i2400m_tx_fifo_push() argument
437 struct device *dev = i2400m_dev(i2400m); in i2400m_tx_fifo_push()
442 room = I2400M_TX_BUF_SIZE - (i2400m->tx_in - i2400m->tx_out); in i2400m_tx_fifo_push()
449 tail_room = __i2400m_tx_tail_room(i2400m); in i2400m_tx_fifo_push()
474 ptr = i2400m->tx_buf + i2400m->tx_in % I2400M_TX_BUF_SIZE; in i2400m_tx_fifo_push()
476 i2400m->tx_in % I2400M_TX_BUF_SIZE); in i2400m_tx_fifo_push()
477 i2400m->tx_in += size; in i2400m_tx_fifo_push()
505 void i2400m_tx_skip_tail(struct i2400m *i2400m) in i2400m_tx_skip_tail() argument
507 struct device *dev = i2400m_dev(i2400m); in i2400m_tx_skip_tail()
508 size_t tx_in = i2400m->tx_in % I2400M_TX_BUF_SIZE; in i2400m_tx_skip_tail()
509 size_t tail_room = __i2400m_tx_tail_room(i2400m); in i2400m_tx_skip_tail()
510 struct i2400m_msg_hdr *msg = i2400m->tx_buf + tx_in; in i2400m_tx_skip_tail()
517 i2400m->tx_in += tail_room; in i2400m_tx_skip_tail()
535 unsigned i2400m_tx_fits(struct i2400m *i2400m) in i2400m_tx_fits() argument
537 struct i2400m_msg_hdr *msg_hdr = i2400m->tx_msg; in i2400m_tx_fits()
561 void i2400m_tx_new(struct i2400m *i2400m) in i2400m_tx_new() argument
563 struct device *dev = i2400m_dev(i2400m); in i2400m_tx_new()
566 BUG_ON(i2400m->tx_msg != NULL); in i2400m_tx_new()
576 tx_msg = i2400m_tx_fifo_push(i2400m, I2400M_TX_PLD_SIZE, in i2400m_tx_new()
577 i2400m->bus_tx_room_min, try_head); in i2400m_tx_new()
581 i2400m_tx_skip_tail(i2400m); in i2400m_tx_new()
589 i2400m->tx_msg = tx_msg; in i2400m_tx_new()
591 tx_msg, (void *) tx_msg - i2400m->tx_buf); in i2400m_tx_new()
613 void i2400m_tx_close(struct i2400m *i2400m) in i2400m_tx_close() argument
615 struct device *dev = i2400m_dev(i2400m); in i2400m_tx_close()
616 struct i2400m_msg_hdr *tx_msg = i2400m->tx_msg; in i2400m_tx_close()
653 aligned_size = ALIGN(tx_msg_moved->size, i2400m->bus_tx_block_size); in i2400m_tx_close()
656 pad_buf = i2400m_tx_fifo_push(i2400m, padding, 0, 0); in i2400m_tx_close()
667 aligned_size, i2400m->tx_buf, i2400m->tx_in, in i2400m_tx_close()
668 i2400m->tx_out); in i2400m_tx_close()
677 i2400m->tx_msg = NULL; in i2400m_tx_close()
713 int i2400m_tx(struct i2400m *i2400m, const void *buf, size_t buf_len, in i2400m_tx() argument
717 struct device *dev = i2400m_dev(i2400m); in i2400m_tx()
726 i2400m, buf, buf_len, pl_type); in i2400m_tx()
732 spin_lock_irqsave(&i2400m->tx_lock, flags); in i2400m_tx()
734 if (i2400m->tx_buf == NULL) { in i2400m_tx()
739 if (unlikely(i2400m->tx_msg == NULL)) in i2400m_tx()
740 i2400m_tx_new(i2400m); in i2400m_tx()
741 else if (unlikely(!i2400m_tx_fits(i2400m) in i2400m_tx()
742 || (is_singleton && i2400m->tx_msg->num_pls != 0))) { in i2400m_tx()
744 "%u num_pls %u)\n", i2400m_tx_fits(i2400m), in i2400m_tx()
745 is_singleton, i2400m->tx_msg->num_pls); in i2400m_tx()
746 i2400m_tx_close(i2400m); in i2400m_tx()
747 i2400m_tx_new(i2400m); in i2400m_tx()
749 if (i2400m->tx_msg == NULL) in i2400m_tx()
757 if (i2400m->tx_msg->size + padded_len > I2400M_TX_MSG_SIZE) { in i2400m_tx()
759 i2400m_tx_close(i2400m); in i2400m_tx()
760 i2400m_tx_new(i2400m); in i2400m_tx()
762 if (i2400m->tx_msg == NULL) in i2400m_tx()
766 ptr = i2400m_tx_fifo_push(i2400m, padded_len, in i2400m_tx()
767 i2400m->bus_tx_block_size, try_head); in i2400m_tx()
770 i2400m_tx_close(i2400m); in i2400m_tx()
771 i2400m_tx_skip_tail(i2400m); in i2400m_tx()
778 struct i2400m_msg_hdr *tx_msg = i2400m->tx_msg; in i2400m_tx()
792 (void *)tx_msg - i2400m->tx_buf, (size_t)tx_msg->size, in i2400m_tx()
793 num_pls+1, ptr - i2400m->tx_buf, buf_len, padded_len); in i2400m_tx()
796 i2400m_tx_close(i2400m); in i2400m_tx()
799 spin_unlock_irqrestore(&i2400m->tx_lock, flags); in i2400m_tx()
803 i2400m->bus_tx_kick(i2400m); in i2400m_tx()
805 i2400m, buf, buf_len, pl_type, result); in i2400m_tx()
837 struct i2400m_msg_hdr *i2400m_tx_msg_get(struct i2400m *i2400m, in i2400m_tx_msg_get() argument
840 struct device *dev = i2400m_dev(i2400m); in i2400m_tx_msg_get()
844 d_fnstart(3, dev, "(i2400m %p bus_size %p)\n", i2400m, bus_size); in i2400m_tx_msg_get()
845 spin_lock_irqsave(&i2400m->tx_lock, flags); in i2400m_tx_msg_get()
847 if (i2400m->tx_buf == NULL) in i2400m_tx_msg_get()
851 if (i2400m->tx_in == i2400m->tx_out) { /* Empty FIFO? */ in i2400m_tx_msg_get()
852 i2400m->tx_in = 0; in i2400m_tx_msg_get()
853 i2400m->tx_out = 0; in i2400m_tx_msg_get()
857 tx_msg = i2400m->tx_buf + i2400m->tx_out % I2400M_TX_BUF_SIZE; in i2400m_tx_msg_get()
860 i2400m->tx_out % I2400M_TX_BUF_SIZE, in i2400m_tx_msg_get()
862 i2400m->tx_out += tx_msg->size & ~I2400M_TX_SKIP; in i2400m_tx_msg_get()
867 if (tx_msg == i2400m->tx_msg) { /* open, we are done */ in i2400m_tx_msg_get()
870 (void *) tx_msg - i2400m->tx_buf); in i2400m_tx_msg_get()
876 (void *) tx_msg - i2400m->tx_buf, in i2400m_tx_msg_get()
878 i2400m->tx_out += tx_msg->size & ~I2400M_TX_SKIP; in i2400m_tx_msg_get()
882 if (tx_msg == i2400m->tx_msg) /* open msg? */ in i2400m_tx_msg_get()
883 i2400m_tx_close(i2400m); in i2400m_tx_msg_get()
887 i2400m->tx_msg_size = tx_msg->size; in i2400m_tx_msg_get()
891 current->pid, (void *) tx_msg - i2400m->tx_buf, in i2400m_tx_msg_get()
895 tx_msg_moved->sequence = le32_to_cpu(i2400m->tx_sequence++); in i2400m_tx_msg_get()
898 i2400m->tx_pl_num += pls; /* Update stats */ in i2400m_tx_msg_get()
899 if (pls > i2400m->tx_pl_max) in i2400m_tx_msg_get()
900 i2400m->tx_pl_max = pls; in i2400m_tx_msg_get()
901 if (pls < i2400m->tx_pl_min) in i2400m_tx_msg_get()
902 i2400m->tx_pl_min = pls; in i2400m_tx_msg_get()
903 i2400m->tx_num++; in i2400m_tx_msg_get()
904 i2400m->tx_size_acc += *bus_size; in i2400m_tx_msg_get()
905 if (*bus_size < i2400m->tx_size_min) in i2400m_tx_msg_get()
906 i2400m->tx_size_min = *bus_size; in i2400m_tx_msg_get()
907 if (*bus_size > i2400m->tx_size_max) in i2400m_tx_msg_get()
908 i2400m->tx_size_max = *bus_size; in i2400m_tx_msg_get()
910 spin_unlock_irqrestore(&i2400m->tx_lock, flags); in i2400m_tx_msg_get()
912 i2400m, bus_size, *bus_size, tx_msg_moved); in i2400m_tx_msg_get()
930 void i2400m_tx_msg_sent(struct i2400m *i2400m) in i2400m_tx_msg_sent() argument
934 struct device *dev = i2400m_dev(i2400m); in i2400m_tx_msg_sent()
936 d_fnstart(3, dev, "(i2400m %p)\n", i2400m); in i2400m_tx_msg_sent()
937 spin_lock_irqsave(&i2400m->tx_lock, flags); in i2400m_tx_msg_sent()
938 if (i2400m->tx_buf == NULL) in i2400m_tx_msg_sent()
940 i2400m->tx_out += i2400m->tx_msg_size; in i2400m_tx_msg_sent()
941 d_printf(2, dev, "TX: sent %zu b\n", (size_t) i2400m->tx_msg_size); in i2400m_tx_msg_sent()
942 i2400m->tx_msg_size = 0; in i2400m_tx_msg_sent()
943 BUG_ON(i2400m->tx_out > i2400m->tx_in); in i2400m_tx_msg_sent()
945 n = i2400m->tx_out / I2400M_TX_BUF_SIZE; in i2400m_tx_msg_sent()
946 i2400m->tx_out %= I2400M_TX_BUF_SIZE; in i2400m_tx_msg_sent()
947 i2400m->tx_in -= n * I2400M_TX_BUF_SIZE; in i2400m_tx_msg_sent()
949 spin_unlock_irqrestore(&i2400m->tx_lock, flags); in i2400m_tx_msg_sent()
950 d_fnend(3, dev, "(i2400m %p) = void\n", i2400m); in i2400m_tx_msg_sent()
963 int i2400m_tx_setup(struct i2400m *i2400m) in i2400m_tx_setup() argument
972 INIT_WORK(&i2400m->wake_tx_ws, i2400m_wake_tx_work); in i2400m_tx_setup()
985 spin_lock_irqsave(&i2400m->tx_lock, flags); in i2400m_tx_setup()
986 i2400m->tx_sequence = 0; in i2400m_tx_setup()
987 i2400m->tx_in = 0; in i2400m_tx_setup()
988 i2400m->tx_out = 0; in i2400m_tx_setup()
989 i2400m->tx_msg_size = 0; in i2400m_tx_setup()
990 i2400m->tx_msg = NULL; in i2400m_tx_setup()
991 i2400m->tx_buf = tx_buf; in i2400m_tx_setup()
992 spin_unlock_irqrestore(&i2400m->tx_lock, flags); in i2400m_tx_setup()
994 BUG_ON(i2400m->bus_tx_block_size == 0); in i2400m_tx_setup()
1004 void i2400m_tx_release(struct i2400m *i2400m) in i2400m_tx_release() argument
1007 spin_lock_irqsave(&i2400m->tx_lock, flags); in i2400m_tx_release()
1008 kfree(i2400m->tx_buf); in i2400m_tx_release()
1009 i2400m->tx_buf = NULL; in i2400m_tx_release()
1010 spin_unlock_irqrestore(&i2400m->tx_lock, flags); in i2400m_tx_release()