From effa0a16cd57c9f778b59e6be04b9d41736502f7 Mon Sep 17 00:00:00 2001
From: joerg_wunsch <joerg_wunsch@81a1dc3b-b13d-400b-aceb-764788c761c2>
Date: Tue, 15 May 2007 20:30:15 +0000
Subject: [PATCH] In ser_send(), don't select() on the output fd before trying
 to write something to the serial line.  That kind of polling isn't very
 useful anyway, and it seems it breaks for the Linux CP210x USB<->RS-232
 bridge driver which is certainly a bug in the driver, but we can just avoid
 that bug alltogether.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@736 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 ChangeLog   |  8 ++++++++
 ser_posix.c | 25 -------------------------
 2 files changed, 8 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7bcd5210..5ce7ac97 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-05-15 Joerg Wunsch <j@uriah.heep.sax.de>
+
+	* ser_posix.c (ser_send): Don't select() on the output fd before
+	trying to write something to the serial line.  That kind of
+	polling isn't very useful anyway, and it seems it breaks for the
+	Linux CP210x USB<->RS-232 bridge driver which is certainly a bug
+	in the driver, but we can just avoid that bug alltogether.
+
 2007-05-15 Joerg Wunsch <j@uriah.heep.sax.de>
 
 	* avrdude.conf.in: Fix the STK500v2 ISP delay parameter for
diff --git a/ser_posix.c b/ser_posix.c
index 6b8b455c..f7d289cb 100644
--- a/ser_posix.c
+++ b/ser_posix.c
@@ -271,8 +271,6 @@ static void ser_close(union filedescriptor *fd)
 static int ser_send(union filedescriptor *fd, unsigned char * buf, size_t buflen)
 {
   struct timeval timeout, to2;
-  fd_set wfds;
-  int nfds;
   int rc;
   unsigned char * p = buf;
   size_t len = buflen;
@@ -306,29 +304,6 @@ static int ser_send(union filedescriptor *fd, unsigned char * buf, size_t buflen
   to2 = timeout;
 
   while (len) {
-  reselect:
-    FD_ZERO(&wfds);
-    FD_SET(fd->ifd, &wfds);
-
-    nfds = select(fd->ifd + 1, NULL, &wfds, NULL, &to2);
-    if (nfds == 0) {
-      if (verbose >= 1)
-	fprintf(stderr,
-		"%s: ser_send(): programmer is not responding\n",
-		progname);
-      exit(1);
-    }
-    else if (nfds == -1) {
-      if (errno == EINTR || errno == EAGAIN) {
-        goto reselect;
-      }
-      else {
-        fprintf(stderr, "%s: ser_send(): select(): %s\n",
-                progname, strerror(errno));
-        exit(1);
-      }
-    }
-
     rc = write(fd->ifd, p, (len > 1024) ? 1024 : len);
     if (rc < 0) {
       fprintf(stderr, "%s: ser_send(): write error: %s\n",