~ubuntu-branches/ubuntu/quantal/usb-modeswitch/quantal

« back to all changes in this revision

Viewing changes to debian/patches/05_fixed_configuration_switching_races.patch

  • Committer: Bazaar Package Importer
  • Author(s): Didier Raboud
  • Date: 2010-11-11 14:52:43 UTC
  • Revision ID: james.westby@ubuntu.com-20101111145243-rj6jiak8xcvzi34e
Tags: 1.1.4-2
Fix configuration switching race (LP: #673435)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
5
 
 
6
---
 
7
 usb_modeswitch.c |    7 ++++++-
 
8
 1 files changed, 6 insertions(+), 1 deletions(-)
 
9
 
 
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:
 
15
        return 2;
 
16
 }
 
17
 
 
18
+#define SWITCH_CONFIG_MAXTRIES   5
 
19
 
 
20
 int switchConfiguration ()
 
21
 {
 
22
+       int count = SWITCH_CONFIG_MAXTRIES; 
 
23
        int ret;
 
24
 
 
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"); 
 
29
+               detachDriver(); 
 
30
+       } 
 
31
        if (ret == 0 ) {
 
32
                SHOW_PROGRESS(" OK, configuration set\n");
 
33
                return 1;
 
34
-- 
 
35
1.7.1
 
36