/* If the device is not connected, data is ignored and the function returns @count. If the buffer is full, the function returns 0. If an existing IUCV communicaton path has been severed, -EPIPE is returned (that can be passed to HVC layer to cause a tty hangup).  */
static int hvc_iucv_queue(struct hvc_iucv_private *priv, const char *buf, int count)
/* If the device is not connected, data is ignored and the function returns @count. If the buffer is full, the function returns 0. If an existing IUCV communicaton path has been severed, -EPIPE is returned (that can be passed to HVC layer to cause a tty hangup).  */
static int hvc_iucv_queue(struct hvc_iucv_private *priv, const char *buf, int count)
{
	size_t len;
	if (priv->iucv_state == IUCV_DISCONN)
		return count;
	if (priv->iucv_state == IUCV_SEVERED)
		return -EPIPE;
	len = min_t(size_t, count, SNDBUF_SIZE - priv->sndbuf_len);
	if (!len)
		return 0;
	memcpy(priv->sndbuf + priv->sndbuf_len, buf, len);
	priv->sndbuf_len += len;
	if (priv->iucv_state == IUCV_CONNECTED)
		schedule_delayed_work(&priv->sndbuf_work, QUEUE_SNDBUF_DELAY);
	return len;
}