Re: [PATCH v12 2/9] usbip: exporting devices: modifications to host side libraries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 13, 2016 at 12:52:06PM +0900, Nobuo Iwata wrote:
> usbip_get_device() method in usbip_host_driver_ops was not used. It is 
> modified as a function to find an exported device for new operations 
> 'connect' and 'disconnect'.
> 
> bind and unbind function are exported for the new operations.
> 
> Signed-off-by: Nobuo Iwata <nobuo.iwata@xxxxxxxxxxxxxxx>
> ---
>  tools/usb/usbip/libsrc/usbip_host_common.c | 6 ++----
>  tools/usb/usbip/libsrc/usbip_host_common.h | 8 ++++----
>  tools/usb/usbip/src/usbip.h                | 3 +++
>  tools/usb/usbip/src/usbip_bind.c           | 7 ++++---
>  tools/usb/usbip/src/usbip_unbind.c         | 7 ++++---
>  5 files changed, 17 insertions(+), 14 deletions(-)
> 
> diff --git a/tools/usb/usbip/libsrc/usbip_host_common.c b/tools/usb/usbip/libsrc/usbip_host_common.c
> index 9d41522..6a98d6c 100644
> --- a/tools/usb/usbip/libsrc/usbip_host_common.c
> +++ b/tools/usb/usbip/libsrc/usbip_host_common.c
> @@ -256,17 +256,15 @@ int usbip_export_device(struct usbip_exported_device *edev, int sockfd)
>  }
>  
>  struct usbip_exported_device *usbip_generic_get_device(
> -		struct usbip_host_driver *hdriver, int num)
> +		struct usbip_host_driver *hdriver, char *busid)
>  {
>  	struct list_head *i;
>  	struct usbip_exported_device *edev;
> -	int cnt = 0;
>  
>  	list_for_each(i, &hdriver->edev_list) {
>  		edev = list_entry(i, struct usbip_exported_device, node);
> -		if (num == cnt)
> +		if (!strncmp(busid, edev->udev.busid, SYSFS_BUS_ID_SIZE))
>  			return edev;
> -		cnt++;
>  	}
>  
>  	return NULL;
> diff --git a/tools/usb/usbip/libsrc/usbip_host_common.h b/tools/usb/usbip/libsrc/usbip_host_common.h
> index a64b803..f9a9def 100644
> --- a/tools/usb/usbip/libsrc/usbip_host_common.h
> +++ b/tools/usb/usbip/libsrc/usbip_host_common.h
> @@ -38,7 +38,7 @@ struct usbip_host_driver_ops {
>  	void (*close)(struct usbip_host_driver *hdriver);
>  	int (*refresh_device_list)(struct usbip_host_driver *hdriver);
>  	struct usbip_exported_device * (*get_device)(
> -		struct usbip_host_driver *hdriver, int num);
> +		struct usbip_host_driver *hdriver, char *busid);
>  
>  	int (*read_device)(struct udev_device *sdev,
>  			   struct usbip_usb_device *dev);
> @@ -86,11 +86,11 @@ static inline int usbip_refresh_device_list(struct usbip_host_driver *hdriver)
>  }
>  
>  static inline struct usbip_exported_device *
> -usbip_get_device(struct usbip_host_driver *hdriver, int num)
> +usbip_get_device(struct usbip_host_driver *hdriver, char *busid)
>  {
>  	if (!hdriver->ops.get_device)
>  		return NULL;
> -	return hdriver->ops.get_device(hdriver, num);
> +	return hdriver->ops.get_device(hdriver, busid);
>  }
>  
>  /* Helper functions for implementing driver backend */
> @@ -99,6 +99,6 @@ void usbip_generic_driver_close(struct usbip_host_driver *hdriver);
>  int usbip_generic_refresh_device_list(struct usbip_host_driver *hdriver);
>  int usbip_export_device(struct usbip_exported_device *edev, int sockfd);
>  struct usbip_exported_device *usbip_generic_get_device(
> -		struct usbip_host_driver *hdriver, int num);
> +		struct usbip_host_driver *hdriver, char *busid);
>  
>  #endif /* __USBIP_HOST_COMMON_H */
> diff --git a/tools/usb/usbip/src/usbip.h b/tools/usb/usbip/src/usbip.h
> index 84fe66a..c296910 100644
> --- a/tools/usb/usbip/src/usbip.h
> +++ b/tools/usb/usbip/src/usbip.h
> @@ -37,4 +37,7 @@ void usbip_list_usage(void);
>  void usbip_bind_usage(void);
>  void usbip_unbind_usage(void);
>  
> +int usbip_bind_device(char *busid);
> +int usbip_unbind_device(char *busid);
> +
>  #endif /* __USBIP_H */
> diff --git a/tools/usb/usbip/src/usbip_bind.c b/tools/usb/usbip/src/usbip_bind.c
> index fa46141..1c09338 100644
> --- a/tools/usb/usbip/src/usbip_bind.c
> +++ b/tools/usb/usbip/src/usbip_bind.c
> @@ -1,5 +1,6 @@
>  /*
> - * Copyright (C) 2011 matt mooney <mfm@xxxxxxxxxxxxx>
> + * Copyright (C) 2015 Nobuo Iwata
> + *               2011 matt mooney <mfm@xxxxxxxxxxxxx>

Minor nit, you are not modifying this file enough to claim copyright,
according to the copyright rules I am familiar with, so please do not do
so here.

>   *               2005-2007 Takahiro Hirofuchi
>   *
>   * This program is free software: you can redistribute it and/or modify
> @@ -139,7 +140,7 @@ static int unbind_other(char *busid)
>  	return status;
>  }
>  
> -static int bind_device(char *busid)
> +int usbip_bind_device(char *busid)
>  {
>  	int rc;
>  	struct udev *udev;
> @@ -200,7 +201,7 @@ int usbip_bind(int argc, char *argv[])
>  
>  		switch (opt) {
>  		case 'b':
> -			ret = bind_device(optarg);
> +			ret = usbip_bind_device(optarg);
>  			goto out;
>  		default:
>  			goto err_out;
> diff --git a/tools/usb/usbip/src/usbip_unbind.c b/tools/usb/usbip/src/usbip_unbind.c
> index a4a496c..cc1ff26 100644
> --- a/tools/usb/usbip/src/usbip_unbind.c
> +++ b/tools/usb/usbip/src/usbip_unbind.c
> @@ -1,5 +1,6 @@
>  /*
> - * Copyright (C) 2011 matt mooney <mfm@xxxxxxxxxxxxx>
> + * Copyright (C) 2015 Nobuo Iwata
> + *               2011 matt mooney <mfm@xxxxxxxxxxxxx>

Same here :(

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



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux