#endif
/** Custom GLib event source for libusb I/O.
- * @internal
*/
struct usb_source {
GSource base;
sr_err("Callback not set, cannot dispatch event.");
return G_SOURCE_REMOVE;
}
- keep = (*(sr_receive_data_callback)callback)(-1, revents, user_data);
+ keep = (*SR_RECEIVE_DATA_CALLBACK(callback))(-1, revents, user_data);
if (G_LIKELY(keep) && G_LIKELY(!g_source_is_destroyed(source))) {
if (usource->timeout_us >= 0)
return;
pollfd = g_slice_new(GPollFD);
-#ifdef G_OS_WIN32
+#ifdef _WIN32
events = G_IO_IN;
#endif
pollfd->fd = (gintptr)fd;
if ((mstr = g_match_info_fetch(match, 2)))
pid = strtoul(mstr, NULL, 16);
g_free(mstr);
- sr_dbg("Trying to find USB device with VID:PID = %04x:%04x.",
- vid, pid);
+ /* Trying to find USB device via VID:PID. */
} else {
g_match_info_unref(match);
g_regex_unref(reg);
if ((mstr = g_match_info_fetch(match, 2)))
addr = strtoul(mstr, NULL, 10);
g_free(mstr);
- sr_dbg("Trying to find USB device with bus.address = "
- "%d.%d.", bus, addr);
+ /* Trying to find USB device via bus.address. */
}
}
g_match_info_unref(match);
sr_dbg("Found USB device (VID:PID = %04x:%04x, bus.address = "
"%d.%d).", des.idVendor, des.idProduct, b, a);
- usb = sr_usb_dev_inst_new(libusb_get_bus_number(devlist[i]),
- libusb_get_device_address(devlist[i]), NULL);
+ usb = sr_usb_dev_inst_new(b, a, NULL);
devices = g_slist_append(devices, usb);
}
libusb_free_device_list(devlist, 1);
- sr_dbg("Found %d device(s).", g_slist_length(devices));
+ /* No log message for #devices found (caller will log that). */
return devices;
}
if (!source)
return SR_ERR;
- g_source_set_callback(source, (GSourceFunc)cb, cb_data, NULL);
+ g_source_set_callback(source, G_SOURCE_FUNC(cb), cb_data, NULL);
ret = sr_session_source_add_internal(session, ctx->libusb_ctx, source);
g_source_unref(source);
}
/**
- * Check the USB configuration to determine if this device has a given
+ * Check the USB configuration to determine if this device has a given
* manufacturer and product string.
*
* @return TRUE if the device's configuration profile strings