View | Details | Raw Unified | Return to bug 267144 | Differences between
and this patch

Collapse All | Expand All

(-)drivers/libusb1.c (-26 lines)
Lines 337-368 Link Here
337
337
338
		/* Now we have matched the device we wanted. Claim it. */
338
		/* Now we have matched the device we wanted. Claim it. */
339
339
340
#if defined(HAVE_LIBUSB_KERNEL_DRIVER_ACTIVE) && defined(HAVE_LIBUSB_SET_AUTO_DETACH_KERNEL_DRIVER)
341
		/* Due to the way FreeBSD implements libusb_set_auto_detach_kernel_driver(),
342
		 * check to see if the kernel driver is active before setting
343
		 * the auto-detach flag. Otherwise, libusb_claim_interface()
344
		 * with the auto-detach flag only works if the driver is
345
		 * running as root.
346
		 *
347
		 * Is the kernel driver active? Consider the unimplemented
348
		 * return code to be equivalent to inactive here.
349
		 */
350
		if((ret = libusb_kernel_driver_active(udev, usb_subdriver.hid_rep_index)) == 1) {
351
			upsdebugx(3, "libusb_kernel_driver_active() returned 1 (driver active)");
352
			/* Try the auto-detach kernel driver method.
353
			 * This function is not available on FreeBSD 10.1-10.3 */
354
			if ((ret = libusb_set_auto_detach_kernel_driver (udev, 1)) != LIBUSB_SUCCESS) {
355
				upsdebugx(1, "failed to set kernel driver auto-detach "
356
					"driver flag for USB device: %s",
357
					libusb_strerror((enum libusb_error)ret));
358
			} else {
359
				upsdebugx(2, "successfully set kernel driver auto-detach flag");
360
			}
361
		} else {
362
			upsdebugx(3, "libusb_kernel_driver_active() returned %d", ret);
363
		}
364
#endif
365
366
#if (defined HAVE_LIBUSB_DETACH_KERNEL_DRIVER) || (defined HAVE_LIBUSB_DETACH_KERNEL_DRIVER_NP)
340
#if (defined HAVE_LIBUSB_DETACH_KERNEL_DRIVER) || (defined HAVE_LIBUSB_DETACH_KERNEL_DRIVER_NP)
367
		/* Then, try the explicit detach method.
341
		/* Then, try the explicit detach method.
368
		 * This function is available on FreeBSD 10.1-10.3 */
342
		 * This function is available on FreeBSD 10.1-10.3 */

Return to bug 267144