[spice-gtk,1/3] usb-backend: Cache isochronous value

Submitted by Frediano Ziglio on July 25, 2019, 1:43 p.m.

Details

Message ID 20190725134353.23174-1-fziglio@redhat.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio July 25, 2019, 1:43 p.m.
Allows to remove _SpiceUsbDevice structure.
_SpiceUsbDevice is only caching this value from SpiceUsbBackendDevice.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 src/usb-backend.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/usb-backend.c b/src/usb-backend.c
index 9ac8595c..7e0e4a8a 100644
--- a/src/usb-backend.c
+++ b/src/usb-backend.c
@@ -50,6 +50,8 @@  struct _SpiceUsbBackendDevice
     gint ref_count;
     SpiceUsbBackendChannel *attached_to;
     UsbDeviceInformation device_info;
+    uint8_t cached_isochronous_valid : 1;
+    uint8_t cached_isochronous : 1;
 };
 
 struct _SpiceUsbBackend
@@ -341,6 +343,10 @@  gboolean spice_usb_backend_device_isoch(SpiceUsbBackendDevice *dev)
     gint i, j, k;
     int rc;
 
+    if (dev->cached_isochronous_valid) {
+        return dev->cached_isochronous;
+    }
+
     g_return_val_if_fail(libdev != NULL, 0);
 
     rc = libusb_get_active_config_descriptor(libdev, &conf_desc);
@@ -362,6 +368,9 @@  gboolean spice_usb_backend_device_isoch(SpiceUsbBackendDevice *dev)
         }
     }
 
+    dev->cached_isochronous_valid = TRUE;
+    dev->cached_isochronous = isoc_found;
+
     libusb_free_config_descriptor(conf_desc);
     return isoc_found;
 }

Comments

ping the series

> 
> Allows to remove _SpiceUsbDevice structure.
> _SpiceUsbDevice is only caching this value from SpiceUsbBackendDevice.
> 
> Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
> ---
>  src/usb-backend.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/src/usb-backend.c b/src/usb-backend.c
> index 9ac8595c..7e0e4a8a 100644
> --- a/src/usb-backend.c
> +++ b/src/usb-backend.c
> @@ -50,6 +50,8 @@ struct _SpiceUsbBackendDevice
>      gint ref_count;
>      SpiceUsbBackendChannel *attached_to;
>      UsbDeviceInformation device_info;
> +    uint8_t cached_isochronous_valid : 1;
> +    uint8_t cached_isochronous : 1;
>  };
>  
>  struct _SpiceUsbBackend
> @@ -341,6 +343,10 @@ gboolean
> spice_usb_backend_device_isoch(SpiceUsbBackendDevice *dev)
>      gint i, j, k;
>      int rc;
>  
> +    if (dev->cached_isochronous_valid) {
> +        return dev->cached_isochronous;
> +    }
> +
>      g_return_val_if_fail(libdev != NULL, 0);
>  
>      rc = libusb_get_active_config_descriptor(libdev, &conf_desc);
> @@ -362,6 +368,9 @@ gboolean
> spice_usb_backend_device_isoch(SpiceUsbBackendDevice *dev)
>          }
>      }
>  
> +    dev->cached_isochronous_valid = TRUE;
> +    dev->cached_isochronous = isoc_found;
> +
>      libusb_free_config_descriptor(conf_desc);
>      return isoc_found;
>  }
> --
> 2.20.1
> 
>
ping

> 
> ping the series
> 
> > 
> > Allows to remove _SpiceUsbDevice structure.
> > _SpiceUsbDevice is only caching this value from SpiceUsbBackendDevice.
> > 
> > Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
> > ---
> >  src/usb-backend.c | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/src/usb-backend.c b/src/usb-backend.c
> > index 9ac8595c..7e0e4a8a 100644
> > --- a/src/usb-backend.c
> > +++ b/src/usb-backend.c
> > @@ -50,6 +50,8 @@ struct _SpiceUsbBackendDevice
> >      gint ref_count;
> >      SpiceUsbBackendChannel *attached_to;
> >      UsbDeviceInformation device_info;
> > +    uint8_t cached_isochronous_valid : 1;
> > +    uint8_t cached_isochronous : 1;
> >  };
> >  
> >  struct _SpiceUsbBackend
> > @@ -341,6 +343,10 @@ gboolean
> > spice_usb_backend_device_isoch(SpiceUsbBackendDevice *dev)
> >      gint i, j, k;
> >      int rc;
> >  
> > +    if (dev->cached_isochronous_valid) {
> > +        return dev->cached_isochronous;
> > +    }
> > +
> >      g_return_val_if_fail(libdev != NULL, 0);
> >  
> >      rc = libusb_get_active_config_descriptor(libdev, &conf_desc);
> > @@ -362,6 +368,9 @@ gboolean
> > spice_usb_backend_device_isoch(SpiceUsbBackendDevice *dev)
> >          }
> >      }
> >  
> > +    dev->cached_isochronous_valid = TRUE;
> > +    dev->cached_isochronous = isoc_found;
> > +
> >      libusb_free_config_descriptor(conf_desc);
> >      return isoc_found;
> >  }