mirror of
https://github.com/palera1n/palera1n.git
synced 2026-10-21 09:47:01 +02:00
even more libusb stuff
This commit is contained in:
1 parent
cad3a8d233
commit
05eb1d791b
2 files changed
+15
-5
No files matched your search
+14
-5
@@ -36,7 +36,7 @@ void *pongo_usb_callback(void *arg) {
|
||||
strncat(xargs_cmd, " wdt=-1", 0x270 - strlen(xargs_cmd) - 1);
|
||||
}
|
||||
LOG(LOG_INFO, "Found PongoOS USB Device");
|
||||
usb_device_handle_t handle = *(usb_device_handle_t *)arg;
|
||||
usb_device_handle_t handle = (((stuff_t *)arg)->handle);
|
||||
issue_pongo_command(handle, NULL);
|
||||
issue_pongo_command(handle, "fuse lock");
|
||||
issue_pongo_command(handle, "sep auto");
|
||||
@@ -74,6 +74,9 @@ void *pongo_usb_callback(void *arg) {
|
||||
}
|
||||
done:
|
||||
device_has_booted = true;
|
||||
#ifdef USE_LIBUSB
|
||||
libusb_unref_device(((stuff_t *)arg)->dev);
|
||||
#endif
|
||||
set_spin(0);
|
||||
return NULL;
|
||||
}
|
||||
@@ -157,11 +160,12 @@ int upload_pongo_file(usb_device_handle_t handle, unsigned char *buf, unsigned i
|
||||
|
||||
void io_start(stuff_t *stuff)
|
||||
{
|
||||
int r = pthread_create(&stuff->th, NULL, &pongo_usb_callback, &stuff->handle);
|
||||
int r = pthread_create(&stuff->th, NULL, &pongo_usb_callback, stuff);
|
||||
if(r != 0)
|
||||
{
|
||||
ERR("pthread_create: %s", strerror(r));
|
||||
exit(-1); // TODO: ok with libusb?
|
||||
set_spin(0);
|
||||
return;
|
||||
}
|
||||
pthread_join(stuff->th, NULL);
|
||||
}
|
||||
@@ -172,14 +176,19 @@ void io_stop(stuff_t *stuff)
|
||||
if(r != 0)
|
||||
{
|
||||
ERR("pthread_cancel: %s", strerror(r));
|
||||
exit(-1); // TODO: ok with libusb?
|
||||
set_spin(0);
|
||||
return;
|
||||
}
|
||||
r = pthread_join(stuff->th, NULL);
|
||||
if(r != 0)
|
||||
{
|
||||
ERR("pthread_join: %s", strerror(r));
|
||||
exit(-1); // TODO: ok with libusb?
|
||||
set_spin(0);
|
||||
return;
|
||||
}
|
||||
#ifdef USE_LIBUSB
|
||||
libusb_unref_device(stuff->dev);
|
||||
#endif
|
||||
}
|
||||
|
||||
void write_stdout(char *buf, uint32_t len)
|
||||
|
||||
@@ -171,6 +171,7 @@ static int LostDevice(libusb_context *ctx, libusb_device *dev, libusb_hotplug_ev
|
||||
|
||||
io_stop(stuff);
|
||||
libusb_close(stuff->handle);
|
||||
libusb_unref_device(dev);
|
||||
stuff->handle = NULL;
|
||||
stuff->dev = NULL;
|
||||
|
||||
|
||||
Reference in new issue
Block a user