On 03/30/2017 06:28 PM, Yuyang Du wrote:
> parse_status() reads the status file one by one, so it can only
> update the available and according vhci_driver->idev's.

What are you fixing? This change log doesn't me what is the bug and
what is being fixed.

thanks,
-- Shuah

> 
> Signed-off-by: Yuyang Du <[email protected]>
> ---
>  tools/usb/usbip/libsrc/vhci_driver.c | 36 
> +++++++++++++++---------------------
>  tools/usb/usbip/src/usbip_attach.c   |  2 ++
>  2 files changed, 17 insertions(+), 21 deletions(-)
> 
> diff --git a/tools/usb/usbip/libsrc/vhci_driver.c 
> b/tools/usb/usbip/libsrc/vhci_driver.c
> index 630b139..f596ef4 100644
> --- a/tools/usb/usbip/libsrc/vhci_driver.c
> +++ b/tools/usb/usbip/libsrc/vhci_driver.c
> @@ -43,11 +43,6 @@ static int parse_status(const char *value)
>       int ret = 0;
>       char *c;
>  
> -
> -     for (int i = 0; i < vhci_driver->nports; i++)
> -             memset(&vhci_driver->idev[i], 0, sizeof(vhci_driver->idev[i]));
> -
> -
>       /* skip a header line */
>       c = strchr(value, '\n');
>       if (!c)
> @@ -58,6 +53,7 @@ static int parse_status(const char *value)
>               int port, status, speed, devid;
>               unsigned long socket;
>               char lbusid[SYSFS_BUS_ID_SIZE];
> +             struct usbip_imported_device *idev;
>  
>               ret = sscanf(c, "%d %d %d %x %lx %31s\n",
>                               &port, &status, &speed,
> @@ -72,30 +68,28 @@ static int parse_status(const char *value)
>                               port, status, speed, devid);
>               dbg("socket %lx lbusid %s", socket, lbusid);
>  
> -
>               /* if a device is connected, look at it */
> -             {
> -                     struct usbip_imported_device *idev = 
> &vhci_driver->idev[port];
> +             idev = &vhci_driver->idev[port];
> +
> +             memset(idev, 0, sizeof(*idev));
>  
> -                     idev->port      = port;
> -                     idev->status    = status;
> +             idev->port      = port;
> +             idev->status    = status;
>  
> -                     idev->devid     = devid;
> +             idev->devid     = devid;
>  
> -                     idev->busnum    = (devid >> 16);
> -                     idev->devnum    = (devid & 0x0000ffff);
> +             idev->busnum    = (devid >> 16);
> +             idev->devnum    = (devid & 0x0000ffff);
>  
> -                     if (idev->status != VDEV_ST_NULL
> -                         && idev->status != VDEV_ST_NOTASSIGNED) {
> -                             idev = imported_device_init(idev, lbusid);
> -                             if (!idev) {
> -                                     dbg("imported_device_init failed");
> -                                     return -1;
> -                             }
> +             if (idev->status != VDEV_ST_NULL
> +                 && idev->status != VDEV_ST_NOTASSIGNED) {
> +                     idev = imported_device_init(idev, lbusid);
> +                     if (!idev) {
> +                             dbg("imported_device_init failed");
> +                             return -1;
>                       }
>               }
>  
> -
>               /* go to the next line */
>               c = strchr(c, '\n');
>               if (!c)
> diff --git a/tools/usb/usbip/src/usbip_attach.c 
> b/tools/usb/usbip/src/usbip_attach.c
> index 70a6b50..62a297f 100644
> --- a/tools/usb/usbip/src/usbip_attach.c
> +++ b/tools/usb/usbip/src/usbip_attach.c
> @@ -108,6 +108,8 @@ static int import_device(int sockfd, struct 
> usbip_usb_device *udev)
>               return -1;
>       }
>  
> +     dbg("got free port %d", port);
> +
>       rc = usbip_vhci_attach_device(port, sockfd, udev->busnum,
>                                     udev->devnum, udev->speed);
>       if (rc < 0) {
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to