Skip to content

Commit

Permalink
Removed deprecated LIBUSBX_API
Browse files Browse the repository at this point in the history
Closes #211 #782.
See also #733.
  • Loading branch information
Nightwalker-87 committed Mar 24, 2020
1 parent 10ae529 commit e3c76aa
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions src/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -936,15 +936,6 @@ static stlink_t* stlink_open(const int verbose) {
return NULL;
}

#if defined (__FreeBSD__)
#define LIBUSBX_API_VERSION LIBUSB_API_VERSION
#endif
#if LIBUSBX_API_VERSION < 0x01000106
libusb_set_debug(slsg->libusb_ctx, 3);
#else
libusb_set_option(slsg->libusb_ctx, LIBUSB_OPTION_LOG_LEVEL, 3);

This comment has been minimized.

Copy link
@slyshykO

slyshykO Mar 24, 2020

Collaborator

I think this call is needed.

This comment has been minimized.

Copy link
@Nightwalker-87

Nightwalker-87 Mar 24, 2020

Author Member

I don't understand: What is it needed for, if the package libusbx including this LIBUSBX_API, is no longer present for years? Since the libusbx project merged back into libusb LIBUSB_API is used instead, so this code-block should be doing nothing as it is no longer called...

This comment has been minimized.

Copy link
@slyshykO

slyshykO Mar 24, 2020

Collaborator

This block was detected which function should be called libusb_set_debug or libusb_set_option .
You remove both.

This comment has been minimized.

Copy link
@slyshykO

slyshykO Mar 24, 2020

Collaborator

Propose rewrite this ifdef to

#if LIBUSB_API_VERSION < 0x01000106
    libusb_set_debug(slsg->libusb_ctx, LIBUSB_LOG_LEVEL_INFO);
#else
    libusb_set_option(slsg->libusb_ctx, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_INFO);
#endif

This comment has been minimized.

Copy link
@Nightwalker-87

Nightwalker-87 Mar 24, 2020

Author Member

Yes, but that was only if LIBUSBX_API_VERSION was present at all.
A similar call must be present somewhere else, otherwise it would never be called.

This comment has been minimized.

Copy link
@slyshykO

slyshykO Mar 24, 2020

Collaborator

ok, agree

This comment has been minimized.

Copy link
@slyshykO

slyshykO Mar 24, 2020

Collaborator

We pass the verbosity parameter to functions that open st-link devices.

stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[STLINK_SERIAL_MAX_SIZE]);
stlink_t* stlink_v1_open(const int verbose, int reset);

So, I think, somewhere in code we also should set the log level to libusb accordingly.

Edit : Maybe open issue?

This comment has been minimized.

Copy link
@Nightwalker-87

Nightwalker-87 Mar 24, 2020

Author Member

Yeah, can you have a look? PR alone would possible do, no need to open a new ticket, I think.

This comment has been minimized.

Copy link
@Nightwalker-87

Nightwalker-87 Mar 28, 2020

Author Member

Libusb log level addressed in PR #894.

#endif

slsg->usb_handle = libusb_open_device_with_vid_pid(slsg->libusb_ctx, STLINK_USB_VID_ST, STLINK_USB_PID_STLINK);
if (slsg->usb_handle == NULL) {
WLOG("Failed to find an stlink v1 by VID:PID\n");
Expand Down

0 comments on commit e3c76aa

Please sign in to comment.