drivers: USB Blaster II: claim interface before using it
If not, multiple instances of OOCD can concurrently use it. Change-Id: I48cc9d90521d1dcc7720c6e8bec74f45972d16f7 Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Reviewed-on: http://openocd.zylin.com/4589 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
parent
eca4f964b4
commit
08c7b904c3
|
@ -133,6 +133,11 @@ static int load_usb_blaster_firmware(struct libusb_device_handle *libusb_dev,
|
||||||
return ERROR_FAIL;
|
return ERROR_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (libusb_claim_interface(libusb_dev, 0)) {
|
||||||
|
LOG_ERROR("unable to claim interface");
|
||||||
|
return ERROR_JTAG_INIT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
ublast2_firmware_image.base_address = 0;
|
ublast2_firmware_image.base_address = 0;
|
||||||
ublast2_firmware_image.base_address_set = false;
|
ublast2_firmware_image.base_address_set = false;
|
||||||
|
|
||||||
|
@ -184,6 +189,13 @@ static int load_usb_blaster_firmware(struct libusb_device_handle *libusb_dev,
|
||||||
|
|
||||||
image_close(&ublast2_firmware_image);
|
image_close(&ublast2_firmware_image);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Release claimed interface. Most probably it is already disconnected
|
||||||
|
* and re-enumerated as new devices after firmware upload, so we do
|
||||||
|
* not need to care about errors.
|
||||||
|
*/
|
||||||
|
libusb_release_interface(libusb_dev, 0);
|
||||||
|
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,6 +240,12 @@ static int ublast2_libusb_init(struct ublast_lowlevel *low)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (libusb_claim_interface(low->libusb_dev, 0)) {
|
||||||
|
LOG_ERROR("unable to claim interface");
|
||||||
|
jtag_libusb_close(low->libusb_dev);
|
||||||
|
return ERROR_JTAG_INIT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
char buffer[5];
|
char buffer[5];
|
||||||
jtag_libusb_control_transfer(low->libusb_dev,
|
jtag_libusb_control_transfer(low->libusb_dev,
|
||||||
LIBUSB_REQUEST_TYPE_VENDOR |
|
LIBUSB_REQUEST_TYPE_VENDOR |
|
||||||
|
@ -246,6 +264,9 @@ static int ublast2_libusb_init(struct ublast_lowlevel *low)
|
||||||
|
|
||||||
static int ublast2_libusb_quit(struct ublast_lowlevel *low)
|
static int ublast2_libusb_quit(struct ublast_lowlevel *low)
|
||||||
{
|
{
|
||||||
|
if (libusb_release_interface(low->libusb_dev, 0))
|
||||||
|
LOG_ERROR("usb release interface failed");
|
||||||
|
|
||||||
jtag_libusb_close(low->libusb_dev);
|
jtag_libusb_close(low->libusb_dev);
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue