int ps3_vuart_read_async()

in ps3-vuart.c [672:701]


int ps3_vuart_read_async(struct ps3_system_bus_device *dev, unsigned int bytes)
{
	struct ps3_vuart_port_priv *priv = to_port_priv(dev);
	unsigned long flags;

	if (priv->rx_list.work.trigger) {
		dev_dbg(&dev->core, "%s:%d: warning, multiple calls\n",
			__func__, __LINE__);
		return -EAGAIN;
	}

	BUG_ON(!bytes);

	spin_lock_irqsave(&priv->rx_list.lock, flags);
	if (priv->rx_list.bytes_held >= bytes) {
		dev_dbg(&dev->core, "%s:%d: schedule_work %xh bytes\n",
			__func__, __LINE__, bytes);
		schedule_work(&priv->rx_list.work.work);
		spin_unlock_irqrestore(&priv->rx_list.lock, flags);
		return 0;
	}

	priv->rx_list.work.trigger = bytes;
	spin_unlock_irqrestore(&priv->rx_list.lock, flags);

	dev_dbg(&dev->core, "%s:%d: waiting for %u(%xh) bytes\n", __func__,
		__LINE__, bytes, bytes);

	return 0;
}