[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 04/18] usb-host: limit open retries
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 04/18] usb-host: limit open retries |
Date: |
Fri, 2 Sep 2011 11:56:33 +0200 |
Limit the number of times qemu tries to open host devices to three.
Reset error counter when the device goes away, after un-plugging and
re-plugging the device qemu will try again three times.
Signed-off-by: Gerd Hoffmann <address@hidden>
---
usb-linux.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/usb-linux.c b/usb-linux.c
index 344af22..36d25d7 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -132,6 +132,7 @@ typedef struct USBHostDevice {
int addr;
char port[MAX_PORTLEN];
struct USBAutoFilter match;
+ int seen, errcount;
QTAILQ_ENTRY(USBHostDevice) next;
} USBHostDevice;
@@ -1769,6 +1770,10 @@ static int usb_host_auto_scan(void *opaque, int bus_num,
int addr, char *port,
continue;
}
/* We got a match */
+ s->seen++;
+ if (s->errcount >= 3) {
+ return 0;
+ }
/* Already attached ? */
if (s->fd != -1) {
@@ -1776,7 +1781,9 @@ static int usb_host_auto_scan(void *opaque, int bus_num,
int addr, char *port,
}
DPRINTF("husb: auto open: bus_num %d addr %d\n", bus_num, addr);
- usb_host_open(s, bus_num, addr, port, product_name, speed);
+ if (usb_host_open(s, bus_num, addr, port, product_name, speed) < 0) {
+ s->errcount++;
+ }
break;
}
@@ -1794,6 +1801,10 @@ static void usb_host_auto_check(void *unused)
if (s->fd == -1) {
unconnected++;
}
+ if (s->seen == 0) {
+ s->errcount = 0;
+ }
+ s->seen = 0;
}
if (unconnected == 0) {
--
1.7.1
- [Qemu-devel] [PULL] usb patch queue, Gerd Hoffmann, 2011/09/02
- [Qemu-devel] [PATCH 03/18] usb-host: fix halted endpoints, Gerd Hoffmann, 2011/09/02
- [Qemu-devel] [PATCH 02/18] usb-host: reapurb error report fix, Gerd Hoffmann, 2011/09/02
- [Qemu-devel] [PATCH 04/18] usb-host: limit open retries,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 01/18] usb-host: start tracing support, Gerd Hoffmann, 2011/09/02
- [Qemu-devel] [PATCH 11/18] usb: fix use after free, Gerd Hoffmann, 2011/09/02
- [Qemu-devel] [PATCH 13/18] usb-ccid: remote wakeup support, Gerd Hoffmann, 2011/09/02
- [Qemu-devel] [PATCH 10/18] usb-host: parse port in /proc/bus/usb/devices scan, Gerd Hoffmann, 2011/09/02
- [Qemu-devel] [PATCH 09/18] usb-host: constify port, Gerd Hoffmann, 2011/09/02
- [Qemu-devel] [PATCH 05/18] usb-host: fix configuration tracking., Gerd Hoffmann, 2011/09/02
- [Qemu-devel] [PATCH 06/18] usb-host: claim port, Gerd Hoffmann, 2011/09/02
- [Qemu-devel] [PATCH 08/18] usb-ehci: handle siTDs, Gerd Hoffmann, 2011/09/02
- [Qemu-devel] [PATCH 07/18] usb-host: endpoint table fixup, Gerd Hoffmann, 2011/09/02
- [Qemu-devel] [PATCH 15/18] usb-host: tag as unmigratable, Gerd Hoffmann, 2011/09/02