mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jean Tourrilhes <jt@bougret.hpl.hp.com>
To: "David S. Miller" <davem@redhat.com>,
	Linux kernel mailing list <linux-kernel@vger.kernel.org>
Subject: [PATCH 2.6 IrDA] sir-dev raw mode fix
Date: Wed, 7 Jan 2004 18:33:57 -0800	[thread overview]
Message-ID: <20040108023357.GD13620@bougret.hpl.hp.com> (raw)

irXXX_sirdev_rawmode.diff :
~~~~~~~~~~~~~~~~~~~~~~~~~
		<Apply *after* irXXX_sirdev_txlock.diff patch>
		<Patch from Martin Diehl>
	o [CORRECT] Fix sir-dev 'raw' mode for sir dongles that need it


diff -urp linux-2.6.0-test9-bk22/drivers/net/irda/sir-dev.h v2.6.0-md/drivers/net/irda/sir-dev.h
--- linux-2.6.0-test9-bk22/drivers/net/irda/sir-dev.h	Wed Oct  8 21:24:07 2003
+++ v2.6.0-md/drivers/net/irda/sir-dev.h	Mon Nov 17 18:51:41 2003
@@ -179,6 +179,7 @@ struct sir_dev {
 
 	struct sir_fsm fsm;
 	atomic_t enable_rx;
+	int raw_tx;
 	spinlock_t tx_lock;
 
 	u32 new_speed;
diff -urp linux-2.6.0-test9-bk22/drivers/net/irda/sir_dev.c v2.6.0-md/drivers/net/irda/sir_dev.c
--- linux-2.6.0-test9-bk22/drivers/net/irda/sir_dev.c	Mon Nov 17 17:39:54 2003
+++ v2.6.0-md/drivers/net/irda/sir_dev.c	Mon Nov 17 18:51:41 2003
@@ -31,7 +31,9 @@ void sirdev_enable_rx(struct sir_dev *de
 
 	/* flush rx-buffer - should also help in case of problems with echo cancelation */
 	dev->rx_buff.data = dev->rx_buff.head;
-	dev->tx_buff.len = 0;
+	dev->rx_buff.len = 0;
+	dev->rx_buff.in_frame = FALSE;
+	dev->rx_buff.state = OUTSIDE_FRAME;
 	atomic_set(&dev->enable_rx, 1);
 }
 
@@ -78,8 +80,17 @@ int sirdev_raw_write(struct sir_dev *dev
 
 	dev->tx_buff.data = dev->tx_buff.head;
 	memcpy(dev->tx_buff.data, buf, len);	
+	dev->tx_buff.len = len;
 
 	ret = dev->drv->do_write(dev, dev->tx_buff.data, dev->tx_buff.len);
+	if (ret > 0) {
+		IRDA_DEBUG(3, "%s(), raw-tx started\n", __FUNCTION__);
+
+		dev->tx_buff.data += ret;
+		dev->tx_buff.len -= ret;
+		dev->raw_tx = 1;
+		ret = len;		/* all data is going to be sent */
+	}
 	spin_unlock_irqrestore(&dev->tx_lock, flags);
 	return ret;
 }
@@ -95,13 +106,13 @@ int sirdev_raw_read(struct sir_dev *dev,
 
 	count = (len < dev->rx_buff.len) ? len : dev->rx_buff.len;
 
-	if (count > 0)
-		memcpy(buf, dev->rx_buff.head, count);
+	if (count > 0) {
+		memcpy(buf, dev->rx_buff.data, count);
+		dev->rx_buff.data += count;
+		dev->rx_buff.len -= count;
+	}
 
-	/* forget trailing stuff */
-	dev->rx_buff.data = dev->rx_buff.head;
-	dev->rx_buff.len = 0;
-	dev->rx_buff.state = OUTSIDE_FRAME;
+	/* remaining stuff gets flushed when re-enabling normal rx */
 
 	return count;
 }
@@ -150,6 +161,19 @@ void sirdev_write_complete(struct sir_de
 		}
 	}
 
+	if (unlikely(dev->raw_tx != 0)) {
+		/* in raw mode we are just done now after the buffer was sent
+		 * completely. Since this was requested by some dongle driver
+		 * running under the control of the irda-thread we must take
+		 * care here not to re-enable the queue. The queue will be
+		 * restarted when the irda-thread has completed the request.
+		 */
+
+		IRDA_DEBUG(3, "%s(), raw-tx done\n", __FUNCTION__);
+		dev->raw_tx = 0;
+		return;
+	}
+
 	/* we have finished now sending this skb.
 	 * update statistics and free the skb.
 	 * finally we check and trigger a pending speed change, if any.
@@ -482,6 +506,7 @@ static int sirdev_open(struct net_device
 		goto errout_free;
 
 	sirdev_enable_rx(dev);
+	dev->raw_tx = 0;
 
 	netif_start_queue(ndev);
 	dev->irlap = irlap_open(ndev, &dev->qos, dev->hwname);


                 reply	other threads:[~2004-01-08  2:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040108023357.GD13620@bougret.hpl.hp.com \
    --to=jt@bougret.hpl.hp.com \
    --cc=davem@redhat.com \
    --cc=jt@hpl.hp.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome