diff options
| author | 2010-07-26 01:44:03 +0200 | |
|---|---|---|
| committer | 2010-07-26 01:44:03 +0200 | |
| commit | 49765561ae922dcfe55294534c493f32cb81b67b (patch) | |
| tree | 24c948ac3c8c436aeb239cc9814742a3843efeec /src | |
| parent | 18c0756c78b49f197437d4aba924ab2e92cdad5d (diff) | |
| download | libirecovery-49765561ae922dcfe55294534c493f32cb81b67b.tar.gz libirecovery-49765561ae922dcfe55294534c493f32cb81b67b.tar.bz2 | |
Cache the USB serial on irecv_open() to avoid descriptor calls later
Diffstat (limited to 'src')
| -rw-r--r-- | src/libirecovery.c | 24 | 
1 files changed, 6 insertions, 18 deletions
| diff --git a/src/libirecovery.c b/src/libirecovery.c index 18683f1..38e0fc3 100644 --- a/src/libirecovery.c +++ b/src/libirecovery.c @@ -93,6 +93,9 @@ irecv_error_t irecv_open(irecv_client_t* pclient) {  					return error;  				} +				/* cache usb serial */ +				libusb_get_string_descriptor_ascii(client->handle, usb_descriptor.iSerialNumber, client->serial, 255); +  				*pclient = client;  				return IRECV_E_SUCCESS;  			} @@ -501,16 +504,11 @@ irecv_error_t irecv_getenv(irecv_client_t client, const char* variable, char** v  }  irecv_error_t irecv_get_cpid(irecv_client_t client, unsigned int* cpid) { -	char info[256]; -	memset(info, '\0', 256); -  	if (client == NULL || client->handle == NULL) {  		return IRECV_E_NO_DEVICE;  	} -	libusb_get_string_descriptor_ascii(client->handle, 3, info, 255); - -	unsigned char* cpid_string = strstr(info, "CPID:"); +	unsigned char* cpid_string = strstr(client->serial, "CPID:");  	if (cpid_string == NULL) {  		*cpid = 0;  		return IRECV_E_UNKNOWN_ERROR; @@ -521,16 +519,11 @@ irecv_error_t irecv_get_cpid(irecv_client_t client, unsigned int* cpid) {  }  irecv_error_t irecv_get_bdid(irecv_client_t client, unsigned int* bdid) { -	char info[256]; -	memset(info, '\0', 256); -  	if (client == NULL || client->handle == NULL) {  		return IRECV_E_NO_DEVICE;  	} -	libusb_get_string_descriptor_ascii(client->handle, 3, info, 255); - -	unsigned char* bdid_string = strstr(info, "BDID:"); +	unsigned char* bdid_string = strstr(client->serial, "BDID:");  	if (bdid_string == NULL) {  		*bdid = 0;  		return IRECV_E_UNKNOWN_ERROR; @@ -541,16 +534,11 @@ irecv_error_t irecv_get_bdid(irecv_client_t client, unsigned int* bdid) {  }  irecv_error_t irecv_get_ecid(irecv_client_t client, unsigned long long* ecid) { -	char info[256]; -	memset(info, '\0', 256); -  	if (client == NULL || client->handle == NULL) {  		return IRECV_E_NO_DEVICE;  	} -	libusb_get_string_descriptor_ascii(client->handle, 3, info, 255); - -	unsigned char* ecid_string = strstr(info, "ECID:"); +	unsigned char* ecid_string = strstr(client->serial, "ECID:");  	if (ecid_string == NULL) {  		*ecid = 0;  		return IRECV_E_UNKNOWN_ERROR; | 
