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
--- a/usb_modeswitch.c
11
+++ b/usb_modeswitch.c
16
+#define SWITCH_CONFIG_MAXTRIES 5
18
int switchConfiguration ()
20
+ int count = SWITCH_CONFIG_MAXTRIES;
23
SHOW_PROGRESS("Changing configuration to %i ...\n", Configuration);
24
- ret = usb_set_configuration(devh, Configuration);
25
+ while (((ret = usb_set_configuration(devh, Configuration)) < 0) && --count) {
26
+ SHOW_PROGRESS(" Device is busy, trying to detach kernel driver\n");
30
SHOW_PROGRESS(" OK, configuration set\n");