mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-10 23:08:07 +00:00
Implement and use usb_cleanup() on shutdown or restart
This commit is contained in:
parent
5d3faba603
commit
e35e8ae135
10
cgminer.c
10
cgminer.c
@ -2842,6 +2842,16 @@ static void __kill_work(void)
|
||||
applog(LOG_DEBUG, "Killing off API thread");
|
||||
thr = &control_thr[api_thr_id];
|
||||
thr_info_cancel(thr);
|
||||
|
||||
#if defined(USE_MODMINER) || defined(USE_BITFORCE)
|
||||
/* Release USB resources in case it's a restart
|
||||
* and not a QUIT */
|
||||
if (!opt_scrypt) {
|
||||
applog(LOG_DEBUG, "Releasing all USB devices");
|
||||
usb_cleanup();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/* This should be the common exit path */
|
||||
|
16
usbutils.c
16
usbutils.c
@ -184,6 +184,7 @@ static const char *C_SETFLOW_S = "SetFlowCtrl";
|
||||
static const char *C_SETMODEM_S = "SetModemCtrl";
|
||||
static const char *C_PURGERX_S = "PurgeRx";
|
||||
static const char *C_PURGETX_S = "PurgeTx";
|
||||
static const char *C_FLASHREPLY_S = "FlashReply";
|
||||
|
||||
#ifdef EOL
|
||||
#undef EOL
|
||||
@ -572,6 +573,7 @@ static void cgusb_check_init()
|
||||
usb_commands[C_SETMODEM] = C_SETMODEM_S;
|
||||
usb_commands[C_PURGERX] = C_PURGERX_S;
|
||||
usb_commands[C_PURGETX] = C_PURGETX_S;
|
||||
usb_commands[C_FLASHREPLY] = C_FLASHREPLY_S;
|
||||
|
||||
stats_initialised = true;
|
||||
}
|
||||
@ -1522,5 +1524,17 @@ int _usb_transfer(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRequest
|
||||
|
||||
void usb_cleanup()
|
||||
{
|
||||
// TODO:
|
||||
int i;
|
||||
|
||||
mutex_lock(&devices_lock);
|
||||
for (i = 0; i < total_devices; i++) {
|
||||
switch (devices[i]->drv->drv_id) {
|
||||
case DRIVER_BITFORCE:
|
||||
case DRIVER_MODMINER:
|
||||
release_cgpu(devices[i]);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&devices_lock);
|
||||
}
|
||||
|
@ -122,6 +122,7 @@ enum usb_cmds {
|
||||
C_SETMODEM,
|
||||
C_PURGERX,
|
||||
C_PURGETX,
|
||||
C_FLASHREPLY,
|
||||
C_MAX
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user