libusb: don't use typedef's
Libusb defines both the struct and a typedef to the struct using the same struct name. It's then possible to use either 'struct x' and 'x'. E.g.: typedef struct libusb_device libusb_device; OpenOCD is not consistent and uses a mix of 'struct x' and 'x'. To make OpenOCD code uniform, stick at project's coding style and use 'struct x' in place of the typedef'd name. Change-Id: I901458b680e42830d3f371e47997157f91b7f675 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6165 Tested-by: jenkins Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li> Reviewed-by: Marc Schink <dev@zapb.de> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
parent
a60979b069
commit
11d918d9c1
|
@ -349,8 +349,8 @@ static void aice_unpack_dthmb(uint8_t *cmd_ack_code, uint8_t *target_id,
|
|||
/* calls the given usb_bulk_* function, allowing for the data to
|
||||
* trickle in with some timeouts */
|
||||
static int usb_bulk_with_retries(
|
||||
int (*f)(libusb_device_handle *, int, char *, int, int, int *),
|
||||
libusb_device_handle *dev, int ep,
|
||||
int (*f)(struct libusb_device_handle *, int, char *, int, int, int *),
|
||||
struct libusb_device_handle *dev, int ep,
|
||||
char *bytes, int size, int timeout, int *transferred)
|
||||
{
|
||||
int tries = 3, count = 0;
|
||||
|
@ -369,7 +369,7 @@ static int usb_bulk_with_retries(
|
|||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int wrap_usb_bulk_write(libusb_device_handle *dev, int ep,
|
||||
static int wrap_usb_bulk_write(struct libusb_device_handle *dev, int ep,
|
||||
char *buff, int size, int timeout, int *transferred)
|
||||
{
|
||||
|
||||
|
@ -379,7 +379,7 @@ static int wrap_usb_bulk_write(libusb_device_handle *dev, int ep,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline int usb_bulk_write_ex(libusb_device_handle *dev, int ep,
|
||||
static inline int usb_bulk_write_ex(struct libusb_device_handle *dev, int ep,
|
||||
char *bytes, int size, int timeout)
|
||||
{
|
||||
int tr = 0;
|
||||
|
|
|
@ -41,8 +41,8 @@
|
|||
#include "cmsis_dap.h"
|
||||
|
||||
struct cmsis_dap_backend_data {
|
||||
libusb_context *usb_ctx;
|
||||
libusb_device_handle *dev_handle;
|
||||
struct libusb_context *usb_ctx;
|
||||
struct libusb_device_handle *dev_handle;
|
||||
unsigned int ep_out;
|
||||
unsigned int ep_in;
|
||||
int interface;
|
||||
|
@ -56,8 +56,8 @@ static int cmsis_dap_usb_alloc(struct cmsis_dap *dap, unsigned int pkt_sz);
|
|||
static int cmsis_dap_usb_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t pids[], char *serial)
|
||||
{
|
||||
int err;
|
||||
libusb_context *ctx;
|
||||
libusb_device **device_list;
|
||||
struct libusb_context *ctx;
|
||||
struct libusb_device **device_list;
|
||||
|
||||
err = libusb_init(&ctx);
|
||||
if (err) {
|
||||
|
@ -73,7 +73,7 @@ static int cmsis_dap_usb_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t p
|
|||
}
|
||||
|
||||
for (int i = 0; i < num_devices; i++) {
|
||||
libusb_device *dev = device_list[i];
|
||||
struct libusb_device *dev = device_list[i];
|
||||
struct libusb_device_descriptor dev_desc;
|
||||
|
||||
err = libusb_get_device_descriptor(dev, &dev_desc);
|
||||
|
@ -101,7 +101,7 @@ static int cmsis_dap_usb_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t p
|
|||
if (dev_desc.iSerialNumber == 0 && serial && serial[0])
|
||||
continue;
|
||||
|
||||
libusb_device_handle *dev_handle = NULL;
|
||||
struct libusb_device_handle *dev_handle = NULL;
|
||||
err = libusb_open(dev, &dev_handle);
|
||||
if (err) {
|
||||
/* It's to be expected that most USB devices can't be opened
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#define MAX_USB_PORTS 7
|
||||
|
||||
static struct libusb_context *jtag_libusb_context; /**< Libusb context **/
|
||||
static libusb_device **devs; /**< The usb device list **/
|
||||
static struct libusb_device **devs; /**< The usb device list **/
|
||||
|
||||
static int jtag_libusb_error(int err)
|
||||
{
|
||||
|
@ -71,7 +71,7 @@ static bool jtag_libusb_match_ids(struct libusb_device_descriptor *dev_desc,
|
|||
}
|
||||
|
||||
#ifdef HAVE_LIBUSB_GET_PORT_NUMBERS
|
||||
static bool jtag_libusb_location_equal(libusb_device *device)
|
||||
static bool jtag_libusb_location_equal(struct libusb_device *device)
|
||||
{
|
||||
uint8_t port_path[MAX_USB_PORTS];
|
||||
uint8_t dev_bus;
|
||||
|
@ -88,7 +88,7 @@ static bool jtag_libusb_location_equal(libusb_device *device)
|
|||
return jtag_usb_location_equal(dev_bus, port_path, path_len);
|
||||
}
|
||||
#else /* HAVE_LIBUSB_GET_PORT_NUMBERS */
|
||||
static bool jtag_libusb_location_equal(libusb_device *device)
|
||||
static bool jtag_libusb_location_equal(struct libusb_device *device)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ static bool jtag_libusb_location_equal(libusb_device *device)
|
|||
|
||||
|
||||
/* Returns true if the string descriptor indexed by str_index in device matches string */
|
||||
static bool string_descriptor_equal(libusb_device_handle *device, uint8_t str_index,
|
||||
static bool string_descriptor_equal(struct libusb_device_handle *device, uint8_t str_index,
|
||||
const char *string)
|
||||
{
|
||||
int retval;
|
||||
|
@ -123,7 +123,7 @@ static bool string_descriptor_equal(libusb_device_handle *device, uint8_t str_in
|
|||
return matched;
|
||||
}
|
||||
|
||||
static bool jtag_libusb_match_serial(libusb_device_handle *device,
|
||||
static bool jtag_libusb_match_serial(struct libusb_device_handle *device,
|
||||
struct libusb_device_descriptor *dev_desc, const char *serial,
|
||||
adapter_get_alternate_serial_fn adapter_get_alternate_serial)
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
/* this callback should return a non NULL value only when the serial could not
|
||||
* be retrieved by the standard 'libusb_get_string_descriptor_ascii' */
|
||||
typedef char * (*adapter_get_alternate_serial_fn)(libusb_device_handle *device,
|
||||
typedef char * (*adapter_get_alternate_serial_fn)(struct libusb_device_handle *device,
|
||||
struct libusb_device_descriptor *dev_desc);
|
||||
|
||||
int jtag_libusb_open(const uint16_t vids[], const uint16_t pids[],
|
||||
|
|
|
@ -62,8 +62,8 @@
|
|||
#define SIO_RESET_PURGE_TX 2
|
||||
|
||||
struct mpsse_ctx {
|
||||
libusb_context *usb_ctx;
|
||||
libusb_device_handle *usb_dev;
|
||||
struct libusb_context *usb_ctx;
|
||||
struct libusb_device_handle *usb_dev;
|
||||
unsigned int usb_write_timeout;
|
||||
unsigned int usb_read_timeout;
|
||||
uint8_t in_ep;
|
||||
|
@ -85,7 +85,7 @@ struct mpsse_ctx {
|
|||
};
|
||||
|
||||
/* Returns true if the string descriptor indexed by str_index in device matches string */
|
||||
static bool string_descriptor_equal(libusb_device_handle *device, uint8_t str_index,
|
||||
static bool string_descriptor_equal(struct libusb_device_handle *device, uint8_t str_index,
|
||||
const char *string)
|
||||
{
|
||||
int retval;
|
||||
|
@ -99,7 +99,7 @@ static bool string_descriptor_equal(libusb_device_handle *device, uint8_t str_in
|
|||
return strncmp(string, desc_string, sizeof(desc_string)) == 0;
|
||||
}
|
||||
|
||||
static bool device_location_equal(libusb_device *device, const char *location)
|
||||
static bool device_location_equal(struct libusb_device *device, const char *location)
|
||||
{
|
||||
bool result = false;
|
||||
#ifdef HAVE_LIBUSB_GET_PORT_NUMBERS
|
||||
|
@ -161,7 +161,7 @@ static bool device_location_equal(libusb_device *device, const char *location)
|
|||
static bool open_matching_device(struct mpsse_ctx *ctx, const uint16_t *vid, const uint16_t *pid,
|
||||
const char *product, const char *serial, const char *location)
|
||||
{
|
||||
libusb_device **list;
|
||||
struct libusb_device **list;
|
||||
struct libusb_device_descriptor desc;
|
||||
struct libusb_config_descriptor *config0;
|
||||
int err;
|
||||
|
@ -171,7 +171,7 @@ static bool open_matching_device(struct mpsse_ctx *ctx, const uint16_t *vid, con
|
|||
LOG_ERROR("libusb_get_device_list() failed with %s", libusb_error_name(cnt));
|
||||
|
||||
for (ssize_t i = 0; i < cnt; i++) {
|
||||
libusb_device *device = list[i];
|
||||
struct libusb_device *device = list[i];
|
||||
|
||||
err = libusb_get_device_descriptor(device, &desc);
|
||||
if (err != LIBUSB_SUCCESS) {
|
||||
|
|
|
@ -96,14 +96,14 @@
|
|||
#define ST7_PC_TDO ST7_PC_IO9
|
||||
#define ST7_PA_DBGACK ST7_PA_IO10
|
||||
|
||||
static libusb_device_handle *pHDev;
|
||||
static struct libusb_device_handle *pHDev;
|
||||
|
||||
/*
|
||||
* ep1 commands are up to USB_EP1OUT_SIZE bytes in length.
|
||||
* This function takes care of zeroing the unused bytes before sending the packet.
|
||||
* Any reply packet is not handled by this function.
|
||||
*/
|
||||
static int ep1_generic_commandl(libusb_device_handle *pHDev_param, size_t length, ...)
|
||||
static int ep1_generic_commandl(struct libusb_device_handle *pHDev_param, size_t length, ...)
|
||||
{
|
||||
uint8_t usb_buffer[USB_EP1OUT_SIZE];
|
||||
uint8_t *usb_buffer_p;
|
||||
|
@ -143,7 +143,7 @@ static int ep1_generic_commandl(libusb_device_handle *pHDev_param, size_t length
|
|||
|
||||
#if 0
|
||||
static ssize_t ep1_memory_read(
|
||||
libusb_device_handle *pHDev_param, uint16_t addr,
|
||||
struct libusb_device_handle *pHDev_param, uint16_t addr,
|
||||
size_t length, uint8_t *buffer)
|
||||
{
|
||||
uint8_t usb_buffer[USB_EP1OUT_SIZE];
|
||||
|
@ -202,7 +202,7 @@ static ssize_t ep1_memory_read(
|
|||
}
|
||||
#endif
|
||||
|
||||
static ssize_t ep1_memory_write(libusb_device_handle *pHDev_param, uint16_t addr,
|
||||
static ssize_t ep1_memory_write(struct libusb_device_handle *pHDev_param, uint16_t addr,
|
||||
size_t length, uint8_t const *buffer)
|
||||
{
|
||||
uint8_t usb_buffer[USB_EP1OUT_SIZE];
|
||||
|
@ -258,7 +258,7 @@ static ssize_t ep1_memory_write(libusb_device_handle *pHDev_param, uint16_t addr
|
|||
|
||||
|
||||
#if 0
|
||||
static ssize_t ep1_memory_writel(libusb_device_handle *pHDev_param, uint16_t addr,
|
||||
static ssize_t ep1_memory_writel(struct libusb_device_handle *pHDev_param, uint16_t addr,
|
||||
size_t length, ...)
|
||||
{
|
||||
uint8_t buffer[USB_EP1OUT_SIZE - 4];
|
||||
|
@ -295,7 +295,7 @@ static ssize_t ep1_memory_writel(libusb_device_handle *pHDev_param, uint16_t add
|
|||
static uint8_t dtc_entry_download;
|
||||
|
||||
/* The buffer is specially formatted to represent a valid image to load into the DTC. */
|
||||
static int dtc_load_from_buffer(libusb_device_handle *pHDev_param, const uint8_t *buffer,
|
||||
static int dtc_load_from_buffer(struct libusb_device_handle *pHDev_param, const uint8_t *buffer,
|
||||
size_t length)
|
||||
{
|
||||
struct header_s {
|
||||
|
@ -469,7 +469,7 @@ static int dtc_start_download(void)
|
|||
}
|
||||
|
||||
static int dtc_run_download(
|
||||
libusb_device_handle *pHDev_param,
|
||||
struct libusb_device_handle *pHDev_param,
|
||||
uint8_t *command_buffer,
|
||||
int command_buffer_size,
|
||||
uint8_t *reply_buffer,
|
||||
|
|
|
@ -3016,7 +3016,7 @@ static int stlink_close(void *handle)
|
|||
* based on the length (0x1a = 26) we could easily decide if we have to fixup the serial
|
||||
* and then we have just to convert the raw data into printable characters using sprintf
|
||||
*/
|
||||
static char *stlink_usb_get_alternate_serial(libusb_device_handle *device,
|
||||
static char *stlink_usb_get_alternate_serial(struct libusb_device_handle *device,
|
||||
struct libusb_device_descriptor *dev_desc)
|
||||
{
|
||||
int usb_retval;
|
||||
|
|
|
@ -266,7 +266,7 @@ static int ulink_usb_open(struct ulink **device)
|
|||
{
|
||||
ssize_t num_devices, i;
|
||||
bool found;
|
||||
libusb_device **usb_devices;
|
||||
struct libusb_device **usb_devices;
|
||||
struct libusb_device_descriptor usb_desc;
|
||||
struct libusb_device_handle *usb_device_handle;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ uint16_t versaloon_buf_size;
|
|||
struct versaloon_pending_t versaloon_pending[VERSALOON_MAX_PENDING_NUMBER];
|
||||
uint16_t versaloon_pending_idx;
|
||||
|
||||
libusb_device_handle *versaloon_usb_device_handle;
|
||||
struct libusb_device_handle *versaloon_usb_device_handle;
|
||||
static uint32_t versaloon_usb_to = VERSALOON_TIMEOUT;
|
||||
|
||||
static RESULT versaloon_init(void);
|
||||
|
|
|
@ -107,6 +107,6 @@ struct versaloon_interface_t {
|
|||
};
|
||||
|
||||
extern struct versaloon_interface_t versaloon_interface;
|
||||
extern libusb_device_handle *versaloon_usb_device_handle;
|
||||
extern struct libusb_device_handle *versaloon_usb_device_handle;
|
||||
|
||||
#endif /* OPENOCD_JTAG_DRIVERS_VERSALOON_VERSALOON_H */
|
||||
|
|
|
@ -812,7 +812,7 @@ static int vsllink_check_usb_strings(
|
|||
static int vsllink_usb_open(struct vsllink *vsllink)
|
||||
{
|
||||
ssize_t num_devices, i;
|
||||
libusb_device **usb_devices;
|
||||
struct libusb_device **usb_devices;
|
||||
struct libusb_device_descriptor usb_desc;
|
||||
struct libusb_device_handle *usb_device_handle;
|
||||
int retval;
|
||||
|
@ -823,7 +823,7 @@ static int vsllink_usb_open(struct vsllink *vsllink)
|
|||
return ERROR_FAIL;
|
||||
|
||||
for (i = 0; i < num_devices; i++) {
|
||||
libusb_device *device = usb_devices[i];
|
||||
struct libusb_device *device = usb_devices[i];
|
||||
|
||||
retval = libusb_get_device_descriptor(device, &usb_desc);
|
||||
if (retval != 0)
|
||||
|
|
|
@ -213,8 +213,8 @@ struct scan_result {
|
|||
|
||||
struct xds110_info {
|
||||
/* USB connection handles and data buffers */
|
||||
libusb_context *ctx;
|
||||
libusb_device_handle *dev;
|
||||
struct libusb_context *ctx;
|
||||
struct libusb_device_handle *dev;
|
||||
unsigned char read_payload[USB_PAYLOAD_SIZE];
|
||||
unsigned char write_packet[3];
|
||||
unsigned char write_payload[USB_PAYLOAD_SIZE];
|
||||
|
@ -317,9 +317,9 @@ static inline uint16_t xds110_get_u16(uint8_t *buffer)
|
|||
|
||||
static bool usb_connect(void)
|
||||
{
|
||||
libusb_context *ctx = NULL;
|
||||
libusb_device **list = NULL;
|
||||
libusb_device_handle *dev = NULL;
|
||||
struct libusb_context *ctx = NULL;
|
||||
struct libusb_device **list = NULL;
|
||||
struct libusb_device_handle *dev = NULL;
|
||||
|
||||
struct libusb_device_descriptor desc;
|
||||
|
||||
|
|
Loading…
Reference in New Issue