Jean THOMAS has uploaded this change for review.
dirtyjtag: Use owned libusb context
Change-Id: I940646d8454bc4ea6cfe263c87ce1f150642988d
Signed-off-by: Jean THOMAS <virgule@jeanthomas.me>
---
M dirtyjtag_spi.c
1 file changed, 19 insertions(+), 7 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/98/67898/1
diff --git a/dirtyjtag_spi.c b/dirtyjtag_spi.c
index 6c5fc72..8fdac00 100644
--- a/dirtyjtag_spi.c
+++ b/dirtyjtag_spi.c
@@ -26,6 +26,7 @@
#include "programmer.h"
struct dirtyjtag_spi_data {
+ struct libusb_context *libusb_ctx;
struct libusb_device_handle *libusb_handle;
enum {
DJTAG1,
@@ -109,6 +110,7 @@
{
struct dirtyjtag_spi_data *djtag_data = (struct dirtyjtag_spi_data*)data;
libusb_close(djtag_data->libusb_handle);
+ libusb_exit(djtag_data->libusb_ctx);
free(data);
return 0;
}
@@ -191,7 +193,13 @@
struct libusb_device_handle *handle = NULL;
struct dirtyjtag_spi_data *djtag_data = NULL;
- int ret = libusb_init(NULL);
+ djtag_data = calloc(1, sizeof(struct dirtyjtag_spi_data));
+ if (djtag_data == NULL) {
+ msg_perr("%s: failed to allocate internal driver data structure\n", __func__);
+ goto cleanup;
+ }
+
+ int ret = libusb_init(&djtag_data->libusb_ctx);
if (ret < 0) {
msg_perr("%s: couldn't initialize libusb!\n", __func__);
return -1;
@@ -223,12 +231,6 @@
goto cleanup;
}
- djtag_data = calloc(1, sizeof(struct dirtyjtag_spi_data));
- if (djtag_data == NULL) {
- msg_perr("%s: failed to allocate internal driver data structure\n", __func__);
- goto cleanup;
- }
-
djtag_data->libusb_handle = handle;
unsigned long int freq = 100;
To view, visit change 67898. To unsubscribe, or for help writing mail filters, visit settings.