1
From bd450d14bde9473a4d413a37092b4fda8184eeca Mon Sep 17 00:00:00 2001
2
From: Amit Mendapara <mendapara.amit@gmail.com>
3
Date: Wed, 10 Nov 2010 16:38:03 +0530
4
Subject: [PATCH] Fixed configuration switching races.
7
usb_modeswitch.c | 7 ++++++-
8
1 files changed, 6 insertions(+), 1 deletions(-)
10
diff --git a/usb_modeswitch.c b/usb_modeswitch.c
11
index 5e6342a..a5f8893 100644
12
--- a/usb_modeswitch.c
13
+++ b/usb_modeswitch.c
14
@@ -788,13 +788,18 @@ skip:
18
+#define SWITCH_CONFIG_MAXTRIES 5
20
int switchConfiguration ()
22
+ int count = SWITCH_CONFIG_MAXTRIES;
25
SHOW_PROGRESS("Changing configuration to %i ...\n", Configuration);
26
- ret = usb_set_configuration(devh, Configuration);
27
+ while (((ret = usb_set_configuration(devh, Configuration)) < 0) && --count) {
28
+ SHOW_PROGRESS(" Device is busy, trying to detach kernel driver\n");
32
SHOW_PROGRESS(" OK, configuration set\n");