diff options
Diffstat (limited to 'iphone.c')
| -rw-r--r-- | iphone.c | 45 |
1 files changed, 5 insertions, 40 deletions
| @@ -314,7 +314,7 @@ iphone_error_t iphone_get_specific_device(int bus_n, int dev_n, iphone_device_t | |||
| 314 | 314 | ||
| 315 | // Set the device configuration | 315 | // Set the device configuration |
| 316 | for (bus = usb_get_busses(); bus; bus = bus->next) | 316 | for (bus = usb_get_busses(); bus; bus = bus->next) |
| 317 | if (bus->location == bus_n) | 317 | //if (bus->location == bus_n) |
| 318 | for (dev = bus->devices; dev != NULL; dev = dev->next) | 318 | for (dev = bus->devices; dev != NULL; dev = dev->next) |
| 319 | if (dev->devnum == dev_n) { | 319 | if (dev->devnum == dev_n) { |
| 320 | phone->__device = dev; | 320 | phone->__device = dev; |
| @@ -374,41 +374,6 @@ iphone_error_t iphone_get_specific_device(int bus_n, int dev_n, iphone_device_t | |||
| 374 | return IPHONE_E_UNKNOWN_ERROR; // if it got to this point it's gotta be bad | 374 | return IPHONE_E_UNKNOWN_ERROR; // if it got to this point it's gotta be bad |
| 375 | } | 375 | } |
| 376 | 376 | ||
| 377 | |||
| 378 | /** | ||
| 379 | * Scans all USB busses and devices for a known AFC-compatible device and | ||
| 380 | * returns a handle to the first such device it finds. Known devices include | ||
| 381 | * those with vendor ID 0x05ac and product ID between 0x1290 and 0x1293 | ||
| 382 | * inclusive. | ||
| 383 | * | ||
| 384 | * This function is convenient, but on systems where higher-level abstractions | ||
| 385 | * (such as HAL) are available it may be preferable to use | ||
| 386 | * iphone_get_specific_device instead, because it can deal with multiple | ||
| 387 | * connected devices as well as devices not known to libiphone. | ||
| 388 | * | ||
| 389 | * @param device Upon calling this function, a pointer to a location of type | ||
| 390 | * iphone_device_t, which must have the value NULL. On return, this location | ||
| 391 | * will be filled with a handle to the device. | ||
| 392 | * @return IPHONE_E_SUCCESS if ok, otherwise an error code. | ||
| 393 | */ | ||
| 394 | iphone_error_t iphone_get_device(iphone_device_t * device) | ||
| 395 | { | ||
| 396 | struct usb_bus *bus; | ||
| 397 | struct usb_device *dev; | ||
| 398 | |||
| 399 | usb_init(); | ||
| 400 | usb_find_busses(); | ||
| 401 | usb_find_devices(); | ||
| 402 | |||
| 403 | for (bus = usb_get_busses(); bus != NULL; bus = bus->next) | ||
| 404 | for (dev = bus->devices; dev != NULL; dev = dev->next) | ||
| 405 | if (dev->descriptor.idVendor == 0x05ac | ||
| 406 | && dev->descriptor.idProduct >= 0x1290 && dev->descriptor.idProduct <= 0x1293) | ||
| 407 | return iphone_get_specific_device(bus->location, dev->devnum, device); | ||
| 408 | |||
| 409 | return IPHONE_E_NO_DEVICE; | ||
| 410 | } | ||
| 411 | |||
| 412 | /** Cleans up an iPhone structure, then frees the structure itself. | 377 | /** Cleans up an iPhone structure, then frees the structure itself. |
| 413 | * This is a library-level function; deals directly with the iPhone to tear | 378 | * This is a library-level function; deals directly with the iPhone to tear |
| 414 | * down relations, but otherwise is mostly internal. | 379 | * down relations, but otherwise is mostly internal. |
| @@ -845,7 +810,7 @@ iphone_error_t iphone_mux_send(iphone_umux_client_t client, const char *data, ui | |||
| 845 | ntoh_header(client->header); | 810 | ntoh_header(client->header); |
| 846 | 811 | ||
| 847 | // update counts ONLY if the send succeeded. | 812 | // update counts ONLY if the send succeeded. |
| 848 | if (sendresult == blocksize) { | 813 | if ((uint32_t)sendresult == blocksize) { |
| 849 | // Re-calculate scnt | 814 | // Re-calculate scnt |
| 850 | client->header->scnt += datalen; | 815 | client->header->scnt += datalen; |
| 851 | client->wr_window -= blocksize; | 816 | client->wr_window -= blocksize; |
| @@ -863,7 +828,7 @@ iphone_error_t iphone_mux_send(iphone_umux_client_t client, const char *data, ui | |||
| 863 | else if (sendresult < 0) { | 828 | else if (sendresult < 0) { |
| 864 | return IPHONE_E_UNKNOWN_ERROR; | 829 | return IPHONE_E_UNKNOWN_ERROR; |
| 865 | } | 830 | } |
| 866 | else if (sendresult == blocksize) { | 831 | else if ((uint32_t)sendresult == blocksize) { |
| 867 | // actual number of data bytes sent. | 832 | // actual number of data bytes sent. |
| 868 | *sent_bytes = sendresult - HEADERLEN; | 833 | *sent_bytes = sendresult - HEADERLEN; |
| 869 | return IPHONE_E_SUCCESS; | 834 | return IPHONE_E_SUCCESS; |
| @@ -1097,7 +1062,7 @@ int iphone_mux_pullbulk(iphone_device_t phone) | |||
| 1097 | // now that we have a header, check if there is sufficient data | 1062 | // now that we have a header, check if there is sufficient data |
| 1098 | // to construct a full packet, including its data | 1063 | // to construct a full packet, including its data |
| 1099 | uint32_t packetlen = ntohl(header->length); | 1064 | uint32_t packetlen = ntohl(header->length); |
| 1100 | if (phone->usbReceive.leftover < packetlen) { | 1065 | if ((uint32_t)phone->usbReceive.leftover < packetlen) { |
| 1101 | fprintf(stderr, "%s: not enough data to construct a full packet\n", __func__); | 1066 | fprintf(stderr, "%s: not enough data to construct a full packet\n", __func__); |
| 1102 | break; | 1067 | break; |
| 1103 | } | 1068 | } |
| @@ -1205,7 +1170,7 @@ iphone_error_t iphone_mux_recv_timeout(iphone_umux_client_t client, char *data, | |||
| 1205 | *recv_bytes = 0; | 1170 | *recv_bytes = 0; |
| 1206 | if (client->recv_buffer != NULL && client->r_len > 0) { | 1171 | if (client->recv_buffer != NULL && client->r_len > 0) { |
| 1207 | uint32_t foolen = datalen; | 1172 | uint32_t foolen = datalen; |
| 1208 | if (foolen > client->r_len) foolen = client->r_len; | 1173 | if ((int)foolen > client->r_len) foolen = client->r_len; |
| 1209 | memcpy(data, client->recv_buffer, foolen); | 1174 | memcpy(data, client->recv_buffer, foolen); |
| 1210 | *recv_bytes = foolen; | 1175 | *recv_bytes = foolen; |
| 1211 | 1176 | ||
