~ubuntu-branches/ubuntu/utopic/usb-modeswitch/utopic-proposed

« back to all changes in this revision

Viewing changes to usb_modeswitch.c

  • 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:
788
788
        return 2;
789
789
}
790
790
 
 
791
#define SWITCH_CONFIG_MAXTRIES   5
791
792
 
792
793
int switchConfiguration ()
793
794
{
 
795
        int count = SWITCH_CONFIG_MAXTRIES; 
794
796
        int ret;
795
797
 
796
798
        SHOW_PROGRESS("Changing configuration to %i ...\n", Configuration);
797
 
        ret = usb_set_configuration(devh, Configuration);
 
799
        while (((ret = usb_set_configuration(devh, Configuration)) < 0) && --count) { 
 
800
                SHOW_PROGRESS(" Device is busy, trying to detach kernel driver\n"); 
 
801
                detachDriver(); 
 
802
        } 
798
803
        if (ret == 0 ) {
799
804
                SHOW_PROGRESS(" OK, configuration set\n");
800
805
                return 1;