Skip to contentSkip to conversation

usb-host: set ifs.detached as true if kernel driver is not active

PATCH Superseded linzhecheng 2 participants 3 messages Nov 20, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb-host: set ifs.detached as true if kernel driver is not active

If no kernel driver is active, we can already claim and perform I/O on it without detaching it.

hw/usb/host-libusb.c +4 -0
index f31e9cbbb8..db4ae1e6e8 100644
@@ -1119,6 +1119,10 @@ static void usb_host_detach_kernel(USBHostDevice *s)
     for (i = 0; i < USB_MAX_INTERFACES; i++) {
         rc = libusb_kernel_driver_active(s->dh, i);
         usb_host_libusb_error("libusb_kernel_driver_active", rc);
+        if (rc == 0) {
+            s->ifs[i].detached = true;
+            continue;
+        }
         if (rc != 1) {
             continue;
         }
Signature · 1 line
2.12.2.windows.2
#1 lore raw
Quoted 10 lines · linzhecheng

If no kernel driver is active, we can already claim and perform I/O on it without detaching it.

hw/usb/host-libusb.c +0 -0
index f31e9cbbb8..db4ae1e6e8 100644

hw/usb/host-libusb.c static void usb_host_detach_kernel(USBHostDevice *s) · line 1126

Quoted 8 lines
hw/usb/host-libusb.c +4 -0
@@ -1119,6 +1119,10 @@ static void usb_host_detach_kernel(USBHostDevice *s)
     for (i = 0; i < USB_MAX_INTERFACES; i++) {
         rc = libusb_kernel_driver_active(s->dh, i);
         usb_host_libusb_error("libusb_kernel_driver_active", rc);
+        if (rc == 0) {
+            s->ifs[i].detached = true;
+            continue;
+        }
         if (rc != 1) {

Can't we just add detached = true here?

hw/usb/host-libusb.c static void usb_host_detach_kernel(USBHostDevice *s) · line 1128

Quoted 2 lines
hw/usb/host-libusb.c +0 -0
             continue;
         }

cheers,
Gerd

#2 lore raw
Quoted 32 lines

-----Original Message-----
From: Gerd Hoffmann [mailto:[email protected]]
Sent: Tuesday, November 20, 2018 4:25 PM
To: linzhecheng <[email protected]>
Cc: [email protected]; Zhoujian (jay) <[email protected]>; wangxin (U) <[email protected]>
Subject: Re: [PATCH] usb-host: set ifs.detached as true if kernel driver is not active

hw/usb/host-libusb.c static void

Quoted 10 lines · linzhecheng

If no kernel driver is active, we can already claim and perform I/O on it without detaching it.

hw/usb/host-libusb.c index renamed from hw/usb/host-libusb.c +0 -0

f31e9cbbb8..db4ae1e6e8 100644

hw/usb/host-libusb.c +0 -0
@@ -1119,6 +1119,10 @@ static void

usb_host_detach_kernel(USBHostDevice *s)

hw/usb/host-libusb.c static void usb_host_detach_kernel(USBHostDevice *s) · line 1126

Quoted 8 lines
hw/usb/host-libusb.c +4 -0
     for (i = 0; i < USB_MAX_INTERFACES; i++) {
         rc = libusb_kernel_driver_active(s->dh, i);
         usb_host_libusb_error("libusb_kernel_driver_active", rc);
+        if (rc == 0) {
+            s->ifs[i].detached = true;
+            continue;
+        }
         if (rc != 1) {
Quoted 1 line

Can't we just add detached = true here?

Yes, it's better.

Quoted 6 lines

hw/usb/host-libusb.c static void usb_host_detach_kernel(USBHostDevice *s) · line 1128

Quoted 3 lines
hw/usb/host-libusb.c +0 -0
             continue;
         }

cheers,
Gerd