[Debian-on-mobile-maintainers] [Git][DebianOnMobile-team/mfgtools][upstream] New upstream version 1.4.193
Henry-Nicolas Tourneur (@hntourne)
gitlab at salsa.debian.org
Tue Feb 22 16:31:45 GMT 2022
Henry-Nicolas Tourneur pushed to branch upstream at Debian On Mobile / mfgtools
Commits:
dc3ec314 by Henry-Nicolas Tourneur at 2022-02-22T16:26:58+00:00
New upstream version 1.4.193
- - - - -
2 changed files:
- libuuu/error.cpp
- libuuu/usbhotplug.cpp
Changes:
=====================================
libuuu/error.cpp
=====================================
@@ -31,6 +31,7 @@
#include "liberror.h"
#include "libuuu.h"
+#include "libusb.h"
using namespace std;
@@ -39,14 +40,20 @@ static int g_last_err_id;
static uint32_t g_debug_level;
-void uuu_set_debug_level(uint32_t mask)
+int get_libusb_debug_level() noexcept
{
- g_debug_level = mask;
+ return g_debug_level & 0xFFFF;
}
-int get_libusb_debug_level() noexcept
+void uuu_set_debug_level(uint32_t mask)
{
- return g_debug_level & 0xFFFF;
+ g_debug_level = mask;
+
+#if LIBUSB_API_VERSION > 0x01000106
+ libusb_set_option(nullptr, LIBUSB_OPTION_LOG_LEVEL, get_libusb_debug_level());
+#else
+ libusb_set_debug(nullptr, get_libusb_debug_level());
+#endif
}
const char * uuu_get_last_err_string()
=====================================
libuuu/usbhotplug.cpp
=====================================
@@ -69,6 +69,11 @@ static atomic<KnownDeviceState> g_known_device_state{NoKnownDevice};
class CAutoDeInit
{
public:
+ CAutoDeInit()
+ {
+ if (libusb_init(nullptr) < 0)
+ throw runtime_error{ "Call libusb_init failure" };
+ }
~CAutoDeInit()
{
libusb_exit(nullptr);
@@ -399,31 +404,8 @@ static int check_usb_timeout(Timer& usb_timer)
return 0;
}
-static int ensure_libusb_initialized()
-{
- static once_flag is_libusb_init;
- try {
- call_once(is_libusb_init, []{
- if (libusb_init(nullptr) < 0)
- throw runtime_error{"Call libusb_init failure"};
-#if LIBUSB_API_VERSION > 0x01000106
- libusb_set_option(nullptr, LIBUSB_OPTION_LOG_LEVEL, get_libusb_debug_level());
-#else
- libusb_set_debug(nullptr, get_libusb_debug_level());
-#endif
- });
- } catch(const exception& ex) {
- set_last_err_string(ex.what());
- return -1;
- }
- return 0;
-}
-
int polling_usb(std::atomic<int>& bexit)
{
- if (ensure_libusb_initialized())
- return -1;
-
if (run_cmds("CFG:", nullptr))
return -1;
@@ -463,9 +445,6 @@ CmdUsbCtx::~CmdUsbCtx()
int CmdUsbCtx::look_for_match_device(const char *pro)
{
- if (ensure_libusb_initialized())
- return -1;
-
if (run_cmds("CFG:", nullptr))
return -1;
@@ -535,9 +514,6 @@ int uuu_add_usbpath_filter(const char *path)
int uuu_for_each_devices(uuu_ls_usb_devices fn, void *p)
{
- if (ensure_libusb_initialized())
- return -1;
-
CAutoList l;
size_t i = 0;
libusb_device *dev;
View it on GitLab: https://salsa.debian.org/DebianOnMobile-team/mfgtools/-/commit/dc3ec3147126c8e827e727be604d0b11753004f2
--
View it on GitLab: https://salsa.debian.org/DebianOnMobile-team/mfgtools/-/commit/dc3ec3147126c8e827e727be604d0b11753004f2
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-on-mobile-maintainers/attachments/20220222/f99469f8/attachment-0001.htm>
More information about the Debian-on-mobile-maintainers
mailing list