diff options
| author | 2024-09-25 01:30:35 +0200 | |
|---|---|---|
| committer | 2024-09-25 01:30:35 +0200 | |
| commit | 3eb4fbb0691df6ef76b4b04b9dccb9b6cf0d079d (patch) | |
| tree | 554216855167653a4182d787ed06d71e22a5f353 /src/libirecovery.c | |
| parent | 3039480107e77c08206fb42e202ec3d1ec3609c1 (diff) | |
| download | libirecovery-3eb4fbb0691df6ef76b4b04b9dccb9b6cf0d079d.tar.gz libirecovery-3eb4fbb0691df6ef76b4b04b9dccb9b6cf0d079d.tar.bz2 | |
KIS: Add some retry loops around open/set config/set interface operations
Diffstat (limited to 'src/libirecovery.c')
| -rw-r--r-- | src/libirecovery.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/libirecovery.c b/src/libirecovery.c index efcb7b4..e25eb7d 100644 --- a/src/libirecovery.c +++ b/src/libirecovery.c | |||
| @@ -2370,13 +2370,19 @@ static void* _irecv_handle_device_add(void *userdata) | |||
| 2370 | 2370 | ||
| 2371 | if (product_id == KIS_PRODUCT_ID) { | 2371 | if (product_id == KIS_PRODUCT_ID) { |
| 2372 | IOObjectRetain(device); | 2372 | IOObjectRetain(device); |
| 2373 | 2373 | int i = 0; | |
| 2374 | error = iokit_usb_open_service(&client, device); | 2374 | for (i = 0; i < 10; i++) { |
| 2375 | error = iokit_usb_open_service(&client, device); | ||
| 2376 | if (error == IRECV_E_SUCCESS) { | ||
| 2377 | break; | ||
| 2378 | } | ||
| 2379 | debug("%s: Could not open KIS device, retrying...\n", __func__); | ||
| 2380 | usleep(500000); | ||
| 2381 | } | ||
| 2375 | if (error != IRECV_E_SUCCESS) { | 2382 | if (error != IRECV_E_SUCCESS) { |
| 2376 | debug("%s: ERROR: could not open KIS device!\n", __func__); | 2383 | debug("%s: ERROR: could not open KIS device!\n", __func__); |
| 2377 | return NULL; | 2384 | return NULL; |
| 2378 | } | 2385 | } |
| 2379 | |||
| 2380 | product_id = client->mode; | 2386 | product_id = client->mode; |
| 2381 | } else { | 2387 | } else { |
| 2382 | CFStringRef serialString = (CFStringRef)IORegistryEntryCreateCFProperty(device, CFSTR(kUSBSerialNumberString), kCFAllocatorDefault, 0); | 2388 | CFStringRef serialString = (CFStringRef)IORegistryEntryCreateCFProperty(device, CFSTR(kUSBSerialNumberString), kCFAllocatorDefault, 0); |
| @@ -2429,14 +2435,29 @@ static void* _irecv_handle_device_add(void *userdata) | |||
| 2429 | #endif /* !WIN32 */ | 2435 | #endif /* !WIN32 */ |
| 2430 | memset(&client_loc, '\0', sizeof(client_loc)); | 2436 | memset(&client_loc, '\0', sizeof(client_loc)); |
| 2431 | if (product_id == KIS_PRODUCT_ID) { | 2437 | if (product_id == KIS_PRODUCT_ID) { |
| 2432 | error = irecv_usb_set_configuration(client, 1); | 2438 | int i = 0; |
| 2439 | for (i = 0; i < 10; i++) { | ||
| 2440 | error = irecv_usb_set_configuration(client, 1); | ||
| 2441 | if (error == IRECV_E_SUCCESS) { | ||
| 2442 | break; | ||
| 2443 | } | ||
| 2444 | debug("Failed to set configuration, error %d, retrying...\n", error); | ||
| 2445 | usleep(500000); | ||
| 2446 | } | ||
| 2433 | if (error != IRECV_E_SUCCESS) { | 2447 | if (error != IRECV_E_SUCCESS) { |
| 2434 | debug("Failed to set configuration, error %d\n", error); | 2448 | debug("Failed to set configuration, error %d\n", error); |
| 2435 | irecv_close(client); | 2449 | irecv_close(client); |
| 2436 | return NULL; | 2450 | return NULL; |
| 2437 | } | 2451 | } |
| 2438 | 2452 | ||
| 2439 | error = irecv_usb_set_interface(client, 0, 0); | 2453 | for (i = 0; i < 10; i++) { |
| 2454 | error = irecv_usb_set_interface(client, 0, 0); | ||
| 2455 | if (error == IRECV_E_SUCCESS) { | ||
| 2456 | break; | ||
| 2457 | } | ||
| 2458 | debug("Failed to set interface, error %d, retrying...\n", error); | ||
| 2459 | usleep(500000); | ||
| 2460 | } | ||
| 2440 | if (error != IRECV_E_SUCCESS) { | 2461 | if (error != IRECV_E_SUCCESS) { |
| 2441 | debug("Failed to set interface, error %d\n", error); | 2462 | debug("Failed to set interface, error %d\n", error); |
| 2442 | irecv_close(client); | 2463 | irecv_close(client); |
