/* * Get the next TX message in the TX FIFO and send it to the device * * Note we exit the loop if i2400mu_tx() fails; that funtion only * fails on hard error (failing to tx a buffer not being one of them, * see its doc). * * Return: 0 */ static int i2400mu_txd(void *_i2400mu) { int result = 0; struct i2400mu *i2400mu = _i2400mu; struct i2400m *i2400m = &i2400mu->i2400m; struct device *dev = &i2400mu->usb_iface->dev; struct i2400m_msg_hdr *tx_msg; size_t tx_msg_size; d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu); while (1) { d_printf(2, dev, "TX: waiting for messages\n"); tx_msg = NULL; wait_event_interruptible( i2400mu->tx_wq, (kthread_should_stop() /* check this first! */ || (tx_msg = i2400m_tx_msg_get(i2400m, &tx_msg_size))) ); if (kthread_should_stop()) break; WARN_ON(tx_msg == NULL); /* should not happen...*/ d_printf(2, dev, "TX: submitting %zu bytes\n", tx_msg_size); d_dump(5, dev, tx_msg, tx_msg_size); /* Yeah, we ignore errors ... not much we can do */ i2400mu_tx(i2400mu, tx_msg, tx_msg_size); i2400m_tx_msg_sent(i2400m); /* ack it, advance the FIFO */ if (result < 0) break; } d_fnend(4, dev, "(i2400mu %p) = %d\n", i2400mu, result); return result; }
static int i2400mu_txd(void *_i2400mu) { struct i2400mu *i2400mu = _i2400mu; struct i2400m *i2400m = &i2400mu->i2400m; struct device *dev = &i2400mu->usb_iface->dev; struct i2400m_msg_hdr *tx_msg; size_t tx_msg_size; unsigned long flags; d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu); spin_lock_irqsave(&i2400m->tx_lock, flags); BUG_ON(i2400mu->tx_kthread != NULL); i2400mu->tx_kthread = current; spin_unlock_irqrestore(&i2400m->tx_lock, flags); while (1) { d_printf(2, dev, "TX: waiting for messages\n"); tx_msg = NULL; wait_event_interruptible( i2400mu->tx_wq, (kthread_should_stop() /* */ || (tx_msg = i2400m_tx_msg_get(i2400m, &tx_msg_size))) ); if (kthread_should_stop()) break; WARN_ON(tx_msg == NULL); /* */ d_printf(2, dev, "TX: submitting %zu bytes\n", tx_msg_size); d_dump(5, dev, tx_msg, tx_msg_size); /* */ i2400mu_tx(i2400mu, tx_msg, tx_msg_size); i2400m_tx_msg_sent(i2400m); /* */ } spin_lock_irqsave(&i2400m->tx_lock, flags); i2400mu->tx_kthread = NULL; spin_unlock_irqrestore(&i2400m->tx_lock, flags); d_fnend(4, dev, "(i2400mu %p)\n", i2400mu); return 0; }