Re: [PATCH v2 05/11] usbip: tools for userspace URBs transmission

2015-04-21 Thread Valentina Manea
On Tue, Apr 14, 2015 at 10:00 AM, Nobuo Iwata
nobuo.iw...@fujixerox.co.jp wrote:
 diff --git a/tools/usb/usbip/libsrc/usbip_ux.h 
 b/tools/usb/usbip/libsrc/usbip_ux.h
 new file mode 100644
 index 000..7506a1c
 --- /dev/null
 +++ b/tools/usb/usbip/libsrc/usbip_ux.h

 +#include ../../../../include/uapi/linux/usbip_ux.h

This is an absolute no-no. It is not mandatory that users have a
kernel tree when compiling the userspace utility - for example, when
they get the sources from their distro.
Instead, that header will be included by the distro in the exported
kernel headers you find in /usr/include. So you can just refer this as
linux/usbip_ux.h but it won't be available until distros pick it up.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 00/11] usbip: features to USB over WebSocket

2015-04-21 Thread Valentina Manea
Hi,

Managed to go through your series and looks like you've spent some
time on this. Good job!
However, given the density of the patches, I haven't really been able
to go through every line of code.
I did do some basic testing and made some comments where needed.

Shuah, Greg, do you think more thorought review is needed?

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


Re: [PATCH v2 04/11] usbip: kernel module for userspace URBs transmission

2015-04-21 Thread Valentina Manea
Looks ok.

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


Re: [PATCH v2 06/11] usbip: readme about user space URBs transmission

2015-04-21 Thread Valentina Manea
Looks good.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 01/11] usbip: exporting devices

2015-04-21 Thread Valentina Manea
Hi,

I looked around your patch and tested it and looks good.
However, I do have 2 nit-picks:

* I noticed in some places you've used labels such as err0 and err1.
Please replace them with something more relevant to their
functionality, such as what you're cleaning up after. There are
examples of this both in USB/IP code and throughout the kernel.
* when calling open_hc_device(), you're using magic constants - 0 and
1. Define them as constants with meaningful names.

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


Re: [PATCH v2 02/11] usbip: readme and manuals about exporting devices

2015-04-21 Thread Valentina Manea
On Tue, Apr 14, 2015 at 10:00 AM, Nobuo Iwata
nobuo.iw...@fujixerox.co.jp wrote:

 -server:# usbip bind --busid=1-2
 +dev:# usbip bind --busid=1-2
  - Bind usbip-host.ko to the device of busid 1-2.
 -- A usb device 1-2 is now exportable to other hosts!
 -- Use 'usbip unbind --busid=1-2' when you want to shutdown exporting 
 and use the device locally.
 +- USB device 1-2 is now importable from other computer!
 +
 +dev:# usbip unbind --busid=1-2
 +- Unind usbip-host.ko from the device of busid 1-2.
 +- USB device 1-2 is not importable from other computer.


I see various parameters, such as --busid, followed by an = sign.
This looks like a thing thoughout the manual.
Although this syntax works as well, I think we should be consistent
and not include =.
I, personally, prefer having --busid busid instead of --busid=busid.

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


Re: [PATCH v2 03/11] usbip: safe completion against usb_kill_urb()

2015-04-21 Thread Valentina Manea
On Tue, Apr 14, 2015 at 10:00 AM, Nobuo Iwata
nobuo.iw...@fujixerox.co.jp wrote:
 stub_shutdown_connection() : drivers/usb/usbip/stub_dev.c
  stub_device_cleanup_urbs() : drivers/usb/usbip/stub_main.c
 requests to kill pending URBs and clears priv lists.

 stub_complete() : drivers/usb/usbip/stub_tx.c might be called with URBs
 to have been requested to kill.

 To avoid kernel panic, this patch ignores killed URBs linked to cleared
 priv lists.
 To know the killed URBs in stub_complete(), sdev-ud.tcp_socket which
 cleared before stub_device_cleanup_urbs() is checked.

 Signed-off-by: Nobuo Iwata nobuo.iw...@fujixerox.co.jp
 ---
  drivers/usb/usbip/stub_tx.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

 diff --git a/drivers/usb/usbip/stub_tx.c b/drivers/usb/usbip/stub_tx.c
 index dbcabc9..f19f321 100644
 --- a/drivers/usb/usbip/stub_tx.c
 +++ b/drivers/usb/usbip/stub_tx.c
 @@ -97,7 +97,9 @@ void stub_complete(struct urb *urb)

 /* link a urb to the queue of tx. */
 spin_lock_irqsave(sdev-priv_lock, flags);
 -   if (priv-unlinking) {
 +   if (sdev-ud.tcp_socket == NULL) {
 +   dev_info(urb-dev-dev, discard a urb for closed 
 connection);
 +   } else if (priv-unlinking) {
 stub_enqueue_ret_unlink(sdev, priv-seqnum, urb-status);
 stub_free_priv_and_urb(priv);
 } else {
 --
 2.1.0


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


Re: [PATCH 01/13] USB/IP: exporting devices

2015-04-19 Thread Valentina Manea
Hi,

On Fri, Apr 3, 2015 at 3:33 AM, Nobuo Iwata nobuo.iw...@fujixerox.co.jp wrote:

 For this, export function, connection is established from device-side machine 
 to application-side machine.

 Following use cases are supposed for the export function.
 1) Server application or cloud service serves distributed ubiquitous devices.
 2) Dedicate devices to server application or cloud service.

 To connect to cloud service, it needs to connect from inside of firewall.


Could you please provide some more detailed examples of use cases for
this feature?

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


Re:

2015-04-17 Thread Valentina Manea
Hi,

Sorry for the lack of review on this series; will take care of this tomorrow.

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


Re: [PATCH 21/22] usbip: vhci_hcd: use USB_DT_HUB

2015-03-31 Thread Valentina Manea
On Sun, Mar 29, 2015 at 12:45 AM, Sergei Shtylyov
sergei.shtyl...@cogentembedded.com wrote:
 Fix  using the  bare number to set the 'bDescriptorType' field of the Hub
 Descriptor while the value  is #define'd in linux/usb/ch11.h.

 Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com

 ---
  drivers/usb/usbip/vhci_hcd.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 Index: usb/drivers/usb/usbip/vhci_hcd.c
 ===
 --- usb.orig/drivers/usb/usbip/vhci_hcd.c
 +++ usb/drivers/usb/usbip/vhci_hcd.c
 @@ -216,7 +216,7 @@ done:
  static inline void hub_descriptor(struct usb_hub_descriptor *desc)
  {
 memset(desc, 0, sizeof(*desc));
 -   desc-bDescriptorType = 0x29;
 +   desc-bDescriptorType = USB_DT_HUB;
 desc-bDescLength = 9;
 desc-wHubCharacteristics = __constant_cpu_to_le16(
 HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_COMMON_OCPM);


Acked-by: Valentina Manea valentina.mane...@gmail.com
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 22/23] usbip: vhci_hcd: use HUB_CHAR_*

2015-01-23 Thread Valentina Manea
On Mon, Jan 19, 2015 at 1:00 AM, Sergei Shtylyov
sergei.shtyl...@cogentembedded.com wrote:
 Fix  using the  bare number  to set the 'wHubCharacteristics' field of the Hub
 Descriptor while the values are #define'd in linux/usb/ch11.h.

 Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com

 ---
  drivers/usb/usbip/vhci_hcd.c |3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

 Index: usb/drivers/usb/usbip/vhci_hcd.c
 ===
 --- usb.orig/drivers/usb/usbip/vhci_hcd.c
 +++ usb/drivers/usb/usbip/vhci_hcd.c
 @@ -218,7 +218,8 @@ static inline void hub_descriptor(struct
 memset(desc, 0, sizeof(*desc));
 desc-bDescriptorType = 0x29;
 desc-bDescLength = 9;
 -   desc-wHubCharacteristics = (__constant_cpu_to_le16(0x0001));
 +   desc-wHubCharacteristics = __constant_cpu_to_le16(
 +   HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_COMMON_OCPM);
 desc-bNbrPorts = VHCI_NPORTS;
 desc-u.hs.DeviceRemovable[0] = 0xff;
 desc-u.hs.DeviceRemovable[1] = 0xff;


Looks good.

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


Re: [PATCH] usbip: fix error handling in stub_probe()

2014-12-01 Thread Valentina Manea
On Sat, Nov 29, 2014 at 12:29 AM, Alexey Khoroshilov
khoroshi...@ispras.ru wrote:
 If usb_hub_claim_port() fails, no resources are deallocated and
 if stub_add_files() fails, port is not released.

 The patch fixes these issues and rearranges error handling code.

 Found by Linux Driver Verification project (linuxtesting.org).

 Signed-off-by: Alexey Khoroshilov khoroshi...@ispras.ru
 ---
  drivers/usb/usbip/stub_dev.c | 26 +++---
  1 file changed, 15 insertions(+), 11 deletions(-)

 diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
 index fac20e0434c0..a3ec49bdc1e6 100644
 --- a/drivers/usb/usbip/stub_dev.c
 +++ b/drivers/usb/usbip/stub_dev.c
 @@ -311,7 +311,6 @@ static int stub_probe(struct usb_device *udev)
  {
 struct stub_device *sdev = NULL;
 const char *udev_busid = dev_name(udev-dev);
 -   int err = 0;
 struct bus_id_priv *busid_priv;
 int rc;

 @@ -372,23 +371,28 @@ static int stub_probe(struct usb_device *udev)
 (struct usb_dev_state *) udev);
 if (rc) {
 dev_dbg(udev-dev, unable to claim port\n);
 -   return rc;
 +   goto err_port;
 }

 -   err = stub_add_files(udev-dev);
 -   if (err) {
 +   rc = stub_add_files(udev-dev);
 +   if (rc) {
 dev_err(udev-dev, stub_add_files for %s\n, udev_busid);
 -   dev_set_drvdata(udev-dev, NULL);
 -   usb_put_dev(udev);
 -   kthread_stop_put(sdev-ud.eh);
 -
 -   busid_priv-sdev = NULL;
 -   stub_device_free(sdev);
 -   return err;
 +   goto err_files;
 }
 busid_priv-status = STUB_BUSID_ALLOC;

 return 0;
 +err_files:
 +   usb_hub_release_port(udev-parent, udev-portnum,
 +(struct usb_dev_state *) udev);
 +err_port:
 +   dev_set_drvdata(udev-dev, NULL);
 +   usb_put_dev(udev);
 +   kthread_stop_put(sdev-ud.eh);
 +
 +   busid_priv-sdev = NULL;
 +   stub_device_free(sdev);
 +   return rc;
  }

  static void shutdown_busid(struct bus_id_priv *busid_priv)
 --
 1.9.1


Nice catch.

Acked-by: Valentina Manea valentina.mane...@gmail.com
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] usbip: remove unneeded structure

2014-12-01 Thread Valentina Manea
On Sun, Nov 30, 2014 at 8:14 PM, Julia Lawall julia.law...@lip6.fr wrote:
 From: Julia Lawall julia.law...@lip6.fr

 Delete a local structure that is only used to be initialized by memset.

 A semantic patch that makes this change is as follows:
 (http://coccinelle.lip6.fr/)

 // smpl
 @@
 identifier x,i;
 @@

 {
 ... when any
 -struct i x;
 +... when != x
 - memset(x,...);
 ...+
 }
 // /smpl

 Signed-off-by: Julia Lawall julia.law...@lip6.fr

 ---
  tools/usb/usbip/src/usbipd.c |2 --
  1 file changed, 2 deletions(-)

 diff --git a/tools/usb/usbip/src/usbipd.c b/tools/usb/usbip/src/usbipd.c
 index 2f87f2d..2a7cd2b 100644
 --- a/tools/usb/usbip/src/usbipd.c
 +++ b/tools/usb/usbip/src/usbipd.c
 @@ -91,7 +91,6 @@ static void usbipd_help(void)
  static int recv_request_import(int sockfd)
  {
 struct op_import_request req;
 -   struct op_common reply;
 struct usbip_exported_device *edev;
 struct usbip_usb_device pdu_udev;
 struct list_head *i;
 @@ -100,7 +99,6 @@ static int recv_request_import(int sockfd)
 int rc;

 memset(req, 0, sizeof(req));
 -   memset(reply, 0, sizeof(reply));

 rc = usbip_net_recv(sockfd, req, sizeof(req));
 if (rc  0) {


Acked-by: Valentina Manea valentina.mane...@gmail.com
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1] USB-IP: Deletion of unnecessary checks before the function call usb_put_dev

2014-11-21 Thread Valentina Manea
On Fri, Nov 21, 2014 at 5:36 PM, SF Markus Elfring
elfr...@users.sourceforge.net wrote:
 From: Markus Elfring elfr...@users.sourceforge.net
 Date: Fri, 21 Nov 2014 16:33:18 +0100

 The usb_put_dev() function tests whether its argument is NULL and then
 returns immediately. Thus the test around the call is not needed.

 This issue was detected by using the Coccinelle software.

 Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
 ---
  drivers/usb/usbip/vhci_hcd.c | 9 +++--
  1 file changed, 3 insertions(+), 6 deletions(-)

 diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
 index c02374b..cc1b03e 100644
 --- a/drivers/usb/usbip/vhci_hcd.c
 +++ b/drivers/usb/usbip/vhci_hcd.c
 @@ -518,8 +518,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct 
 urb *urb,
 dev_info(dev, SetAddress Request (%d) to port %d\n,
  ctrlreq-wValue, vdev-rhport);

 -   if (vdev-udev)
 -   usb_put_dev(vdev-udev);
 +   usb_put_dev(vdev-udev);
 vdev-udev = usb_get_dev(urb-dev);

 spin_lock(vdev-ud.lock);
 @@ -539,8 +538,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct 
 urb *urb,
 usbip_dbg_vhci_hc(
 Not yet?:Get_Descriptor to device 0 
 (get max pipe size)\n);

 -   if (vdev-udev)
 -   usb_put_dev(vdev-udev);
 +   usb_put_dev(vdev-udev);
 vdev-udev = usb_get_dev(urb-dev);
 goto out;

 @@ -831,8 +829,7 @@ static void vhci_device_reset(struct usbip_device *ud)
 vdev-speed  = 0;
 vdev-devid  = 0;

 -   if (vdev-udev)
 -   usb_put_dev(vdev-udev);
 +   usb_put_dev(vdev-udev);
 vdev-udev = NULL;

 if (ud-tcp_socket) {
 --
 2.1.3


Acked-by: Valentina Manea valentina.mane...@gmail.com
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: usbip: fix usbip.h path in userspace tool

2014-09-04 Thread Valentina Manea
On Thu, Sep 4, 2014 at 2:41 AM, Greg KH gre...@linuxfoundation.org wrote:

 Shouldn't you be able to use the same path as ch9.h uses?  It's a uapi
 .h file, no relative paths should be needed.


For the userspace tool, the build system only looks for headers in the
system default locations, such as /usr/include. Hence, this won't work
for systems that don't have kernel 3.17 headers. This patch is a
pretty nasty hack to get it to compile within the kernel tree.
I wonder whether we can make this self-contained by duplicating the
header's content inside usbip_common.h. Greg, Shuah, what do you
think?

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


Re: [PATCH] usb: usbip: fix usbip.h path in userspace tool

2014-09-04 Thread Valentina Manea
On Thu, Sep 4, 2014 at 5:14 AM, Greg KH gre...@linuxfoundation.org wrote:

 This patch is a pretty nasty hack to get it to compile within the
 kernel tree.  I wonder whether we can make this self-contained by
 duplicating the header's content inside usbip_common.h.

 Ick, no, don't do that, use the .h file, that is what it is there for.


This leaves 2 options:
a. include the file the way this patch did it
b. include as linux/usbip.h and add the relative path in the kernel
tree to include/uapi as include path. the problem with this is that
the previous header, ch9.h, eventually includes other kernel headers
and a path to include/ would also be necessary. plus, there's a
warning about using kernel headers from user space, which is legit.

For the time being, I suppose the first option will do.

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


Re: [PATCH v2] usb: usbip: fix usbip.h path in userspace tool

2014-09-04 Thread Valentina Manea
On Fri, Sep 5, 2014 at 1:58 AM, Piotr Król piotr.k...@3mdeb.com wrote:
 Fixes: 588b48caf65c (usbip: move usbip userspace code out of staging)
 which introduced build failure by not changing uapi/usbip.h include path
 according to new location.

 Signed-off-by: Piotr Król piotr.k...@3mdeb.com
 ---
  include/uapi/linux/Kbuild | 1 +
  tools/usb/usbip/libsrc/usbip_common.h | 2 +-
  2 files changed, 2 insertions(+), 1 deletion(-)

 diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
 index 24e9033f8b3f..9955c3b0ef93 100644
 --- a/include/uapi/linux/Kbuild
 +++ b/include/uapi/linux/Kbuild
 @@ -395,6 +395,7 @@ header-y += un.h
  header-y += unistd.h
  header-y += unix_diag.h
  header-y += usbdevice_fs.h
 +header-y += usbip.h
  header-y += utime.h
  header-y += utsname.h
  header-y += uuid.h
 diff --git a/tools/usb/usbip/libsrc/usbip_common.h 
 b/tools/usb/usbip/libsrc/usbip_common.h
 index 5a0e95edf4df..15fe792e1e96 100644
 --- a/tools/usb/usbip/libsrc/usbip_common.h
 +++ b/tools/usb/usbip/libsrc/usbip_common.h
 @@ -15,7 +15,7 @@
  #include syslog.h
  #include unistd.h
  #include linux/usb/ch9.h
 -#include ../../uapi/usbip.h
 +#include linux/usbip.h

  #ifndef USBIDS_FILE
  #define USBIDS_FILE /usr/share/hwdata/usb.ids
 --
 2.1.0


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


Re: staging: usbip: bugfix for isochronous packets and optimization

2014-08-26 Thread Valentina Manea
On Tue, Aug 26, 2014 at 6:12 AM, Dan Carpenter dan.carpen...@oracle.com wrote:
 This was promoted out of staging and there wasn't an email to the
 staging list.  Normally I like to go through any remaining questions
 before the code is moved. The code looks pretty good, I just had one
 question.


I didn't know I should send to that list as well; will keep in mind
for next time.

 drivers/usb/usbip/usbip_common.c:712 usbip_pad_iso()
 warn: why is zero skipped 'i'

 drivers/usb/usbip/usbip_common.c
687  void usbip_pad_iso(struct usbip_device *ud, struct urb *urb)
688  {
689  int np = urb-number_of_packets;
690  int i;
691  int actualoffset = urb-actual_length;
692
693  if (!usb_pipeisoc(urb-pipe))
694  return;
695
696  /* if no packets or length of data is 0, then nothing to 
 unpack */
697  if (np == 0 || urb-actual_length == 0)
698  return;
699
700  /*
701   * if actual_length is transfer_buffer_length then no padding 
 is
702   * present.
703   */
704  if (urb-actual_length == urb-transfer_buffer_length)
705  return;
706
707  /*
708   * loop over all packets from last to first (to prevent 
 overwritting
709   * memory when padding) and move them into the proper place
710   */
711  for (i = np-1; i  0; i--) {

 I don't understand this loop.  If we really intended to skip the first
 packet then why isn't the if (np == 0 condition if (np = 1?  That
 would be more clear and the comment would say if 1 packet then nothing
 to unpack.

712  actualoffset -= urb-iso_frame_desc[i].actual_length;
713  memmove(urb-transfer_buffer + 
 urb-iso_frame_desc[i].offset,
714  urb-transfer_buffer + actualoffset,
715  urb-iso_frame_desc[i].actual_length);
716  }
717  }


urb-actual_length is the sum of individual packets' lengths,
urb-iso_frame_desc[i].actual_length. Since actualoffset in the loop
keeps decreasing, it will reach 0 when the first packet is processed.
The first packet's offset is 0 as well and this just does memmove to
the same buffer location.
The (np == 0) condition is *not* the same as (np = 1) because we want
to return only is there are any packets.
In my opinion, the code is correct as it is. Do you think I should add
an extra comment about the loop?

 Also there is a smatch warning:
 drivers/usb/usbip/stub_tx.c:186 stub_send_ret_submit() warn: returning -1 
 instead of -ENOMEM is sloppy


Noted, will fix after the patch series is upstream.

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


Re: staging: usbip: bugfix for isochronous packets and optimization

2014-08-26 Thread Valentina Manea
On Tue, Aug 26, 2014 at 11:47 AM, Dan Carpenter
dan.carpen...@oracle.com wrote:
 On Tue, Aug 26, 2014 at 09:06:17AM -0700, Valentina Manea wrote:
 On Tue, Aug 26, 2014 at 6:12 AM, Dan Carpenter dan.carpen...@oracle.com 
 wrote:
 707  /*
 708   * loop over all packets from last to first (to prevent 
  overwritting
 709   * memory when padding) and move them into the proper place
 710   */
 711  for (i = np-1; i  0; i--) {
 
  I don't understand this loop.  If we really intended to skip the first
  packet then why isn't the if (np == 0 condition if (np = 1?  That
  would be more clear and the comment would say if 1 packet then nothing
  to unpack.
 
 712  actualoffset -= 
  urb-iso_frame_desc[i].actual_length;
 713  memmove(urb-transfer_buffer + 
  urb-iso_frame_desc[i].offset,
 714  urb-transfer_buffer + actualoffset,
 715  urb-iso_frame_desc[i].actual_length);
 716  }
 717  }
 

 urb-actual_length is the sum of individual packets' lengths,
 urb-iso_frame_desc[i].actual_length. Since actualoffset in the loop
 keeps decreasing, it will reach 0 when the first packet is processed.
 The first packet's offset is 0 as well and this just does memmove to
 the same buffer location.

 It actually won't do the memove() if the i = 0, because the for loop
 condition says i  0.


Well, yes. What I said would happen if it wasn't i  0. Having this
prevents a useless memmove.

 The (np == 0) condition is *not* the same as (np = 1) because we want
 to return only is there are any packets.

 Read the code again.  For np == 1 then it doesn't do anything because it
 doesn't enter the for loop.  In other words, it returns without doing
 anything either way.


It just happens that for np == 1 doesn't do anything and returns but,
conceptually, having one packet
that doesn't need extra processing (for loop) is not the same as not
having any packets at all (np == 0)
and I believe we shouldn't mix up these conditions.

 I'm not necessarily saying the code is wrong...  I just think that it
 would be more clear if we said explicitly that we should return without
 doing anything if np == 1.


I think just adding a comment about the for loop stating that the
first packet doesn't need any extra processing would suffice.

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


Re: [PATCH 1/4] usbip: move usbip userspace code out of staging

2014-08-24 Thread Valentina Manea
On Tue, Aug 19, 2014 at 9:30 PM, Valentina Manea
valentina.mane...@gmail.com wrote:
 At this point, USB/IP userspace code is fully functional
 and can be moved out of staging.

 Signed-off-by: Valentina Manea valentina.mane...@gmail.com

Bumping this in case Greg missed the patch series.

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


Re: [PATCH 2/3] usbip: move usbip kernel code out of staging

2014-08-19 Thread Valentina Manea
On Tue, Aug 19, 2014 at 11:38 AM, Greg KH gre...@linuxfoundation.org wrote:

 This patch moves the code, but now it's gone from the build system as
 it is not hooked up and can not be built at all.

 So while I really wanted to apply this series right now, I can't, as
 this is a regression (working driver - no driver).

You mean it should be in Kbuild and Makefile from drivers/, right?
Will resend the series again, with MAINTAINERS modified.

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


[PATCH 3/4] usbip: remove struct usb_device_id table

2014-08-19 Thread Valentina Manea
This was used back when usbip-host was an interface device driver;
after the conversion to device driver, the table remained unused.
Remove it in order to stop receiving a warning about it.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/usb/usbip/stub_dev.c | 27 ---
 1 file changed, 27 deletions(-)

diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
index 51d0c71..fac20e0 100644
--- a/drivers/usb/usbip/stub_dev.c
+++ b/drivers/usb/usbip/stub_dev.c
@@ -26,33 +26,6 @@
 #include stub.h
 
 /*
- * Define device IDs here if you want to explicitly limit exportable devices.
- * In most cases, wildcard matching will be okay because driver binding can be
- * changed dynamically by a userland program.
- */
-static struct usb_device_id stub_table[] = {
-#if 0
-   /* just an example */
-   { USB_DEVICE(0x05ac, 0x0301) },   /* Mac 1 button mouse */
-   { USB_DEVICE(0x0430, 0x0009) },   /* Plat Home Keyboard */
-   { USB_DEVICE(0x059b, 0x0001) },   /* Iomega USB Zip 100 */
-   { USB_DEVICE(0x04b3, 0x4427) },   /* IBM USB CD-ROM */
-   { USB_DEVICE(0x05a9, 0xa511) },   /* LifeView USB cam */
-   { USB_DEVICE(0x55aa, 0x0201) },   /* Imation card reader */
-   { USB_DEVICE(0x046d, 0x0870) },   /* Qcam Express(QV-30) */
-   { USB_DEVICE(0x04bb, 0x0101) },   /* IO-DATA HD 120GB */
-   { USB_DEVICE(0x04bb, 0x0904) },   /* IO-DATA USB-ET/TX */
-   { USB_DEVICE(0x04bb, 0x0201) },   /* IO-DATA USB-ET/TX */
-   { USB_DEVICE(0x08bb, 0x2702) },   /* ONKYO USB Speaker */
-   { USB_DEVICE(0x046d, 0x08b2) },   /* Logicool Qcam 4000 Pro */
-#endif
-   /* magic for wild card */
-   { .driver_info = 1 },
-   { 0, } /* Terminating entry */
-};
-MODULE_DEVICE_TABLE(usb, stub_table);
-
-/*
  * usbip_status shows the status of usbip-host as long as this driver is bound
  * to the target device.
  */
-- 
1.8.1.2

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


[PATCH 0/4] *** SUBJECT HERE ***

2014-08-19 Thread Valentina Manea
After migrating userspace code to libudev, converting usbip-host
to a device driver and various bug fixes and enhancements, USB/IP
is fully functional and can be moved out of staging.

This patch series moves it as following:
* userspace code to tools/usb/usbip
* kernel code to drivers/usb/usbip

A warning generated in the kernel code is also solved and an entry
in MAINTAINERS file is created for this driver.

Valentina Manea (4):
  usbip: move usbip userspace code out of staging
  usbip: move usbip kernel code out of staging
  usbip: remove struct usb_device_id table
  MAINTAINERS: Add an entry for USB/IP driver

 MAINTAINERS|  8 +++
 drivers/staging/Kconfig|  2 --
 drivers/staging/Makefile   |  1 -
 drivers/usb/Kconfig|  2 ++
 drivers/usb/Makefile   |  2 ++
 drivers/{staging = usb}/usbip/Kconfig |  0
 drivers/{staging = usb}/usbip/Makefile|  0
 drivers/{staging = usb}/usbip/README  |  0
 drivers/{staging = usb}/usbip/stub.h  |  0
 drivers/{staging = usb}/usbip/stub_dev.c  | 27 --
 drivers/{staging = usb}/usbip/stub_main.c |  0
 drivers/{staging = usb}/usbip/stub_rx.c   |  0
 drivers/{staging = usb}/usbip/stub_tx.c   |  0
 drivers/{staging = usb}/usbip/usbip_common.c  |  0
 drivers/{staging = usb}/usbip/usbip_common.h  |  2 +-
 drivers/{staging = usb}/usbip/usbip_event.c   |  0
 drivers/{staging = usb}/usbip/usbip_protocol.txt  |  0
 drivers/{staging = usb}/usbip/vhci.h  |  0
 drivers/{staging = usb}/usbip/vhci_hcd.c  |  0
 drivers/{staging = usb}/usbip/vhci_rx.c   |  0
 drivers/{staging = usb}/usbip/vhci_sysfs.c|  0
 drivers/{staging = usb}/usbip/vhci_tx.c   |  0
 .../usbip/uapi = include/uapi/linux}/usbip.h  |  0
 .../usbip/userspace = tools/usb/usbip}/.gitignore |  0
 .../usbip/userspace = tools/usb/usbip}/AUTHORS|  0
 .../usbip/userspace = tools/usb/usbip}/COPYING|  0
 .../usbip/userspace = tools/usb/usbip}/INSTALL|  0
 .../userspace = tools/usb/usbip}/Makefile.am  |  0
 .../usbip/userspace = tools/usb/usbip}/README |  0
 .../usbip/userspace = tools/usb/usbip}/autogen.sh |  0
 .../usbip/userspace = tools/usb/usbip}/cleanup.sh |  0
 .../userspace = tools/usb/usbip}/configure.ac |  0
 .../userspace = tools/usb/usbip}/doc/usbip.8  |  0
 .../userspace = tools/usb/usbip}/doc/usbipd.8 |  0
 .../usb/usbip}/libsrc/Makefile.am  |  0
 .../userspace = tools/usb/usbip}/libsrc/list.h|  0
 .../userspace = tools/usb/usbip}/libsrc/names.c   |  0
 .../userspace = tools/usb/usbip}/libsrc/names.h   |  0
 .../usb/usbip}/libsrc/sysfs_utils.c|  0
 .../usb/usbip}/libsrc/sysfs_utils.h|  0
 .../usb/usbip}/libsrc/usbip_common.c   |  0
 .../usb/usbip}/libsrc/usbip_common.h   |  0
 .../usb/usbip}/libsrc/usbip_host_driver.c  |  0
 .../usb/usbip}/libsrc/usbip_host_driver.h  |  0
 .../usb/usbip}/libsrc/vhci_driver.c|  0
 .../usb/usbip}/libsrc/vhci_driver.h|  0
 .../userspace = tools/usb/usbip}/src/Makefile.am  |  0
 .../userspace = tools/usb/usbip}/src/usbip.c  |  0
 .../userspace = tools/usb/usbip}/src/usbip.h  |  0
 .../usb/usbip}/src/usbip_attach.c  |  0
 .../userspace = tools/usb/usbip}/src/usbip_bind.c |  0
 .../usb/usbip}/src/usbip_detach.c  |  0
 .../userspace = tools/usb/usbip}/src/usbip_list.c |  0
 .../usb/usbip}/src/usbip_network.c |  0
 .../usb/usbip}/src/usbip_network.h |  0
 .../userspace = tools/usb/usbip}/src/usbip_port.c |  0
 .../usb/usbip}/src/usbip_unbind.c  |  0
 .../userspace = tools/usb/usbip}/src/usbipd.c |  0
 .../userspace = tools/usb/usbip}/src/utils.c  |  0
 .../userspace = tools/usb/usbip}/src/utils.h  |  0
 60 files changed, 13 insertions(+), 31 deletions(-)
 rename drivers/{staging = usb}/usbip/Kconfig (100%)
 rename drivers/{staging = usb}/usbip/Makefile (100%)
 rename drivers/{staging = usb}/usbip/README (100%)
 rename drivers/{staging = usb}/usbip/stub.h (100%)
 rename drivers/{staging = usb}/usbip/stub_dev.c (90%)
 rename drivers/{staging = usb}/usbip/stub_main.c (100%)
 rename drivers/{staging = usb}/usbip/stub_rx.c (100%)
 rename drivers/{staging = usb}/usbip/stub_tx.c (100%)
 rename drivers/{staging = usb}/usbip/usbip_common.c (100%)
 rename drivers/{staging = usb}/usbip/usbip_common.h (99%)
 rename drivers/{staging = usb}/usbip/usbip_event.c (100%)
 rename drivers/{staging = usb}/usbip/usbip_protocol.txt (100%)
 rename drivers/{staging = usb}/usbip/vhci.h (100%)
 rename drivers/{staging = usb}/usbip/vhci_hcd.c (100%)
 rename drivers/{staging = usb}/usbip/vhci_rx.c (100%)
 rename drivers/{staging = usb}/usbip/vhci_sysfs.c (100

[PATCH 1/4] usbip: move usbip userspace code out of staging

2014-08-19 Thread Valentina Manea
At this point, USB/IP userspace code is fully functional
and can be moved out of staging.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 {drivers/staging/usbip/userspace = tools/usb/usbip}/.gitignore   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/AUTHORS  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/COPYING  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/INSTALL  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/Makefile.am  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/README   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/autogen.sh   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/cleanup.sh   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/configure.ac | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/doc/usbip.8  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/doc/usbipd.8 | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/Makefile.am   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/list.h| 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/names.c   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/names.h   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/sysfs_utils.c | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/sysfs_utils.h | 0
 .../staging/usbip/userspace = tools/usb/usbip}/libsrc/usbip_common.c | 0
 .../staging/usbip/userspace = tools/usb/usbip}/libsrc/usbip_common.h | 0
 .../usbip/userspace = tools/usb/usbip}/libsrc/usbip_host_driver.c| 0
 .../usbip/userspace = tools/usb/usbip}/libsrc/usbip_host_driver.h| 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/vhci_driver.c | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/vhci_driver.h | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/Makefile.am  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip.c  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip.h  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip_attach.c   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip_bind.c | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip_detach.c   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip_list.c | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip_network.c  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip_network.h  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip_port.c | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip_unbind.c   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbipd.c | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/utils.c  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/utils.h  | 0
 37 files changed, 0 insertions(+), 0 deletions(-)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/.gitignore (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/AUTHORS (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/COPYING (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/INSTALL (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/Makefile.am (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/README (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/autogen.sh (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/cleanup.sh (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/configure.ac (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/doc/usbip.8 (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/doc/usbipd.8 (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/Makefile.am 
(100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/list.h 
(100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/names.c 
(100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/names.h 
(100%)
 rename {drivers/staging/usbip/userspace = 
tools/usb/usbip}/libsrc/sysfs_utils.c (100%)
 rename {drivers/staging/usbip/userspace = 
tools/usb/usbip}/libsrc/sysfs_utils.h (100%)
 rename {drivers/staging/usbip/userspace = 
tools/usb/usbip}/libsrc/usbip_common.c (100%)
 rename {drivers/staging/usbip/userspace = 
tools/usb/usbip}/libsrc/usbip_common.h (100%)
 rename {drivers/staging/usbip/userspace = 
tools/usb/usbip}/libsrc/usbip_host_driver.c (100%)
 rename {drivers/staging/usbip/userspace = 
tools/usb/usbip}/libsrc/usbip_host_driver.h (100%)
 rename {drivers/staging/usbip/userspace = 
tools/usb/usbip}/libsrc/vhci_driver.c (100%)
 rename {drivers/staging/usbip/userspace = 
tools/usb/usbip}/libsrc/vhci_driver.h

Re: [PATCH 0/3] usbip: move usbip out of staging

2014-08-08 Thread Valentina Manea
On Thu, Aug 7, 2014 at 1:16 PM, Greg KH gre...@linuxfoundation.org wrote:

 The top of the MAINTAINERS should have this information, look in the S:
 Status section about what type of category you are in.

 Basically I'd like you to be the one to handle patches that are sent in
 for the code, just by reviewing them, you don't have to send them on to
 me if you don't want to (some usb subsystem maintainers do do this, like
 for usb-serial and xhci), it's up to you.

 Also, any bug reports or questions about the code would come to you
 first, along with the rest of the linux-usb@vger developers, you aren't
 alone in this at all.


Ok, this sounds good. I suppose sending you the patches involves
picking them up from the email, batching them and sending with
send-email.
Shuah, I would appreciate if you'd like to help with this. The more
eyes for review, the better.

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


Re: [PATCH 0/3] usbip: move usbip out of staging

2014-08-07 Thread Valentina Manea
On Wed, Aug 6, 2014 at 10:33 PM, Greg KH gre...@linuxfoundation.org wrote:
 On Thu, Aug 07, 2014 at 08:10:25AM +0300, Valentina Manea wrote:
 This is a resend of the patch series from March.

 After migrating userspace code to libudev, converting usbip-host
 to a device driver and various bug fixes and enhancements, USB/IP
 is fully functional and can be moved out of staging.

 This patch series moves it as following:
 * userspace code to tools/usb/usbip
 * kernel code to drivers/usb/usbip

 Besides this, a warning generated in the kernel code is solved.

 What kernel version is this against?


I rebased my tree against master in the staging tree.

 And can we get a maintainer for this code?  I don't want to see it sit
 ownerless in the kernel tree.  Will you be willing to do this?


Yes. But I should be briefed about that responsibilities will this involve.

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


[PATCH 3/3] usbip: remove struct usb_device_id table

2014-08-06 Thread Valentina Manea
This was used back when usbip-host was an interface device driver;
after the conversion to device driver, the table remained unused.
Remove it in order to stop receiving a warning about it.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/usb/usbip/stub_dev.c | 27 ---
 1 file changed, 27 deletions(-)

diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
index 51d0c71..fac20e0 100644
--- a/drivers/usb/usbip/stub_dev.c
+++ b/drivers/usb/usbip/stub_dev.c
@@ -26,33 +26,6 @@
 #include stub.h
 
 /*
- * Define device IDs here if you want to explicitly limit exportable devices.
- * In most cases, wildcard matching will be okay because driver binding can be
- * changed dynamically by a userland program.
- */
-static struct usb_device_id stub_table[] = {
-#if 0
-   /* just an example */
-   { USB_DEVICE(0x05ac, 0x0301) },   /* Mac 1 button mouse */
-   { USB_DEVICE(0x0430, 0x0009) },   /* Plat Home Keyboard */
-   { USB_DEVICE(0x059b, 0x0001) },   /* Iomega USB Zip 100 */
-   { USB_DEVICE(0x04b3, 0x4427) },   /* IBM USB CD-ROM */
-   { USB_DEVICE(0x05a9, 0xa511) },   /* LifeView USB cam */
-   { USB_DEVICE(0x55aa, 0x0201) },   /* Imation card reader */
-   { USB_DEVICE(0x046d, 0x0870) },   /* Qcam Express(QV-30) */
-   { USB_DEVICE(0x04bb, 0x0101) },   /* IO-DATA HD 120GB */
-   { USB_DEVICE(0x04bb, 0x0904) },   /* IO-DATA USB-ET/TX */
-   { USB_DEVICE(0x04bb, 0x0201) },   /* IO-DATA USB-ET/TX */
-   { USB_DEVICE(0x08bb, 0x2702) },   /* ONKYO USB Speaker */
-   { USB_DEVICE(0x046d, 0x08b2) },   /* Logicool Qcam 4000 Pro */
-#endif
-   /* magic for wild card */
-   { .driver_info = 1 },
-   { 0, } /* Terminating entry */
-};
-MODULE_DEVICE_TABLE(usb, stub_table);
-
-/*
  * usbip_status shows the status of usbip-host as long as this driver is bound
  * to the target device.
  */
-- 
1.8.1.2

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


[PATCH 1/3] usbip: move usbip userspace code out of staging

2014-08-06 Thread Valentina Manea
At this point, USB/IP userspace code is fully functional
and can be moved out of staging.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 {drivers/staging/usbip/userspace = tools/usb/usbip}/.gitignore   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/AUTHORS  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/COPYING  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/INSTALL  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/Makefile.am  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/README   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/autogen.sh   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/cleanup.sh   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/configure.ac | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/doc/usbip.8  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/doc/usbipd.8 | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/Makefile.am   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/list.h| 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/names.c   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/names.h   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/sysfs_utils.c | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/sysfs_utils.h | 0
 .../staging/usbip/userspace = tools/usb/usbip}/libsrc/usbip_common.c | 0
 .../staging/usbip/userspace = tools/usb/usbip}/libsrc/usbip_common.h | 0
 .../usbip/userspace = tools/usb/usbip}/libsrc/usbip_host_driver.c| 0
 .../usbip/userspace = tools/usb/usbip}/libsrc/usbip_host_driver.h| 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/vhci_driver.c | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/vhci_driver.h | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/Makefile.am  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip.c  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip.h  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip_attach.c   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip_bind.c | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip_detach.c   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip_list.c | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip_network.c  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip_network.h  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip_port.c | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbip_unbind.c   | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/usbipd.c | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/utils.c  | 0
 {drivers/staging/usbip/userspace = tools/usb/usbip}/src/utils.h  | 0
 37 files changed, 0 insertions(+), 0 deletions(-)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/.gitignore (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/AUTHORS (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/COPYING (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/INSTALL (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/Makefile.am (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/README (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/autogen.sh (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/cleanup.sh (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/configure.ac (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/doc/usbip.8 (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/doc/usbipd.8 (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/Makefile.am 
(100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/list.h 
(100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/names.c 
(100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/libsrc/names.h 
(100%)
 rename {drivers/staging/usbip/userspace = 
tools/usb/usbip}/libsrc/sysfs_utils.c (100%)
 rename {drivers/staging/usbip/userspace = 
tools/usb/usbip}/libsrc/sysfs_utils.h (100%)
 rename {drivers/staging/usbip/userspace = 
tools/usb/usbip}/libsrc/usbip_common.c (100%)
 rename {drivers/staging/usbip/userspace = 
tools/usb/usbip}/libsrc/usbip_common.h (100%)
 rename {drivers/staging/usbip/userspace = 
tools/usb/usbip}/libsrc/usbip_host_driver.c (100%)
 rename {drivers/staging/usbip/userspace = 
tools/usb/usbip}/libsrc/usbip_host_driver.h (100%)
 rename {drivers/staging/usbip/userspace = 
tools/usb/usbip}/libsrc/vhci_driver.c (100%)
 rename {drivers/staging/usbip/userspace = 
tools/usb/usbip}/libsrc/vhci_driver.h

[PATCH 0/3] usbip: move usbip out of staging

2014-08-06 Thread Valentina Manea
After migrating userspace code to libudev, converting usbip-host
to a device driver and various bug fixes and enhancements, USB/IP
is fully functional and can be moved out of staging.

This patch series moves it as following:
* userspace code to tools/usb/usbip
* kernel code to drivers/usb/usbip

Besides this, a warning generated in the kernel code is solved.

Valentina Manea (3):
  usbip: move usbip userspace code out of staging
  usbip: move usbip kernel code out of staging
  usbip: remove struct usb_device_id table

 drivers/staging/Kconfig|  2 --
 drivers/staging/Makefile   |  1 -
 drivers/{staging = usb}/usbip/Kconfig |  0
 drivers/{staging = usb}/usbip/Makefile|  0
 drivers/{staging = usb}/usbip/README  |  0
 drivers/{staging = usb}/usbip/stub.h  |  0
 drivers/{staging = usb}/usbip/stub_dev.c  | 27 --
 drivers/{staging = usb}/usbip/stub_main.c |  0
 drivers/{staging = usb}/usbip/stub_rx.c   |  0
 drivers/{staging = usb}/usbip/stub_tx.c   |  0
 drivers/{staging = usb}/usbip/usbip_common.c  |  0
 drivers/{staging = usb}/usbip/usbip_common.h  |  2 +-
 drivers/{staging = usb}/usbip/usbip_event.c   |  0
 drivers/{staging = usb}/usbip/usbip_protocol.txt  |  0
 drivers/{staging = usb}/usbip/vhci.h  |  0
 drivers/{staging = usb}/usbip/vhci_hcd.c  |  0
 drivers/{staging = usb}/usbip/vhci_rx.c   |  0
 drivers/{staging = usb}/usbip/vhci_sysfs.c|  0
 drivers/{staging = usb}/usbip/vhci_tx.c   |  0
 .../usbip/uapi = include/uapi/linux}/usbip.h  |  0
 .../usbip/userspace = tools/usb/usbip}/.gitignore |  0
 .../usbip/userspace = tools/usb/usbip}/AUTHORS|  0
 .../usbip/userspace = tools/usb/usbip}/COPYING|  0
 .../usbip/userspace = tools/usb/usbip}/INSTALL|  0
 .../userspace = tools/usb/usbip}/Makefile.am  |  0
 .../usbip/userspace = tools/usb/usbip}/README |  0
 .../usbip/userspace = tools/usb/usbip}/autogen.sh |  0
 .../usbip/userspace = tools/usb/usbip}/cleanup.sh |  0
 .../userspace = tools/usb/usbip}/configure.ac |  0
 .../userspace = tools/usb/usbip}/doc/usbip.8  |  0
 .../userspace = tools/usb/usbip}/doc/usbipd.8 |  0
 .../usb/usbip}/libsrc/Makefile.am  |  0
 .../userspace = tools/usb/usbip}/libsrc/list.h|  0
 .../userspace = tools/usb/usbip}/libsrc/names.c   |  0
 .../userspace = tools/usb/usbip}/libsrc/names.h   |  0
 .../usb/usbip}/libsrc/sysfs_utils.c|  0
 .../usb/usbip}/libsrc/sysfs_utils.h|  0
 .../usb/usbip}/libsrc/usbip_common.c   |  0
 .../usb/usbip}/libsrc/usbip_common.h   |  0
 .../usb/usbip}/libsrc/usbip_host_driver.c  |  0
 .../usb/usbip}/libsrc/usbip_host_driver.h  |  0
 .../usb/usbip}/libsrc/vhci_driver.c|  0
 .../usb/usbip}/libsrc/vhci_driver.h|  0
 .../userspace = tools/usb/usbip}/src/Makefile.am  |  0
 .../userspace = tools/usb/usbip}/src/usbip.c  |  0
 .../userspace = tools/usb/usbip}/src/usbip.h  |  0
 .../usb/usbip}/src/usbip_attach.c  |  0
 .../userspace = tools/usb/usbip}/src/usbip_bind.c |  0
 .../usb/usbip}/src/usbip_detach.c  |  0
 .../userspace = tools/usb/usbip}/src/usbip_list.c |  0
 .../usb/usbip}/src/usbip_network.c |  0
 .../usb/usbip}/src/usbip_network.h |  0
 .../userspace = tools/usb/usbip}/src/usbip_port.c |  0
 .../usb/usbip}/src/usbip_unbind.c  |  0
 .../userspace = tools/usb/usbip}/src/usbipd.c |  0
 .../userspace = tools/usb/usbip}/src/utils.c  |  0
 .../userspace = tools/usb/usbip}/src/utils.h  |  0
 57 files changed, 1 insertion(+), 31 deletions(-)
 rename drivers/{staging = usb}/usbip/Kconfig (100%)
 rename drivers/{staging = usb}/usbip/Makefile (100%)
 rename drivers/{staging = usb}/usbip/README (100%)
 rename drivers/{staging = usb}/usbip/stub.h (100%)
 rename drivers/{staging = usb}/usbip/stub_dev.c (90%)
 rename drivers/{staging = usb}/usbip/stub_main.c (100%)
 rename drivers/{staging = usb}/usbip/stub_rx.c (100%)
 rename drivers/{staging = usb}/usbip/stub_tx.c (100%)
 rename drivers/{staging = usb}/usbip/usbip_common.c (100%)
 rename drivers/{staging = usb}/usbip/usbip_common.h (99%)
 rename drivers/{staging = usb}/usbip/usbip_event.c (100%)
 rename drivers/{staging = usb}/usbip/usbip_protocol.txt (100%)
 rename drivers/{staging = usb}/usbip/vhci.h (100%)
 rename drivers/{staging = usb}/usbip/vhci_hcd.c (100%)
 rename drivers/{staging = usb}/usbip/vhci_rx.c (100%)
 rename drivers/{staging = usb}/usbip/vhci_sysfs.c (100%)
 rename drivers/{staging = usb}/usbip/vhci_tx.c (100%)
 rename {drivers/staging/usbip/uapi = include/uapi/linux}/usbip.h (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/.gitignore (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/AUTHORS (100

[PATCH 2/3] usbip: move usbip kernel code out of staging

2014-08-06 Thread Valentina Manea
At this point, USB/IP kernel code is fully functional
and can be moved out of staging.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/Kconfig| 2 --
 drivers/staging/Makefile   | 1 -
 drivers/{staging = usb}/usbip/Kconfig | 0
 drivers/{staging = usb}/usbip/Makefile| 0
 drivers/{staging = usb}/usbip/README  | 0
 drivers/{staging = usb}/usbip/stub.h  | 0
 drivers/{staging = usb}/usbip/stub_dev.c  | 0
 drivers/{staging = usb}/usbip/stub_main.c | 0
 drivers/{staging = usb}/usbip/stub_rx.c   | 0
 drivers/{staging = usb}/usbip/stub_tx.c   | 0
 drivers/{staging = usb}/usbip/usbip_common.c  | 0
 drivers/{staging = usb}/usbip/usbip_common.h  | 2 +-
 drivers/{staging = usb}/usbip/usbip_event.c   | 0
 drivers/{staging = usb}/usbip/usbip_protocol.txt  | 0
 drivers/{staging = usb}/usbip/vhci.h  | 0
 drivers/{staging = usb}/usbip/vhci_hcd.c  | 0
 drivers/{staging = usb}/usbip/vhci_rx.c   | 0
 drivers/{staging = usb}/usbip/vhci_sysfs.c| 0
 drivers/{staging = usb}/usbip/vhci_tx.c   | 0
 {drivers/staging/usbip/uapi = include/uapi/linux}/usbip.h | 0
 20 files changed, 1 insertion(+), 4 deletions(-)
 rename drivers/{staging = usb}/usbip/Kconfig (100%)
 rename drivers/{staging = usb}/usbip/Makefile (100%)
 rename drivers/{staging = usb}/usbip/README (100%)
 rename drivers/{staging = usb}/usbip/stub.h (100%)
 rename drivers/{staging = usb}/usbip/stub_dev.c (100%)
 rename drivers/{staging = usb}/usbip/stub_main.c (100%)
 rename drivers/{staging = usb}/usbip/stub_rx.c (100%)
 rename drivers/{staging = usb}/usbip/stub_tx.c (100%)
 rename drivers/{staging = usb}/usbip/usbip_common.c (100%)
 rename drivers/{staging = usb}/usbip/usbip_common.h (99%)
 rename drivers/{staging = usb}/usbip/usbip_event.c (100%)
 rename drivers/{staging = usb}/usbip/usbip_protocol.txt (100%)
 rename drivers/{staging = usb}/usbip/vhci.h (100%)
 rename drivers/{staging = usb}/usbip/vhci_hcd.c (100%)
 rename drivers/{staging = usb}/usbip/vhci_rx.c (100%)
 rename drivers/{staging = usb}/usbip/vhci_sysfs.c (100%)
 rename drivers/{staging = usb}/usbip/vhci_tx.c (100%)
 rename {drivers/staging/usbip/uapi = include/uapi/linux}/usbip.h (100%)

diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 2c486ea..35b494f 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -28,8 +28,6 @@ source drivers/staging/et131x/Kconfig
 
 source drivers/staging/slicoss/Kconfig
 
-source drivers/staging/usbip/Kconfig
-
 source drivers/staging/wlan-ng/Kconfig
 
 source drivers/staging/comedi/Kconfig
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 1e1a3a1..e66a5db 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -6,7 +6,6 @@ obj-$(CONFIG_STAGING)   += staging.o
 obj-y  += media/
 obj-$(CONFIG_ET131X)   += et131x/
 obj-$(CONFIG_SLICOSS)  += slicoss/
-obj-$(CONFIG_USBIP_CORE)   += usbip/
 obj-$(CONFIG_PRISM2_USB)   += wlan-ng/
 obj-$(CONFIG_COMEDI)   += comedi/
 obj-$(CONFIG_FB_OLPC_DCON) += olpc_dcon/
diff --git a/drivers/staging/usbip/Kconfig b/drivers/usb/usbip/Kconfig
similarity index 100%
rename from drivers/staging/usbip/Kconfig
rename to drivers/usb/usbip/Kconfig
diff --git a/drivers/staging/usbip/Makefile b/drivers/usb/usbip/Makefile
similarity index 100%
rename from drivers/staging/usbip/Makefile
rename to drivers/usb/usbip/Makefile
diff --git a/drivers/staging/usbip/README b/drivers/usb/usbip/README
similarity index 100%
rename from drivers/staging/usbip/README
rename to drivers/usb/usbip/README
diff --git a/drivers/staging/usbip/stub.h b/drivers/usb/usbip/stub.h
similarity index 100%
rename from drivers/staging/usbip/stub.h
rename to drivers/usb/usbip/stub.h
diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
similarity index 100%
rename from drivers/staging/usbip/stub_dev.c
rename to drivers/usb/usbip/stub_dev.c
diff --git a/drivers/staging/usbip/stub_main.c b/drivers/usb/usbip/stub_main.c
similarity index 100%
rename from drivers/staging/usbip/stub_main.c
rename to drivers/usb/usbip/stub_main.c
diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/usb/usbip/stub_rx.c
similarity index 100%
rename from drivers/staging/usbip/stub_rx.c
rename to drivers/usb/usbip/stub_rx.c
diff --git a/drivers/staging/usbip/stub_tx.c b/drivers/usb/usbip/stub_tx.c
similarity index 100%
rename from drivers/staging/usbip/stub_tx.c
rename to drivers/usb/usbip/stub_tx.c
diff --git a/drivers/staging/usbip/usbip_common.c 
b/drivers/usb/usbip/usbip_common.c
similarity index 100%
rename from drivers/staging/usbip/usbip_common.c
rename to drivers/usb/usbip

[PATCH 0/3] usbip: move usbip out of staging

2014-08-06 Thread Valentina Manea
This is a resend of the patch series from March.

After migrating userspace code to libudev, converting usbip-host
to a device driver and various bug fixes and enhancements, USB/IP
is fully functional and can be moved out of staging.

This patch series moves it as following:
* userspace code to tools/usb/usbip
* kernel code to drivers/usb/usbip

Besides this, a warning generated in the kernel code is solved.

Valentina Manea (3):
  usbip: move usbip userspace code out of staging
  usbip: move usbip kernel code out of staging
  usbip: remove struct usb_device_id table

 drivers/staging/Kconfig|  2 --
 drivers/staging/Makefile   |  1 -
 drivers/{staging = usb}/usbip/Kconfig |  0
 drivers/{staging = usb}/usbip/Makefile|  0
 drivers/{staging = usb}/usbip/README  |  0
 drivers/{staging = usb}/usbip/stub.h  |  0
 drivers/{staging = usb}/usbip/stub_dev.c  | 27 --
 drivers/{staging = usb}/usbip/stub_main.c |  0
 drivers/{staging = usb}/usbip/stub_rx.c   |  0
 drivers/{staging = usb}/usbip/stub_tx.c   |  0
 drivers/{staging = usb}/usbip/usbip_common.c  |  0
 drivers/{staging = usb}/usbip/usbip_common.h  |  2 +-
 drivers/{staging = usb}/usbip/usbip_event.c   |  0
 drivers/{staging = usb}/usbip/usbip_protocol.txt  |  0
 drivers/{staging = usb}/usbip/vhci.h  |  0
 drivers/{staging = usb}/usbip/vhci_hcd.c  |  0
 drivers/{staging = usb}/usbip/vhci_rx.c   |  0
 drivers/{staging = usb}/usbip/vhci_sysfs.c|  0
 drivers/{staging = usb}/usbip/vhci_tx.c   |  0
 .../usbip/uapi = include/uapi/linux}/usbip.h  |  0
 .../usbip/userspace = tools/usb/usbip}/.gitignore |  0
 .../usbip/userspace = tools/usb/usbip}/AUTHORS|  0
 .../usbip/userspace = tools/usb/usbip}/COPYING|  0
 .../usbip/userspace = tools/usb/usbip}/INSTALL|  0
 .../userspace = tools/usb/usbip}/Makefile.am  |  0
 .../usbip/userspace = tools/usb/usbip}/README |  0
 .../usbip/userspace = tools/usb/usbip}/autogen.sh |  0
 .../usbip/userspace = tools/usb/usbip}/cleanup.sh |  0
 .../userspace = tools/usb/usbip}/configure.ac |  0
 .../userspace = tools/usb/usbip}/doc/usbip.8  |  0
 .../userspace = tools/usb/usbip}/doc/usbipd.8 |  0
 .../usb/usbip}/libsrc/Makefile.am  |  0
 .../userspace = tools/usb/usbip}/libsrc/list.h|  0
 .../userspace = tools/usb/usbip}/libsrc/names.c   |  0
 .../userspace = tools/usb/usbip}/libsrc/names.h   |  0
 .../usb/usbip}/libsrc/sysfs_utils.c|  0
 .../usb/usbip}/libsrc/sysfs_utils.h|  0
 .../usb/usbip}/libsrc/usbip_common.c   |  0
 .../usb/usbip}/libsrc/usbip_common.h   |  0
 .../usb/usbip}/libsrc/usbip_host_driver.c  |  0
 .../usb/usbip}/libsrc/usbip_host_driver.h  |  0
 .../usb/usbip}/libsrc/vhci_driver.c|  0
 .../usb/usbip}/libsrc/vhci_driver.h|  0
 .../userspace = tools/usb/usbip}/src/Makefile.am  |  0
 .../userspace = tools/usb/usbip}/src/usbip.c  |  0
 .../userspace = tools/usb/usbip}/src/usbip.h  |  0
 .../usb/usbip}/src/usbip_attach.c  |  0
 .../userspace = tools/usb/usbip}/src/usbip_bind.c |  0
 .../usb/usbip}/src/usbip_detach.c  |  0
 .../userspace = tools/usb/usbip}/src/usbip_list.c |  0
 .../usb/usbip}/src/usbip_network.c |  0
 .../usb/usbip}/src/usbip_network.h |  0
 .../userspace = tools/usb/usbip}/src/usbip_port.c |  0
 .../usb/usbip}/src/usbip_unbind.c  |  0
 .../userspace = tools/usb/usbip}/src/usbipd.c |  0
 .../userspace = tools/usb/usbip}/src/utils.c  |  0
 .../userspace = tools/usb/usbip}/src/utils.h  |  0
 57 files changed, 1 insertion(+), 31 deletions(-)
 rename drivers/{staging = usb}/usbip/Kconfig (100%)
 rename drivers/{staging = usb}/usbip/Makefile (100%)
 rename drivers/{staging = usb}/usbip/README (100%)
 rename drivers/{staging = usb}/usbip/stub.h (100%)
 rename drivers/{staging = usb}/usbip/stub_dev.c (90%)
 rename drivers/{staging = usb}/usbip/stub_main.c (100%)
 rename drivers/{staging = usb}/usbip/stub_rx.c (100%)
 rename drivers/{staging = usb}/usbip/stub_tx.c (100%)
 rename drivers/{staging = usb}/usbip/usbip_common.c (100%)
 rename drivers/{staging = usb}/usbip/usbip_common.h (99%)
 rename drivers/{staging = usb}/usbip/usbip_event.c (100%)
 rename drivers/{staging = usb}/usbip/usbip_protocol.txt (100%)
 rename drivers/{staging = usb}/usbip/vhci.h (100%)
 rename drivers/{staging = usb}/usbip/vhci_hcd.c (100%)
 rename drivers/{staging = usb}/usbip/vhci_rx.c (100%)
 rename drivers/{staging = usb}/usbip/vhci_sysfs.c (100%)
 rename drivers/{staging = usb}/usbip/vhci_tx.c (100%)
 rename {drivers/staging/usbip/uapi = include/uapi/linux}/usbip.h (100%)
 rename {drivers/staging/usbip/userspace = tools/usb/usbip}/.gitignore (100%)
 rename {drivers/staging/usbip

[PATCH 0/3] usbip: move usbip out of staging

2014-03-18 Thread Valentina Manea
After migrating userspace code to libudev, converting usbip-host
to a device driver and various bug fixes and enhancements, USB/IP
is fully functional and can be moved out of staging.

This patch series moves it as following:
* userspace code to tools/usb/usbip
* kernel code to drivers/usb/usbip

Besides this, a warning generated in the kernel code is solved.

Valentina Manea (3):
  usbip: move usbip userspace code out of staging
  usbip: move usbip kernel code out of staging
  usbip: remove struct usb_device_id table

 drivers/staging/Kconfig|2 -
 drivers/staging/Makefile   |1 -
 drivers/staging/usbip/Kconfig  |   45 -
 drivers/staging/usbip/Makefile |   10 -
 drivers/staging/usbip/README   |7 -
 drivers/staging/usbip/stub.h   |  113 --
 drivers/staging/usbip/stub_dev.c   |  524 -
 drivers/staging/usbip/stub_main.c  |  339 --
 drivers/staging/usbip/stub_rx.c|  595 --
 drivers/staging/usbip/stub_tx.c|  397 ---
 drivers/staging/usbip/uapi/usbip.h |   26 -
 drivers/staging/usbip/usbip_common.c   |  803 --
 drivers/staging/usbip/usbip_common.h   |  334 --
 drivers/staging/usbip/usbip_event.c|  128 ---
 drivers/staging/usbip/usbip_protocol.txt   |  358 --
 drivers/staging/usbip/userspace/.gitignore |   28 -
 drivers/staging/usbip/userspace/AUTHORS|3 -
 drivers/staging/usbip/userspace/COPYING|  340 --
 drivers/staging/usbip/userspace/INSTALL|  237 
 drivers/staging/usbip/userspace/Makefile.am|6 -
 drivers/staging/usbip/userspace/README |  203 
 drivers/staging/usbip/userspace/autogen.sh |9 -
 drivers/staging/usbip/userspace/cleanup.sh |   12 -
 drivers/staging/usbip/userspace/configure.ac   |  111 --
 drivers/staging/usbip/userspace/doc/usbip.8|   95 --
 drivers/staging/usbip/userspace/doc/usbipd.8   |   91 --
 drivers/staging/usbip/userspace/libsrc/Makefile.am |8 -
 drivers/staging/usbip/userspace/libsrc/list.h  |  136 ---
 drivers/staging/usbip/userspace/libsrc/names.c |  504 -
 drivers/staging/usbip/userspace/libsrc/names.h |   41 -
 .../staging/usbip/userspace/libsrc/sysfs_utils.c   |   31 -
 .../staging/usbip/userspace/libsrc/sysfs_utils.h   |8 -
 .../staging/usbip/userspace/libsrc/usbip_common.c  |  285 -
 .../staging/usbip/userspace/libsrc/usbip_common.h  |  137 ---
 .../usbip/userspace/libsrc/usbip_host_driver.c |  276 -
 .../usbip/userspace/libsrc/usbip_host_driver.h |   49 -
 .../staging/usbip/userspace/libsrc/vhci_driver.c   |  411 ---
 .../staging/usbip/userspace/libsrc/vhci_driver.h   |   59 -
 drivers/staging/usbip/userspace/src/Makefile.am|   11 -
 drivers/staging/usbip/userspace/src/usbip.c|  201 
 drivers/staging/usbip/userspace/src/usbip.h|   40 -
 drivers/staging/usbip/userspace/src/usbip_attach.c |  240 
 drivers/staging/usbip/userspace/src/usbip_bind.c   |  214 
 drivers/staging/usbip/userspace/src/usbip_detach.c |  110 --
 drivers/staging/usbip/userspace/src/usbip_list.c   |  283 -
 .../staging/usbip/userspace/src/usbip_network.c|  303 -
 .../staging/usbip/userspace/src/usbip_network.h|  185 
 drivers/staging/usbip/userspace/src/usbip_port.c   |   57 -
 drivers/staging/usbip/userspace/src/usbip_unbind.c |  141 ---
 drivers/staging/usbip/userspace/src/usbipd.c   |  675 ---
 drivers/staging/usbip/userspace/src/utils.c|   52 -
 drivers/staging/usbip/userspace/src/utils.h|   25 -
 drivers/staging/usbip/vhci.h   |  129 ---
 drivers/staging/usbip/vhci_hcd.c   | 1168 
 drivers/staging/usbip/vhci_rx.c|  270 -
 drivers/staging/usbip/vhci_sysfs.c |  252 -
 drivers/staging/usbip/vhci_tx.c|  224 
 drivers/usb/Kconfig|2 +
 drivers/usb/Makefile   |2 +
 drivers/usb/usbip/Kconfig  |   45 +
 drivers/usb/usbip/Makefile |   10 +
 drivers/usb/usbip/README   |7 +
 drivers/usb/usbip/stub.h   |  113 ++
 drivers/usb/usbip/stub_dev.c   |  497 +
 drivers/usb/usbip/stub_main.c  |  339 ++
 drivers/usb/usbip/stub_rx.c|  595 ++
 drivers/usb/usbip/stub_tx.c|  397 +++
 drivers/usb/usbip/usbip_common.c   |  803 ++
 drivers/usb/usbip/usbip_common.h   |  334 ++
 drivers/usb/usbip/usbip_event.c|  128

[PATCH 3/3] usbip: remove struct usb_device_id table

2014-03-18 Thread Valentina Manea
This was used back when usbip-host was an interface device driver;
after the conversion to device driver, the table remained unused.
Remove it in order to stop receiving a warning about it.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/usb/usbip/stub_dev.c | 27 ---
 1 file changed, 27 deletions(-)

diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
index 773d8ca..ca01f67 100644
--- a/drivers/usb/usbip/stub_dev.c
+++ b/drivers/usb/usbip/stub_dev.c
@@ -26,33 +26,6 @@
 #include stub.h
 
 /*
- * Define device IDs here if you want to explicitly limit exportable devices.
- * In most cases, wildcard matching will be okay because driver binding can be
- * changed dynamically by a userland program.
- */
-static struct usb_device_id stub_table[] = {
-#if 0
-   /* just an example */
-   { USB_DEVICE(0x05ac, 0x0301) },   /* Mac 1 button mouse */
-   { USB_DEVICE(0x0430, 0x0009) },   /* Plat Home Keyboard */
-   { USB_DEVICE(0x059b, 0x0001) },   /* Iomega USB Zip 100 */
-   { USB_DEVICE(0x04b3, 0x4427) },   /* IBM USB CD-ROM */
-   { USB_DEVICE(0x05a9, 0xa511) },   /* LifeView USB cam */
-   { USB_DEVICE(0x55aa, 0x0201) },   /* Imation card reader */
-   { USB_DEVICE(0x046d, 0x0870) },   /* Qcam Express(QV-30) */
-   { USB_DEVICE(0x04bb, 0x0101) },   /* IO-DATA HD 120GB */
-   { USB_DEVICE(0x04bb, 0x0904) },   /* IO-DATA USB-ET/TX */
-   { USB_DEVICE(0x04bb, 0x0201) },   /* IO-DATA USB-ET/TX */
-   { USB_DEVICE(0x08bb, 0x2702) },   /* ONKYO USB Speaker */
-   { USB_DEVICE(0x046d, 0x08b2) },   /* Logicool Qcam 4000 Pro */
-#endif
-   /* magic for wild card */
-   { .driver_info = 1 },
-   { 0, } /* Terminating entry */
-};
-MODULE_DEVICE_TABLE(usb, stub_table);
-
-/*
  * usbip_status shows the status of usbip-host as long as this driver is bound
  * to the target device.
  */
-- 
1.8.1.2

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


[PATCH 0/2] Rename struct dev_state to struct usb_dev_state

2014-03-10 Thread Valentina Manea
Since it is needed outside usbcore and exposed in include/linux/usb.h,
it conflicts with enum dev_state in rt2x00 wireless driver and breaks
the build.

Mark it as usb specific to avoid conflicts in the future and update
USB/IP to use the new name.

Valentina Manea (2):
  usbcore: rename struct dev_state to struct usb_dev_state
  staging: usbip: rename struct dev_state to usb_dev_state

 drivers/staging/usbip/stub_dev.c |   4 +-
 drivers/usb/core/devio.c | 112 +++
 drivers/usb/core/hub.c   |  12 ++---
 drivers/usb/core/hub.h   |   2 +-
 drivers/usb/core/usb.h   |   4 +-
 include/linux/usb.h  |   6 +--
 6 files changed, 70 insertions(+), 70 deletions(-)

-- 
1.8.1.2

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


[PATCH 1/2] usbcore: rename struct dev_state to struct usb_dev_state

2014-03-10 Thread Valentina Manea
Since it is needed outside usbcore and exposed in include/linux/usb.h,
it conflicts with enum dev_state in rt2x00 wireless driver.

Mark it as usb specific to avoid conflicts in the future.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/usb/core/devio.c | 112 +++
 drivers/usb/core/hub.c   |  12 ++---
 drivers/usb/core/hub.h   |   2 +-
 drivers/usb/core/usb.h   |   4 +-
 include/linux/usb.h  |   6 +--
 5 files changed, 68 insertions(+), 68 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 90e18f6..2a8afe6 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -62,7 +62,7 @@
 /* Mutual exclusion for removal, open, and release */
 DEFINE_MUTEX(usbfs_mutex);
 
-struct dev_state {
+struct usb_dev_state {
struct list_head list;  /* state list */
struct usb_device *dev;
struct file *file;
@@ -81,7 +81,7 @@ struct dev_state {
 
 struct async {
struct list_head asynclist;
-   struct dev_state *ps;
+   struct usb_dev_state *ps;
struct pid *pid;
const struct cred *cred;
unsigned int signr;
@@ -151,7 +151,7 @@ static void usbfs_decrease_memory_usage(unsigned amount)
atomic_sub(amount, usbfs_memory_usage);
 }
 
-static int connected(struct dev_state *ps)
+static int connected(struct usb_dev_state *ps)
 {
return (!list_empty(ps-list) 
ps-dev-state != USB_STATE_NOTATTACHED);
@@ -184,7 +184,7 @@ static loff_t usbdev_lseek(struct file *file, loff_t 
offset, int orig)
 static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
   loff_t *ppos)
 {
-   struct dev_state *ps = file-private_data;
+   struct usb_dev_state *ps = file-private_data;
struct usb_device *dev = ps-dev;
ssize_t ret = 0;
unsigned len;
@@ -307,7 +307,7 @@ static void free_async(struct async *as)
 
 static void async_newpending(struct async *as)
 {
-   struct dev_state *ps = as-ps;
+   struct usb_dev_state *ps = as-ps;
unsigned long flags;
 
spin_lock_irqsave(ps-lock, flags);
@@ -317,7 +317,7 @@ static void async_newpending(struct async *as)
 
 static void async_removepending(struct async *as)
 {
-   struct dev_state *ps = as-ps;
+   struct usb_dev_state *ps = as-ps;
unsigned long flags;
 
spin_lock_irqsave(ps-lock, flags);
@@ -325,7 +325,7 @@ static void async_removepending(struct async *as)
spin_unlock_irqrestore(ps-lock, flags);
 }
 
-static struct async *async_getcompleted(struct dev_state *ps)
+static struct async *async_getcompleted(struct usb_dev_state *ps)
 {
unsigned long flags;
struct async *as = NULL;
@@ -340,7 +340,7 @@ static struct async *async_getcompleted(struct dev_state 
*ps)
return as;
 }
 
-static struct async *async_getpending(struct dev_state *ps,
+static struct async *async_getpending(struct usb_dev_state *ps,
 void __user *userurb)
 {
struct async *as;
@@ -448,7 +448,7 @@ static int copy_urb_data_to_user(u8 __user *userbuffer, 
struct urb *urb)
 #define AS_CONTINUATION1
 #define AS_UNLINK  2
 
-static void cancel_bulk_urbs(struct dev_state *ps, unsigned bulk_addr)
+static void cancel_bulk_urbs(struct usb_dev_state *ps, unsigned bulk_addr)
 __releases(ps-lock)
 __acquires(ps-lock)
 {
@@ -489,7 +489,7 @@ __acquires(ps-lock)
 static void async_completed(struct urb *urb)
 {
struct async *as = urb-context;
-   struct dev_state *ps = as-ps;
+   struct usb_dev_state *ps = as-ps;
struct siginfo sinfo;
struct pid *pid = NULL;
u32 secid = 0;
@@ -529,7 +529,7 @@ static void async_completed(struct urb *urb)
wake_up(ps-wait);
 }
 
-static void destroy_async(struct dev_state *ps, struct list_head *list)
+static void destroy_async(struct usb_dev_state *ps, struct list_head *list)
 {
struct urb *urb;
struct async *as;
@@ -551,7 +551,7 @@ static void destroy_async(struct dev_state *ps, struct 
list_head *list)
spin_unlock_irqrestore(ps-lock, flags);
 }
 
-static void destroy_async_on_interface(struct dev_state *ps,
+static void destroy_async_on_interface(struct usb_dev_state *ps,
   unsigned int ifnum)
 {
struct list_head *p, *q, hitlist;
@@ -566,7 +566,7 @@ static void destroy_async_on_interface(struct dev_state *ps,
destroy_async(ps, hitlist);
 }
 
-static void destroy_all_async(struct dev_state *ps)
+static void destroy_all_async(struct usb_dev_state *ps)
 {
destroy_async(ps, ps-async_pending);
 }
@@ -585,7 +585,7 @@ static int driver_probe(struct usb_interface *intf,
 
 static void driver_disconnect(struct usb_interface *intf)
 {
-   struct dev_state *ps = usb_get_intfdata(intf);
+   struct usb_dev_state *ps = usb_get_intfdata(intf);
unsigned int ifnum

[PATCH 2/2] staging: usbip: rename struct dev_state to usb_dev_state

2014-03-10 Thread Valentina Manea
struct dev_state definition in usbcore conflicted with
enum dev_state definition in rt2x00 driver so it was
renamed to usb_dev_state.

Update usbip for this change.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/stub_dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index 952743c..773d8ca 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -395,7 +395,7 @@ static int stub_probe(struct usb_device *udev)
 * (struct dev_state) as long as it is unique.
 */
rc = usb_hub_claim_port(udev-parent, udev-portnum,
-   (struct dev_state *) udev);
+   (struct usb_dev_state *) udev);
if (rc) {
dev_dbg(udev-dev, unable to claim port\n);
return rc;
@@ -464,7 +464,7 @@ static void stub_disconnect(struct usb_device *udev)
 
/* release port */
rc = usb_hub_release_port(udev-parent, udev-portnum,
- (struct dev_state *) udev);
+ (struct usb_dev_state *) udev);
if (rc) {
dev_dbg(udev-dev, unable to release port\n);
return;
-- 
1.8.1.2

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


Re: [PATCH 00/18] Resend of usbip-utils migration patches and various other fixes

2014-03-09 Thread Valentina Manea
I was notified that one of the patches in the series (staging: usbip:
claim ports used by shared devices) breaks the build.
I take full responsability for this as I haven't compiled the kernel
with allyesconfig and I am sorry.

This can be fixed by moving struct dev_state, usb_hub_claim_port() and
usb_hub_release_port() declarations from include/linux/usb.h to
usbip/stub.h, and leaving the declarations in usb/core/usb.h
untouched.

Should the fix come as a separate patch or v2 of the broken one?

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


[PATCH 13/18] staging: usbip: userspace: increase version to 2.0

2014-03-08 Thread Valentina Manea
Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/usbip/userspace/configure.ac 
b/drivers/staging/usbip/userspace/configure.ac
index 25bf160..607d05c 100644
--- a/drivers/staging/usbip/userspace/configure.ac
+++ b/drivers/staging/usbip/userspace/configure.ac
@@ -1,7 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.59)
-AC_INIT([usbip-utils], [1.1.1], [linux-usb@vger.kernel.org])
+AC_INIT([usbip-utils], [2.0], [linux-usb@vger.kernel.org])
 AC_DEFINE([USBIP_VERSION], [0x0111], [binary-coded decimal version number])
 
 CURRENT=0
-- 
1.8.1.2

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


[PATCH 18/18] staging: usbip: userspace: add hwdata as optional dependency in README

2014-03-08 Thread Valentina Manea
This is an optional dependency since USB/IP can fully work without
it. However, it is needed to display device information such as
vendor.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/README | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/usbip/userspace/README 
b/drivers/staging/usbip/userspace/README
index 6ead290..f528ba4 100644
--- a/drivers/staging/usbip/userspace/README
+++ b/drivers/staging/usbip/userspace/README
@@ -19,6 +19,10 @@
 
 - libtool, automake = 1.9, autoconf = 2.5.0, pkg-config
 
+[Optional]
+- hwdata
+Contains USB device identification data.
+
 
 [Install]
 0. Generate configuration scripts.
-- 
1.8.1.2

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


[PATCH 15/18] staging: usbip: trigger driver probing after unbinding from usbip-host

2014-03-08 Thread Valentina Manea
A sysfs attribute is used to announce kernel space that a
new driver probing session should be triggered for the just
unbinded device.

In order to have the address of struct device associated to this
USB device, a new member has been added to struct bus_id_priv.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/stub.h   |  1 +
 drivers/staging/usbip/stub_dev.c   |  1 +
 drivers/staging/usbip/stub_main.c  | 39 ++
 drivers/staging/usbip/userspace/src/usbip_unbind.c | 17 --
 4 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/usbip/stub.h b/drivers/staging/usbip/stub.h
index 82e539a..266e2b0 100644
--- a/drivers/staging/usbip/stub.h
+++ b/drivers/staging/usbip/stub.h
@@ -86,6 +86,7 @@ struct bus_id_priv {
char status;
int interf_count;
struct stub_device *sdev;
+   struct usb_device *udev;
char shutdown_busid;
 };
 
diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index 1bd13cf..ee899f0 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -386,6 +386,7 @@ static int stub_probe(struct usb_device *udev)
/* set private data to usb_device */
dev_set_drvdata(udev-dev, sdev);
busid_priv-sdev = sdev;
+   busid_priv-udev = udev;
 
err = stub_add_files(udev-dev);
if (err) {
diff --git a/drivers/staging/usbip/stub_main.c 
b/drivers/staging/usbip/stub_main.c
index bd7b83a..9c5832a 100644
--- a/drivers/staging/usbip/stub_main.c
+++ b/drivers/staging/usbip/stub_main.c
@@ -19,6 +19,7 @@
 
 #include linux/string.h
 #include linux/module.h
+#include linux/device.h
 
 #include usbip_common.h
 #include stub.h
@@ -187,6 +188,34 @@ static ssize_t store_match_busid(struct device_driver 
*dev, const char *buf,
 static DRIVER_ATTR(match_busid, S_IRUSR | S_IWUSR, show_match_busid,
   store_match_busid);
 
+static ssize_t rebind_store(struct device_driver *dev, const char *buf,
+size_t count)
+{
+   int ret;
+   int len;
+   struct bus_id_priv *bid;
+
+   /* buf length should be less that BUSID_SIZE */
+   len = strnlen(buf, BUSID_SIZE);
+
+   if (!(len  BUSID_SIZE))
+   return -EINVAL;
+
+   bid = get_busid_priv(buf);
+   if (!bid)
+   return -ENODEV;
+
+   ret = device_attach(bid-udev-dev);
+   if (ret  0) {
+   dev_err(bid-udev-dev, rebind failed\n);
+   return ret;
+   }
+
+   return count;
+}
+
+static DRIVER_ATTR_WO(rebind);
+
 static struct stub_priv *stub_priv_pop_from_listhead(struct list_head 
*listhead)
 {
struct stub_priv *priv, *tmp;
@@ -267,6 +296,13 @@ static int __init usbip_host_init(void)
goto err_create_file;
}
 
+   ret = driver_create_file(stub_driver.drvwrap.driver,
+driver_attr_rebind);
+   if (ret) {
+   pr_err(driver_create_file failed\n);
+   goto err_create_file;
+   }
+
pr_info(DRIVER_DESC  v USBIP_VERSION \n);
return ret;
 
@@ -282,6 +318,9 @@ static void __exit usbip_host_exit(void)
driver_remove_file(stub_driver.drvwrap.driver,
   driver_attr_match_busid);
 
+   driver_remove_file(stub_driver.drvwrap.driver,
+  driver_attr_rebind);
+
/*
 * deregister() calls stub_disconnect() for all devices. Device
 * specific data is cleared in stub_disconnect().
diff --git a/drivers/staging/usbip/userspace/src/usbip_unbind.c 
b/drivers/staging/usbip/userspace/src/usbip_unbind.c
index 7180dbe..a4a496c 100644
--- a/drivers/staging/usbip/userspace/src/usbip_unbind.c
+++ b/drivers/staging/usbip/userspace/src/usbip_unbind.c
@@ -44,8 +44,10 @@ static int unbind_device(char *busid)
char bus_type[] = usb;
int rc, ret = -1;
 
-   char attr_name[] = unbind;
+   char unbind_attr_name[] = unbind;
char unbind_attr_path[SYSFS_PATH_MAX];
+   char rebind_attr_name[] = rebind;
+   char rebind_attr_path[SYSFS_PATH_MAX];
 
struct udev *udev;
struct udev_device *dev;
@@ -71,7 +73,7 @@ static int unbind_device(char *busid)
/* Unbind device from driver. */
snprintf(unbind_attr_path, sizeof(unbind_attr_path), 
%s/%s/%s/%s/%s/%s,
 SYSFS_MNT_PATH, SYSFS_BUS_NAME, bus_type, SYSFS_DRIVERS_NAME,
-USBIP_HOST_DRV_NAME, attr_name);
+USBIP_HOST_DRV_NAME, unbind_attr_name);
 
rc = write_sysfs_attribute(unbind_attr_path, busid, strlen(busid));
if (rc  0) {
@@ -86,6 +88,17 @@ static int unbind_device(char *busid)
goto err_close_udev;
}
 
+   /* Trigger new probing. */
+   snprintf(rebind_attr_path, sizeof(unbind_attr_path), 
%s/%s/%s/%s/%s/%s

[PATCH 17/18] staging: usbip: userspace: don't throw error when trying to read configuration specific attributes

2014-03-08 Thread Valentina Manea
When a device has just been bound to usbip-host but the client hasn't
set a configuration on it, certain attributes will not exist. Don't
treat this as an error.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/libsrc/usbip_common.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.c 
b/drivers/staging/usbip/userspace/libsrc/usbip_common.c
index 998c11c..238bf5b 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.c
+++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.c
@@ -127,10 +127,23 @@ int read_attr_value(struct udev_device *dev, const char 
*name,
goto err;
}
 
+   /* The client chooses the device configuration
+* when attaching it so right after being bound
+* to usbip-host on the server the device will
+* have no configuration.
+* Therefore, attributes such as bConfigurationValue
+* and bNumInterfaces will not exist and sscanf will
+* fail. Check for these cases and don't treat them
+* as errors.
+*/
+
ret = sscanf(attr, format, num);
if (ret  1) {
-   err(sscanf failed);
-   goto err;
+   if (strcmp(name, bConfigurationValue) 
+   strcmp(name, bNumInterfaces)) {
+   err(sscanf failed for attribute %s, name);
+   goto err;
+   }
}
 
 err:
-- 
1.8.1.2

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


[PATCH 16/18] staging: usbip: claim ports used by shared devices

2014-03-08 Thread Valentina Manea
A device should not be able to be used concurrently both by
the server and the client. Claiming the port used by the
shared device ensures no interface drivers bind to it and
that it is not usable from the server.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 drivers/staging/usbip/stub_dev.c | 22 ++
 drivers/usb/core/hub.c   |  2 ++
 drivers/usb/core/usb.h   |  4 
 include/linux/usb.h  |  7 +++
 4 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index ee899f0..952743c 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -339,6 +339,7 @@ static int stub_probe(struct usb_device *udev)
const char *udev_busid = dev_name(udev-dev);
int err = 0;
struct bus_id_priv *busid_priv;
+   int rc;
 
dev_dbg(udev-dev, Enter\n);
 
@@ -388,6 +389,18 @@ static int stub_probe(struct usb_device *udev)
busid_priv-sdev = sdev;
busid_priv-udev = udev;
 
+   /*
+* Claim this hub port.
+* It doesn't matter what value we pass as owner
+* (struct dev_state) as long as it is unique.
+*/
+   rc = usb_hub_claim_port(udev-parent, udev-portnum,
+   (struct dev_state *) udev);
+   if (rc) {
+   dev_dbg(udev-dev, unable to claim port\n);
+   return rc;
+   }
+
err = stub_add_files(udev-dev);
if (err) {
dev_err(udev-dev, stub_add_files for %s\n, udev_busid);
@@ -424,6 +437,7 @@ static void stub_disconnect(struct usb_device *udev)
struct stub_device *sdev;
const char *udev_busid = dev_name(udev-dev);
struct bus_id_priv *busid_priv;
+   int rc;
 
dev_dbg(udev-dev, Enter\n);
 
@@ -448,6 +462,14 @@ static void stub_disconnect(struct usb_device *udev)
 */
stub_remove_files(udev-dev);
 
+   /* release port */
+   rc = usb_hub_release_port(udev-parent, udev-portnum,
+ (struct dev_state *) udev);
+   if (rc) {
+   dev_dbg(udev-dev, unable to release port\n);
+   return;
+   }
+
/* If usb reset is called from event handler */
if (busid_priv-sdev-ud.eh == current)
return;
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 64ea219..e484933 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1819,6 +1819,7 @@ int usb_hub_claim_port(struct usb_device *hdev, unsigned 
port1,
*powner = owner;
return rc;
 }
+EXPORT_SYMBOL_GPL(usb_hub_claim_port);
 
 int usb_hub_release_port(struct usb_device *hdev, unsigned port1,
 struct dev_state *owner)
@@ -1834,6 +1835,7 @@ int usb_hub_release_port(struct usb_device *hdev, 
unsigned port1,
*powner = NULL;
return rc;
 }
+EXPORT_SYMBOL_GPL(usb_hub_release_port);
 
 void usb_hub_release_all_ports(struct usb_device *hdev, struct dev_state 
*owner)
 {
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 8238577..222bbd2 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -57,10 +57,6 @@ extern int usb_match_device(struct usb_device *dev,
 extern void usb_forced_unbind_intf(struct usb_interface *intf);
 extern void usb_rebind_intf(struct usb_interface *intf);
 
-extern int usb_hub_claim_port(struct usb_device *hdev, unsigned port,
-   struct dev_state *owner);
-extern int usb_hub_release_port(struct usb_device *hdev, unsigned port,
-   struct dev_state *owner);
 extern void usb_hub_release_all_ports(struct usb_device *hdev,
struct dev_state *owner);
 extern bool usb_device_is_owned(struct usb_device *udev);
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 22de4af..140a6a3 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -366,6 +366,8 @@ struct usb_bus {
 #endif
 };
 
+struct dev_state;
+
 /* --- */
 
 struct usb_tt;
@@ -749,6 +751,11 @@ extern struct usb_host_interface *usb_find_alt_setting(
unsigned int iface_num,
unsigned int alt_num);
 
+/* port claiming functions */
+int usb_hub_claim_port(struct usb_device *hdev, unsigned port1,
+   struct dev_state *owner);
+int usb_hub_release_port(struct usb_device *hdev, unsigned port1,
+   struct dev_state *owner);
 
 /**
  * usb_make_path - returns stable device path in the usb tree
-- 
1.8.1.2

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


[PATCH 14/18] staging: usbip: let client choose device configuration

2014-03-08 Thread Valentina Manea
Since usbip-host is now a device driver and the client
has full access to the shared device, it makes sense to
let the client choose device configuration.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/stub_dev.c | 10 +-
 drivers/staging/usbip/stub_rx.c  | 26 +++---
 2 files changed, 8 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index 60a3e3f..1bd13cf 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -337,7 +337,7 @@ static int stub_probe(struct usb_device *udev)
 {
struct stub_device *sdev = NULL;
const char *udev_busid = dev_name(udev-dev);
-   int err = 0, config;
+   int err = 0;
struct bus_id_priv *busid_priv;
 
dev_dbg(udev-dev, Enter\n);
@@ -383,14 +383,6 @@ static int stub_probe(struct usb_device *udev)
 
busid_priv-shutdown_busid = 0;
 
-   config = usb_choose_configuration(udev);
-   if (config = 0) {
-   err = usb_set_configuration(udev, config);
-   if (err  err != -ENODEV)
-   dev_err(udev-dev, can't set config #%d, error %d\n,
-   config, err);
-   }
-
/* set private data to usb_device */
dev_set_drvdata(udev-dev, sdev);
busid_priv-sdev = sdev;
diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/staging/usbip/stub_rx.c
index 76e44d9..e0b6d6b 100644
--- a/drivers/staging/usbip/stub_rx.c
+++ b/drivers/staging/usbip/stub_rx.c
@@ -142,31 +142,19 @@ static int tweak_set_interface_cmd(struct urb *urb)
 
 static int tweak_set_configuration_cmd(struct urb *urb)
 {
+   struct stub_priv *priv = (struct stub_priv *) urb-context;
+   struct stub_device *sdev = priv-sdev;
struct usb_ctrlrequest *req;
__u16 config;
+   int err;
 
req = (struct usb_ctrlrequest *) urb-setup_packet;
config = le16_to_cpu(req-wValue);
 
-   /*
-* I have never seen a multi-config device. Very rare.
-* For most devices, this will be called to choose a default
-* configuration only once in an initialization phase.
-*
-* set_configuration may change a device configuration and its device
-* drivers will be unbound and assigned for a new device configuration.
-* This means this usbip driver will be also unbound when called, then
-* eventually reassigned to the device as far as driver matching
-* condition is kept.
-*
-* Unfortunately, an existing usbip connection will be dropped
-* due to this driver unbinding. So, skip here.
-* A user may need to set a special configuration value before
-* exporting the device.
-*/
-   dev_info(urb-dev-dev, usb_set_configuration %d to %s... skip!\n,
-config, dev_name(urb-dev-dev));
-
+   err = usb_set_configuration(sdev-udev, config);
+   if (err  err != -ENODEV)
+   dev_err(sdev-udev-dev, can't set config #%d, error %d\n,
+   config, err);
return 0;
 }
 
-- 
1.8.1.2

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


[PATCH 12/18] staging: usbip: userspace: update dependencies in README

2014-03-08 Thread Valentina Manea
Add libudev as dependency and remove libsysfs.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/README | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/usbip/userspace/README 
b/drivers/staging/usbip/userspace/README
index 00a1658..6ead290 100644
--- a/drivers/staging/usbip/userspace/README
+++ b/drivers/staging/usbip/userspace/README
@@ -9,8 +9,8 @@
 - USB/IP device drivers
Found in the staging directory of the Linux kernel.
 
-- sysfsutils = 2.0.0
-   sysfsutils library
+- libudev = 2.0
+   libudev library
 
 - libwrap0-dev
tcp wrapper library
-- 
1.8.1.2

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


[PATCH 11/18] staging: usbip: userspace: remove libsysfs flag and autoconf check

2014-03-08 Thread Valentina Manea
libsysfs is now completely removed from USB/IP.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/configure.ac | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/usbip/userspace/configure.ac 
b/drivers/staging/usbip/userspace/configure.ac
index a5193c6..25bf160 100644
--- a/drivers/staging/usbip/userspace/configure.ac
+++ b/drivers/staging/usbip/userspace/configure.ac
@@ -44,12 +44,6 @@ AC_FUNC_REALLOC
 AC_CHECK_FUNCS([memset mkdir regcomp socket strchr strerror strstr dnl
strtoul])
 
-AC_CHECK_HEADER([sysfs/libsysfs.h],
-   [AC_CHECK_LIB([sysfs], [sysfs_open_directory_list],
- [LIBS=$LIBS -lsysfs],
- [AC_MSG_ERROR([Missing sysfs2 library!])])],
-   [AC_MSG_ERROR([Missing /usr/include/sysfs/libsysfs.h])])
-
 AC_CHECK_HEADER([libudev.h],
[AC_CHECK_LIB([udev], [udev_new],
  [LIBS=$LIBS -ludev],
-- 
1.8.1.2

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


[PATCH 07/18] staging: usbip: userspace: move sysfs_utils to libsrc

2014-03-08 Thread Valentina Manea
Since it offers a API to both usbip tools and libusbip,
it is more appropriate to be place in the library.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/libsrc/Makefile.am |  3 ++-
 .../staging/usbip/userspace/libsrc/sysfs_utils.c   | 31 ++
 .../staging/usbip/userspace/libsrc/sysfs_utils.h   |  8 ++
 drivers/staging/usbip/userspace/src/Makefile.am|  4 +--
 drivers/staging/usbip/userspace/src/sysfs_utils.c  | 31 --
 drivers/staging/usbip/userspace/src/sysfs_utils.h  |  8 --
 6 files changed, 42 insertions(+), 43 deletions(-)
 create mode 100644 drivers/staging/usbip/userspace/libsrc/sysfs_utils.c
 create mode 100644 drivers/staging/usbip/userspace/libsrc/sysfs_utils.h
 delete mode 100644 drivers/staging/usbip/userspace/src/sysfs_utils.c
 delete mode 100644 drivers/staging/usbip/userspace/src/sysfs_utils.h

diff --git a/drivers/staging/usbip/userspace/libsrc/Makefile.am 
b/drivers/staging/usbip/userspace/libsrc/Makefile.am
index 4921189..7c8f8a4 100644
--- a/drivers/staging/usbip/userspace/libsrc/Makefile.am
+++ b/drivers/staging/usbip/userspace/libsrc/Makefile.am
@@ -4,4 +4,5 @@ libusbip_la_LDFLAGS  = -version-info @LIBUSBIP_VERSION@
 
 lib_LTLIBRARIES := libusbip.la
 libusbip_la_SOURCES := names.c names.h usbip_host_driver.c usbip_host_driver.h 
\
-  usbip_common.c usbip_common.h vhci_driver.c vhci_driver.h
+  usbip_common.c usbip_common.h vhci_driver.c 
vhci_driver.h \
+  sysfs_utils.c sysfs_utils.h
diff --git a/drivers/staging/usbip/userspace/libsrc/sysfs_utils.c 
b/drivers/staging/usbip/userspace/libsrc/sysfs_utils.c
new file mode 100644
index 000..36ac88e
--- /dev/null
+++ b/drivers/staging/usbip/userspace/libsrc/sysfs_utils.c
@@ -0,0 +1,31 @@
+#include sys/types.h
+#include sys/stat.h
+#include fcntl.h
+#include errno.h
+
+#include sysfs_utils.h
+#include usbip_common.h
+
+int write_sysfs_attribute(const char *attr_path, const char *new_value,
+ size_t len)
+{
+   int fd;
+   int length;
+
+   fd = open(attr_path, O_WRONLY);
+   if (fd  0) {
+   dbg(error opening attribute %s, attr_path);
+   return -1;
+   }
+
+   length = write(fd, new_value, len);
+   if (length  0) {
+   dbg(error writing to attribute %s, attr_path);
+   close(fd);
+   return -1;
+   }
+
+   close(fd);
+
+   return 0;
+}
diff --git a/drivers/staging/usbip/userspace/libsrc/sysfs_utils.h 
b/drivers/staging/usbip/userspace/libsrc/sysfs_utils.h
new file mode 100644
index 000..32ac1d1
--- /dev/null
+++ b/drivers/staging/usbip/userspace/libsrc/sysfs_utils.h
@@ -0,0 +1,8 @@
+
+#ifndef __SYSFS_UTILS_H
+#define __SYSFS_UTILS_H
+
+int write_sysfs_attribute(const char *attr_path, const char *new_value,
+ size_t len);
+
+#endif
diff --git a/drivers/staging/usbip/userspace/src/Makefile.am 
b/drivers/staging/usbip/userspace/src/Makefile.am
index 6c91bcb..e81a4eb 100644
--- a/drivers/staging/usbip/userspace/src/Makefile.am
+++ b/drivers/staging/usbip/userspace/src/Makefile.am
@@ -6,8 +6,6 @@ sbin_PROGRAMS := usbip usbipd
 
 usbip_SOURCES := usbip.h utils.h usbip.c utils.c usbip_network.c \
 usbip_attach.c usbip_detach.c usbip_list.c \
-usbip_bind.c usbip_unbind.c usbip_port.c \
-sysfs_utils.c
-
+usbip_bind.c usbip_unbind.c usbip_port.c
 
 usbipd_SOURCES := usbip_network.h usbipd.c usbip_network.c
diff --git a/drivers/staging/usbip/userspace/src/sysfs_utils.c 
b/drivers/staging/usbip/userspace/src/sysfs_utils.c
deleted file mode 100644
index 36ac88e..000
--- a/drivers/staging/usbip/userspace/src/sysfs_utils.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include sys/types.h
-#include sys/stat.h
-#include fcntl.h
-#include errno.h
-
-#include sysfs_utils.h
-#include usbip_common.h
-
-int write_sysfs_attribute(const char *attr_path, const char *new_value,
- size_t len)
-{
-   int fd;
-   int length;
-
-   fd = open(attr_path, O_WRONLY);
-   if (fd  0) {
-   dbg(error opening attribute %s, attr_path);
-   return -1;
-   }
-
-   length = write(fd, new_value, len);
-   if (length  0) {
-   dbg(error writing to attribute %s, attr_path);
-   close(fd);
-   return -1;
-   }
-
-   close(fd);
-
-   return 0;
-}
diff --git a/drivers/staging/usbip/userspace/src/sysfs_utils.h 
b/drivers/staging/usbip/userspace/src/sysfs_utils.h
deleted file mode 100644
index 32ac1d1..000
--- a/drivers/staging/usbip/userspace/src/sysfs_utils.h
+++ /dev/null
@@ -1,8 +0,0 @@
-
-#ifndef __SYSFS_UTILS_H
-#define __SYSFS_UTILS_H
-
-int write_sysfs_attribute(const char *attr_path, const char *new_value,
- size_t len);
-
-#endif
-- 
1.8.1.2

--
To unsubscribe from

[PATCH 05/18] staging: usbip: userspace: re-add interface information listing

2014-03-08 Thread Valentina Manea
This was deleted in the driver conversion patch. It didn't need
to be deleted; showing more information is ok.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
Reviewed-by: Shuah Khan shuah...@samsung.com
---
 drivers/staging/usbip/userspace/src/usbip_list.c | 20 +++-
 drivers/staging/usbip/userspace/src/usbipd.c | 16 +++-
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/usbip/userspace/src/usbip_list.c 
b/drivers/staging/usbip/userspace/src/usbip_list.c
index 54178b7..d5ce34a 100644
--- a/drivers/staging/usbip/userspace/src/usbip_list.c
+++ b/drivers/staging/usbip/userspace/src/usbip_list.c
@@ -52,8 +52,9 @@ static int get_exported_devices(char *host, int sockfd)
struct op_devlist_reply reply;
uint16_t code = OP_REP_DEVLIST;
struct usbip_usb_device udev;
+   struct usbip_usb_interface uintf;
unsigned int i;
-   int rc;
+   int rc, j;
 
rc = usbip_net_send_op_common(sockfd, OP_REQ_DEVLIST, 0);
if (rc  0) {
@@ -103,6 +104,23 @@ static int get_exported_devices(char *host, int sockfd)
printf(%11s: %s\n, , udev.path);
printf(%11s: %s\n, , class_name);
 
+   for (j = 0; j  udev.bNumInterfaces; j++) {
+   rc = usbip_net_recv(sockfd, uintf, sizeof(uintf));
+   if (rc  0) {
+   err(usbip_net_recv failed: usbip_usb_intf[%d],
+   j);
+
+   return -1;
+   }
+   usbip_net_pack_usb_interface(0, uintf);
+
+   usbip_names_get_class(class_name, sizeof(class_name),
+   uintf.bInterfaceClass,
+   uintf.bInterfaceSubClass,
+   uintf.bInterfaceProtocol);
+   printf(%11s: %2d - %s\n, , j, class_name);
+   }
+
printf(\n);
}
 
diff --git a/drivers/staging/usbip/userspace/src/usbipd.c 
b/drivers/staging/usbip/userspace/src/usbipd.c
index c2b3ced..771d6c2 100644
--- a/drivers/staging/usbip/userspace/src/usbipd.c
+++ b/drivers/staging/usbip/userspace/src/usbipd.c
@@ -159,8 +159,9 @@ static int send_reply_devlist(int connfd)
 {
struct usbip_exported_device *edev;
struct usbip_usb_device pdu_udev;
+   struct usbip_usb_interface pdu_uinf;
struct op_devlist_reply reply;
-   int rc;
+   int rc, i;
 
reply.ndev = 0;
/* number of exported devices */
@@ -194,6 +195,19 @@ static int send_reply_devlist(int connfd)
dbg(usbip_net_send failed: pdu_udev);
return -1;
}
+
+   for (i = 0; i  edev-udev.bNumInterfaces; i++) {
+   dump_usb_interface(edev-uinf[i]);
+   memcpy(pdu_uinf, edev-uinf[i], sizeof(pdu_uinf));
+   usbip_net_pack_usb_interface(1, pdu_uinf);
+
+   rc = usbip_net_send(connfd, pdu_uinf,
+   sizeof(pdu_uinf));
+   if (rc  0) {
+   err(usbip_net_send failed: pdu_uinf);
+   return -1;
+   }
+   }
}
 
return 0;
-- 
1.8.1.2

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


[PATCH 08/18] staging: usbip: userspace: migrate usbip_host_driver to libudev

2014-03-08 Thread Valentina Manea
This patch modifies usbip_host_driver to use libudev.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
Reviewed-by: Shuah Khan shuah...@samsung.com
---
 .../staging/usbip/userspace/libsrc/usbip_common.c  |  76 ++
 .../staging/usbip/userspace/libsrc/usbip_common.h  |   5 +-
 .../usbip/userspace/libsrc/usbip_host_driver.c | 285 ++---
 .../usbip/userspace/libsrc/usbip_host_driver.h |   7 +-
 .../staging/usbip/userspace/libsrc/vhci_driver.c   |  22 +-
 drivers/staging/usbip/userspace/src/usbipd.c   |  14 +-
 6 files changed, 145 insertions(+), 264 deletions(-)

diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.c 
b/drivers/staging/usbip/userspace/libsrc/usbip_common.c
index 6620d18..998c11c 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.c
+++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.c
@@ -2,6 +2,7 @@
  * Copyright (C) 2005-2007 Takahiro Hirofuchi
  */
 
+#include libudev.h
 #include usbip_common.h
 #include names.h
 
@@ -12,6 +13,8 @@ int usbip_use_syslog;
 int usbip_use_stderr;
 int usbip_use_debug;
 
+extern struct udev *udev_context;
+
 struct speed_string {
int num;
char *speed;
@@ -111,75 +114,48 @@ void dump_usb_device(struct usbip_usb_device *udev)
 }
 
 
-int read_attr_value(struct sysfs_device *dev, const char *name,
+int read_attr_value(struct udev_device *dev, const char *name,
const char *format)
 {
-   char attrpath[SYSFS_PATH_MAX];
-   struct sysfs_attribute *attr;
+   const char *attr;
int num = 0;
int ret;
 
-   snprintf(attrpath, sizeof(attrpath), %s/%s, dev-path, name);
-
-   attr = sysfs_open_attribute(attrpath);
+   attr = udev_device_get_sysattr_value(dev, name);
if (!attr) {
-   dbg(sysfs_open_attribute failed: %s, attrpath);
-   return 0;
-   }
-
-   ret = sysfs_read_attribute(attr);
-   if (ret  0) {
-   dbg(sysfs_read_attribute failed);
+   err(udev_device_get_sysattr_value failed);
goto err;
}
 
-   ret = sscanf(attr-value, format, num);
+   ret = sscanf(attr, format, num);
if (ret  1) {
-   dbg(sscanf failed);
+   err(sscanf failed);
goto err;
}
 
 err:
-   sysfs_close_attribute(attr);
 
return num;
 }
 
 
-int read_attr_speed(struct sysfs_device *dev)
+int read_attr_speed(struct udev_device *dev)
 {
-   char attrpath[SYSFS_PATH_MAX];
-   struct sysfs_attribute *attr;
-   char speed[100];
-   int ret;
-
-   snprintf(attrpath, sizeof(attrpath), %s/%s, dev-path, speed);
-
-   attr = sysfs_open_attribute(attrpath);
-   if (!attr) {
-   dbg(sysfs_open_attribute failed: %s, attrpath);
-   return 0;
-   }
+   const char *speed;
 
-   ret = sysfs_read_attribute(attr);
-   if (ret  0) {
-   dbg(sysfs_read_attribute failed);
+   speed = udev_device_get_sysattr_value(dev, speed);
+   if (!speed) {
+   err(udev_device_get_sysattr_value failed);
goto err;
}
 
-   ret = sscanf(attr-value, %99s\n, speed);
-   if (ret  1) {
-   dbg(sscanf failed);
-   goto err;
-   }
-err:
-   sysfs_close_attribute(attr);
-
for (int i = 0; speed_strings[i].speed != NULL; i++) {
if (!strcmp(speed, speed_strings[i].speed))
return speed_strings[i].num;
}
 
+err:
+
return USB_SPEED_UNKNOWN;
 }
 
@@ -190,9 +166,10 @@ err:
} while (0)
 
 
-int read_usb_device(struct sysfs_device *sdev, struct usbip_usb_device *udev)
+int read_usb_device(struct udev_device *sdev, struct usbip_usb_device *udev)
 {
uint32_t busnum, devnum;
+   const char *path, *name;
 
READ_ATTR(udev, uint8_t,  sdev, bDeviceClass,   %02x\n);
READ_ATTR(udev, uint8_t,  sdev, bDeviceSubClass,%02x\n);
@@ -209,10 +186,13 @@ int read_usb_device(struct sysfs_device *sdev, struct 
usbip_usb_device *udev)
READ_ATTR(udev, uint8_t,  sdev, devnum, %d\n);
udev-speed = read_attr_speed(sdev);
 
-   strncpy(udev-path,  sdev-path,  SYSFS_PATH_MAX);
-   strncpy(udev-busid, sdev-name, SYSFS_BUS_ID_SIZE);
+   path = udev_device_get_syspath(sdev);
+   name = udev_device_get_sysname(sdev);
 
-   sscanf(sdev-name, %u-%u, busnum, devnum);
+   strncpy(udev-path,  path,  SYSFS_PATH_MAX);
+   strncpy(udev-busid, name, SYSFS_BUS_ID_SIZE);
+
+   sscanf(name, %u-%u, busnum, devnum);
udev-busnum = busnum;
 
return 0;
@@ -222,13 +202,13 @@ int read_usb_interface(struct usbip_usb_device *udev, int 
i,
   struct usbip_usb_interface *uinf)
 {
char busid[SYSFS_BUS_ID_SIZE];
-   struct sysfs_device *sif;
+   struct udev_device *sif;
 
sprintf(busid, %s:%d.%d, udev

[PATCH 10/18] staging: usbip: userspace: migrate vhci_driver to libudev

2014-03-08 Thread Valentina Manea
This patch migrates vhci_driver to libudev.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
Reviewed-by: Shuah Khan shuah...@samsung.com
---
 .../staging/usbip/userspace/libsrc/usbip_common.h  |   1 -
 .../staging/usbip/userspace/libsrc/vhci_driver.c   | 154 ++---
 .../staging/usbip/userspace/libsrc/vhci_driver.h   |   5 +-
 3 files changed, 44 insertions(+), 116 deletions(-)

diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.h 
b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
index ed9b43b..23be848 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.h
+++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
@@ -5,7 +5,6 @@
 #ifndef __USBIP_COMMON_H
 #define __USBIP_COMMON_H
 
-#include sysfs/libsysfs.h
 #include libudev.h
 
 #include stdint.h
diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c 
b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
index fa68bed..8901fcb 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
@@ -7,6 +7,7 @@
 #include limits.h
 #include netdb.h
 #include libudev.h
+#include sysfs_utils.h
 
 #undef  PROGNAME
 #define PROGNAME libusbip
@@ -36,7 +37,7 @@ err:
 
 
 
-static int parse_status(char *value)
+static int parse_status(const char *value)
 {
int ret = 0;
char *c;
@@ -108,42 +109,33 @@ static int parse_status(char *value)
 
 static int refresh_imported_device_list(void)
 {
-   struct sysfs_attribute *attr_status;
+   const char *attr_status;
 
-
-   attr_status = sysfs_get_device_attr(vhci_driver-hc_device, status);
+   attr_status = udev_device_get_sysattr_value(vhci_driver-hc_device,
+  status);
if (!attr_status) {
-   dbg(sysfs_get_device_attr(\status\) failed: %s,
-   vhci_driver-hc_device-name);
+   err(udev_device_get_sysattr_value failed);
return -1;
}
 
-   dbg(name: %s  path: %s  len: %d  method: %d  value: %s,
-   attr_status-name, attr_status-path, attr_status-len,
-   attr_status-method, attr_status-value);
-
-   return parse_status(attr_status-value);
+   return parse_status(attr_status);
 }
 
 static int get_nports(void)
 {
char *c;
int nports = 0;
-   struct sysfs_attribute *attr_status;
+   const char *attr_status;
 
-   attr_status = sysfs_get_device_attr(vhci_driver-hc_device, status);
+   attr_status = udev_device_get_sysattr_value(vhci_driver-hc_device,
+  status);
if (!attr_status) {
-   dbg(sysfs_get_device_attr(\status\) failed: %s,
-   vhci_driver-hc_device-name);
+   err(udev_device_get_sysattr_value failed);
return -1;
}
 
-   dbg(name: %s  path: %s  len: %d  method: %d  value: %s,
-   attr_status-name, attr_status-path, attr_status-len,
-   attr_status-method, attr_status-value);
-
/* skip a header line */
-   c = strchr(attr_status-value, '\n');
+   c = strchr(attr_status, '\n');
if (!c)
return 0;
c++;
@@ -160,50 +152,6 @@ static int get_nports(void)
return nports;
 }
 
-static int get_hc_busid(char *sysfs_mntpath, char *hc_busid)
-{
-   struct sysfs_driver *sdriver;
-   char sdriver_path[SYSFS_PATH_MAX];
-
-   struct sysfs_device *hc_dev;
-   struct dlist *hc_devs;
-
-   int found = 0;
-
-   snprintf(sdriver_path, SYSFS_PATH_MAX, %s/%s/%s/%s/%s, sysfs_mntpath,
-   SYSFS_BUS_NAME, USBIP_VHCI_BUS_TYPE, SYSFS_DRIVERS_NAME,
-   USBIP_VHCI_DRV_NAME);
-
-   sdriver = sysfs_open_driver_path(sdriver_path);
-   if (!sdriver) {
-   dbg(sysfs_open_driver_path failed: %s, sdriver_path);
-   dbg(make sure  USBIP_CORE_MOD_NAME .ko and 
-   USBIP_VHCI_DRV_NAME .ko are loaded!);
-   return -1;
-   }
-
-   hc_devs = sysfs_get_driver_devices(sdriver);
-   if (!hc_devs) {
-   dbg(sysfs_get_driver failed);
-   goto err;
-   }
-
-   /* assume only one vhci_hcd */
-   dlist_for_each_data(hc_devs, hc_dev, struct sysfs_device) {
-   strncpy(hc_busid, hc_dev-bus_id, SYSFS_BUS_ID_SIZE);
-   found = 1;
-   }
-
-err:
-   sysfs_close_driver(sdriver);
-
-   if (found)
-   return 0;
-
-   dbg(%s not found, hc_busid);
-   return -1;
-}
-
 /*
  * Read the given port's record.
  *
@@ -215,7 +163,6 @@ err:
  */
 static int read_record(int rhport, char *host, unsigned long host_len,
char *port, unsigned long port_len, char *busid)
-
 {
int part;
FILE *file;
@@ -272,36 +219,21 @@ static int read_record(int rhport, char *host, unsigned 
long host_len,
 
 int usbip_vhci_driver_open(void)
 {
-   int ret

[PATCH 03/18] staging: usbip: userspace: migrate usbip_unbind to libudev

2014-03-08 Thread Valentina Manea
This patch modifies usbip_unbind to use libudev.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
Reviewed-by: Shuah Khan shuah...@samsung.com
---
 drivers/staging/usbip/userspace/src/usbip_unbind.c | 93 +++---
 1 file changed, 29 insertions(+), 64 deletions(-)

diff --git a/drivers/staging/usbip/userspace/src/usbip_unbind.c 
b/drivers/staging/usbip/userspace/src/usbip_unbind.c
index cace878..7180dbe 100644
--- a/drivers/staging/usbip/userspace/src/usbip_unbind.c
+++ b/drivers/staging/usbip/userspace/src/usbip_unbind.c
@@ -16,7 +16,7 @@
  * along with this program. If not, see http://www.gnu.org/licenses/.
  */
 
-#include sysfs/libsysfs.h
+#include libudev.h
 
 #include errno.h
 #include stdio.h
@@ -27,6 +27,7 @@
 #include usbip_common.h
 #include utils.h
 #include usbip.h
+#include sysfs_utils.h
 
 static const char usbip_unbind_usage_string[] =
usbip unbind args\n
@@ -41,92 +42,56 @@ void usbip_unbind_usage(void)
 static int unbind_device(char *busid)
 {
char bus_type[] = usb;
-   struct sysfs_driver *usbip_host_drv;
-   struct sysfs_device *dev;
-   struct dlist *devlist;
-   int verified = 0;
int rc, ret = -1;
 
char attr_name[] = unbind;
-   char sysfs_mntpath[SYSFS_PATH_MAX];
char unbind_attr_path[SYSFS_PATH_MAX];
-   struct sysfs_attribute *unbind_attr;
-
-   /* verify the busid device is using usbip-host */
-   usbip_host_drv = sysfs_open_driver(bus_type, USBIP_HOST_DRV_NAME);
-   if (!usbip_host_drv) {
-   err(could not open %s driver: %s, USBIP_HOST_DRV_NAME,
-   strerror(errno));
-   return -1;
-   }
 
-   devlist = sysfs_get_driver_devices(usbip_host_drv);
-   if (!devlist) {
-   err(%s is not in use by any devices, USBIP_HOST_DRV_NAME);
-   goto err_close_usbip_host_drv;
-   }
+   struct udev *udev;
+   struct udev_device *dev;
+   const char *driver;
 
-   dlist_for_each_data(devlist, dev, struct sysfs_device) {
-   if (!strncmp(busid, dev-name, strlen(busid)) 
-   !strncmp(dev-driver_name, USBIP_HOST_DRV_NAME,
-strlen(USBIP_HOST_DRV_NAME))) {
-   verified = 1;
-   break;
-   }
-   }
+   /* Create libudev context. */
+   udev = udev_new();
 
-   if (!verified) {
-   err(device on busid %s is not using %s, busid,
-   USBIP_HOST_DRV_NAME);
-   goto err_close_usbip_host_drv;
+   /* Check whether the device with this bus ID exists. */
+   dev = udev_device_new_from_subsystem_sysname(udev, usb, busid);
+   if (!dev) {
+   err(device with the specified bus ID does not exist);
+   goto err_close_udev;
}
 
-   /*
-* NOTE: A read and write of an attribute value of the device busid
-* refers to must be done to start probing. That way a rebind of the
-* default driver for the device occurs.
-*
-* This seems very hackish and adds a lot of pointless code. I think it
-* should be done in the kernel by the driver after del_match_busid is
-* finished!
-*/
-
-   rc = sysfs_get_mnt_path(sysfs_mntpath, SYSFS_PATH_MAX);
-   if (rc  0) {
-   err(sysfs must be mounted: %s, strerror(errno));
-   return -1;
+   /* Check whether the device is using usbip-host driver. */
+   driver = udev_device_get_driver(dev);
+   if (!driver || strcmp(driver, usbip-host)) {
+   err(device is not bound to usbip-host driver);
+   goto err_close_udev;
}
 
+   /* Unbind device from driver. */
snprintf(unbind_attr_path, sizeof(unbind_attr_path), 
%s/%s/%s/%s/%s/%s,
-sysfs_mntpath, SYSFS_BUS_NAME, bus_type, SYSFS_DRIVERS_NAME,
+SYSFS_MNT_PATH, SYSFS_BUS_NAME, bus_type, SYSFS_DRIVERS_NAME,
 USBIP_HOST_DRV_NAME, attr_name);
 
-   /* read a device attribute */
-   unbind_attr = sysfs_open_attribute(unbind_attr_path);
-   if (!unbind_attr) {
-   err(could not open %s/%s: %s, busid, attr_name,
-   strerror(errno));
-   return -1;
+   rc = write_sysfs_attribute(unbind_attr_path, busid, strlen(busid));
+   if (rc  0) {
+   err(error unbinding device %s from driver, busid);
+   goto err_close_udev;
}
 
-   /* notify driver of unbind */
+   /* Notify driver of unbind. */
rc = modify_match_busid(busid, 0);
if (rc  0) {
err(unable to unbind device on %s, busid);
+   goto err_close_udev;
}
 
-   rc = sysfs_write_attribute(unbind_attr, busid,
-  SYSFS_BUS_ID_SIZE);
-   if (rc  0) {
-   dbg(bind driver at %s failed, busid

[PATCH 09/18] staging: usbip: userspace: remove class device infrastructure in vhci_driver

2014-03-08 Thread Valentina Manea
The class device lists were used only when being initialized,
being populated and being destroyed. They had no real meaning
and thus the code was useless.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 .../staging/usbip/userspace/libsrc/vhci_driver.c   | 178 -
 .../staging/usbip/userspace/libsrc/vhci_driver.h   |   9 --
 2 files changed, 187 deletions(-)

diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c 
b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
index acdcb13..fa68bed 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
@@ -28,26 +28,6 @@ imported_device_init(struct usbip_imported_device *idev, 
char *busid)
read_usb_device(sudev, idev-udev);
udev_device_unref(sudev);
 
-   /* add class devices of this imported device */
-   struct usbip_class_device *cdev;
-   dlist_for_each_data(vhci_driver-cdev_list, cdev,
-   struct usbip_class_device) {
-   if (!strncmp(cdev-dev_path, idev-udev.path,
-strlen(idev-udev.path))) {
-   struct usbip_class_device *new_cdev;
-   /*
-* alloc and copy because dlist is linked
-* from only one list
-*/
-   new_cdev = calloc(1, sizeof(*new_cdev));
-   if (!new_cdev)
-   goto err;
-
-   memcpy(new_cdev, cdev, sizeof(*new_cdev));
-   dlist_unshift(idev-cdev_list, (void *) new_cdev);
-   }
-   }
-
return idev;
 
 err:
@@ -103,12 +83,6 @@ static int parse_status(char *value)
idev-busnum= (devid  16);
idev-devnum= (devid  0x);
 
-   idev-cdev_list = dlist_new(sizeof(struct 
usbip_class_device));
-   if (!idev-cdev_list) {
-   dbg(dlist_new failed);
-   return -1;
-   }
-
if (idev-status != VDEV_ST_NULL
 idev-status != VDEV_ST_NOTASSIGNED) {
idev = imported_device_init(idev, lbusid);
@@ -132,118 +106,6 @@ static int parse_status(char *value)
return 0;
 }
 
-
-static int check_usbip_device(struct sysfs_class_device *cdev)
-{
-   /* /sys/class/video4linux/video0/device */
-   char class_path[SYSFS_PATH_MAX];
-   /* /sys/devices/platform/vhci_hcd/usb6/6-1:1.1 */
-   char dev_path[SYSFS_PATH_MAX];
-   int ret;
-   struct usbip_class_device *usbip_cdev;
-
-   snprintf(class_path, sizeof(class_path), %s/device, cdev-path);
-
-   ret = sysfs_get_link(class_path, dev_path, sizeof(dev_path));
-   if (ret == 0) {
-   if (!strncmp(dev_path, vhci_driver-hc_device-path,
-strlen(vhci_driver-hc_device-path))) {
-   /* found usbip device */
-   usbip_cdev = calloc(1, sizeof(*usbip_cdev));
-   if (!usbip_cdev) {
-   dbg(calloc failed);
-   return -1;
-   }
-   dlist_unshift(vhci_driver-cdev_list, usbip_cdev);
-   strncpy(usbip_cdev-class_path, class_path,
-   sizeof(usbip_cdev-class_path));
-   strncpy(usbip_cdev-dev_path, dev_path,
-   sizeof(usbip_cdev-dev_path));
-   dbg(found: %s %s, class_path, dev_path);
-   }
-   }
-
-   return 0;
-}
-
-
-static int search_class_for_usbip_device(char *cname)
-{
-   struct sysfs_class *class;
-   struct dlist *cdev_list;
-   struct sysfs_class_device *cdev;
-   int ret = 0;
-
-   class = sysfs_open_class(cname);
-   if (!class) {
-   dbg(sysfs_open_class failed);
-   return -1;
-   }
-
-   dbg(class: %s, class-name);
-
-   cdev_list = sysfs_get_class_devices(class);
-   if (!cdev_list)
-   /* nothing */
-   goto out;
-
-   dlist_for_each_data(cdev_list, cdev, struct sysfs_class_device) {
-   dbg(cdev: %s, cdev-name);
-   ret = check_usbip_device(cdev);
-   if (ret  0)
-   goto out;
-   }
-
-out:
-   sysfs_close_class(class);
-
-   return ret;
-}
-
-
-static int refresh_class_device_list(void)
-{
-   int ret;
-   struct dlist *cname_list;
-   char *cname;
-   char sysfs_mntpath[SYSFS_PATH_MAX];
-   char class_path[SYSFS_PATH_MAX];
-
-   ret = sysfs_get_mnt_path(sysfs_mntpath, SYSFS_PATH_MAX);
-   if (ret  0) {
-   dbg(sysfs_get_mnt_path failed);
-   return -1

[PATCH 06/18] staging: usbip: userspace: add new list API

2014-03-08 Thread Valentina Manea
Take the linked list implementation from the Linux Kernel
and strip it down to what it is needed.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/libsrc/list.h | 136 ++
 1 file changed, 136 insertions(+)
 create mode 100644 drivers/staging/usbip/userspace/libsrc/list.h

diff --git a/drivers/staging/usbip/userspace/libsrc/list.h 
b/drivers/staging/usbip/userspace/libsrc/list.h
new file mode 100644
index 000..8d0c936
--- /dev/null
+++ b/drivers/staging/usbip/userspace/libsrc/list.h
@@ -0,0 +1,136 @@
+#ifndef _LIST_H
+#define _LIST_H
+
+/* Stripped down implementation of linked list taken
+ * from the Linux Kernel.
+ */
+
+/*
+ * Simple doubly linked list implementation.
+ *
+ * Some of the internal functions (__xxx) are useful when
+ * manipulating whole lists rather than single entries, as
+ * sometimes we already know the next/prev entries and we can
+ * generate better code by using them directly rather than
+ * using the generic single-entry routines.
+ */
+
+struct list_head {
+   struct list_head *next, *prev;
+};
+
+#define LIST_HEAD_INIT(name) { (name), (name) }
+
+#define LIST_HEAD(name) \
+   struct list_head name = LIST_HEAD_INIT(name)
+
+static inline void INIT_LIST_HEAD(struct list_head *list)
+{
+   list-next = list;
+   list-prev = list;
+}
+
+/*
+ * Insert a new entry between two known consecutive entries.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_add(struct list_head *new,
+ struct list_head *prev,
+ struct list_head *next)
+{
+   next-prev = new;
+   new-next = next;
+   new-prev = prev;
+   prev-next = new;
+}
+
+/**
+ * list_add - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it after
+ *
+ * Insert a new entry after the specified head.
+ * This is good for implementing stacks.
+ */
+static inline void list_add(struct list_head *new, struct list_head *head)
+{
+   __list_add(new, head, head-next);
+}
+
+/*
+ * Delete a list entry by making the prev/next entries
+ * point to each other.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_del(struct list_head * prev, struct list_head * next)
+{
+   next-prev = prev;
+   prev-next = next;
+}
+
+#define POISON_POINTER_DELTA 0
+#define LIST_POISON1  ((void *) 0x00100100 + POISON_POINTER_DELTA)
+#define LIST_POISON2  ((void *) 0x00200200 + POISON_POINTER_DELTA)
+
+/**
+ * list_del - deletes entry from list.
+ * @entry: the element to delete from the list.
+ * Note: list_empty() on entry does not return true after this, the entry is
+ * in an undefined state.
+ */
+static inline void __list_del_entry(struct list_head *entry)
+{
+   __list_del(entry-prev, entry-next);
+}
+
+static inline void list_del(struct list_head *entry)
+{
+   __list_del(entry-prev, entry-next);
+   entry-next = LIST_POISON1;
+   entry-prev = LIST_POISON2;
+}
+
+/**
+ * list_entry - get the struct for this entry
+ * @ptr:   the struct list_head pointer.
+ * @type:  the type of the struct this is embedded in.
+ * @member:the name of the list_struct within the struct.
+ */
+#define list_entry(ptr, type, member) \
+   container_of(ptr, type, member)
+/**
+ * list_for_each   -   iterate over a list
+ * @pos:   the struct list_head to use as a loop cursor.
+ * @head:  the head for your list.
+ */
+#define list_for_each(pos, head) \
+   for (pos = (head)-next; pos != (head); pos = pos-next)
+
+/**
+ * list_for_each_safe - iterate over a list safe against removal of list entry
+ * @pos:   the struct list_head to use as a loop cursor.
+ * @n: another struct list_head to use as temporary storage
+ * @head:  the head for your list.
+ */
+#define list_for_each_safe(pos, n, head) \
+   for (pos = (head)-next, n = pos-next; pos != (head); \
+   pos = n, n = pos-next)
+
+#define offsetof(TYPE, MEMBER) ((size_t) ((TYPE *)0)-MEMBER)
+
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr:   the pointer to the member.
+ * @type:  the type of the container struct this is embedded in.
+ * @member:the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({ \
+   const typeof( ((type *)0)-member ) *__mptr = (ptr);\
+   (type *)( (char *)__mptr - offsetof(type,member) );})
+
+#endif
-- 
1.8.1.2

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


[PATCH 04/18] staging: usbip: userspace: migrate usbip_list to libudev

2014-03-08 Thread Valentina Manea
This patch modifies usbip_list to use libudev.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/src/usbip_list.c | 133 +--
 1 file changed, 50 insertions(+), 83 deletions(-)

diff --git a/drivers/staging/usbip/userspace/src/usbip_list.c 
b/drivers/staging/usbip/userspace/src/usbip_list.c
index 8864fa2..54178b7 100644
--- a/drivers/staging/usbip/userspace/src/usbip_list.c
+++ b/drivers/staging/usbip/userspace/src/usbip_list.c
@@ -17,7 +17,7 @@
  */
 
 #include sys/types.h
-#include sysfs/libsysfs.h
+#include libudev.h
 
 #include errno.h
 #include stdbool.h
@@ -133,8 +133,8 @@ static int list_exported_devices(char *host)
return 0;
 }
 
-static void print_device(char *busid, char *vendor, char *product,
-bool parsable)
+static void print_device(const char *busid, const char *vendor,
+const char *product, bool parsable)
 {
if (parsable)
printf(busid=%s#usbid=%.4s:%.4s#, busid, vendor, product);
@@ -148,106 +148,73 @@ static void print_product_name(char *product_name, bool 
parsable)
printf(   %s\n, product_name);
 }
 
-static void print_interface(char *busid, char *driver, bool parsable)
-{
-   if (parsable)
-   printf(%s=%s#, busid, driver);
-   else
-   printf(%9s%s - %s\n, , busid, driver);
-}
-
-static int is_device(void *x)
-{
-   struct sysfs_attribute *devpath;
-   struct sysfs_device *dev = x;
-   int ret = 0;
-
-   devpath = sysfs_get_device_attr(dev, devpath);
-   if (devpath  *devpath-value != '0')
-   ret = 1;
-
-   return ret;
-}
-
-static int devcmp(void *a, void *b)
-{
-   return strcmp(a, b);
-}
-
 static int list_devices(bool parsable)
 {
-   char bus_type[] = usb;
-   char busid[SYSFS_BUS_ID_SIZE];
+   struct udev *udev;
+   struct udev_enumerate *enumerate;
+   struct udev_list_entry *devices, *dev_list_entry;
+   struct udev_device *dev;
+   const char *path;
+   const char *idVendor;
+   const char *idProduct;
+   const char *bConfValue;
+   const char *bNumIntfs;
+   const char *busid;
char product_name[128];
-   struct sysfs_bus *ubus;
-   struct sysfs_device *dev;
-   struct sysfs_device *intf;
-   struct sysfs_attribute *idVendor;
-   struct sysfs_attribute *idProduct;
-   struct sysfs_attribute *bConfValue;
-   struct sysfs_attribute *bNumIntfs;
-   struct dlist *devlist;
-   int i;
int ret = -1;
 
-   ubus = sysfs_open_bus(bus_type);
-   if (!ubus) {
-   err(could not open %s bus: %s, bus_type, strerror(errno));
-   return -1;
-   }
-
-   devlist = sysfs_get_bus_devices(ubus);
-   if (!devlist) {
-   err(could not get %s bus devices: %s, bus_type,
-   strerror(errno));
-   goto err_out;
-   }
-
-   /* remove interfaces and root hubs from device list */
-   dlist_filter_sort(devlist, is_device, devcmp);
-
-   if (!parsable) {
-   printf(Local USB devices\n);
-   printf(=\n);
-   }
-   dlist_for_each_data(devlist, dev, struct sysfs_device) {
-   idVendor   = sysfs_get_device_attr(dev, idVendor);
-   idProduct  = sysfs_get_device_attr(dev, idProduct);
-   bConfValue = sysfs_get_device_attr(dev, bConfigurationValue);
-   bNumIntfs  = sysfs_get_device_attr(dev, bNumInterfaces);
+   /* Create libudev context. */
+   udev = udev_new();
+
+   /* Create libudev device enumeration. */
+   enumerate = udev_enumerate_new(udev);
+
+   /* Take only USB devices that are not hubs and do not have
+* the bInterfaceNumber attribute, i.e. are not interfaces.
+*/
+   udev_enumerate_add_match_subsystem(enumerate, usb);
+   udev_enumerate_add_nomatch_sysattr(enumerate, bDeviceClass, 09);
+   udev_enumerate_add_nomatch_sysattr(enumerate, bInterfaceNumber, NULL);
+   udev_enumerate_scan_devices(enumerate);
+
+   devices = udev_enumerate_get_list_entry(enumerate);
+
+   /* Show information about each device. */
+   udev_list_entry_foreach(dev_list_entry, devices) {
+   path = udev_list_entry_get_name(dev_list_entry);
+   dev = udev_device_new_from_syspath(udev, path);
+
+   /* Get device information. */
+   idVendor = udev_device_get_sysattr_value(dev, idVendor);
+   idProduct = udev_device_get_sysattr_value(dev, idProduct);
+   bConfValue = udev_device_get_sysattr_value(dev, 
bConfigurationValue);
+   bNumIntfs = udev_device_get_sysattr_value(dev, 
bNumInterfaces);
+   busid = udev_device_get_sysname(dev);
if (!idVendor || !idProduct || !bConfValue || !bNumIntfs) {
err(problem getting

[PATCH 01/18] staging: usbip: userspace: migrate usbip_bind to libudev

2014-03-08 Thread Valentina Manea
This patch adds autoconf check for libudev and migrates
usbip_bind to the new library.

libsysfs will still be used until all userspace is modified.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
Reviewed-by: Shuah Khan shuah...@samsung.com
---
 drivers/staging/usbip/userspace/configure.ac   |   6 +
 .../staging/usbip/userspace/libsrc/usbip_common.h  |   9 ++
 drivers/staging/usbip/userspace/src/Makefile.am|   3 +-
 drivers/staging/usbip/userspace/src/sysfs_utils.c  |  31 +
 drivers/staging/usbip/userspace/src/sysfs_utils.h  |   8 ++
 drivers/staging/usbip/userspace/src/usbip_bind.c   | 149 -
 drivers/staging/usbip/userspace/src/utils.c|  48 ++-
 7 files changed, 127 insertions(+), 127 deletions(-)
 create mode 100644 drivers/staging/usbip/userspace/src/sysfs_utils.c
 create mode 100644 drivers/staging/usbip/userspace/src/sysfs_utils.h

diff --git a/drivers/staging/usbip/userspace/configure.ac 
b/drivers/staging/usbip/userspace/configure.ac
index 0ee5d92..a5193c6 100644
--- a/drivers/staging/usbip/userspace/configure.ac
+++ b/drivers/staging/usbip/userspace/configure.ac
@@ -50,6 +50,12 @@ AC_CHECK_HEADER([sysfs/libsysfs.h],
  [AC_MSG_ERROR([Missing sysfs2 library!])])],
[AC_MSG_ERROR([Missing /usr/include/sysfs/libsysfs.h])])
 
+AC_CHECK_HEADER([libudev.h],
+   [AC_CHECK_LIB([udev], [udev_new],
+ [LIBS=$LIBS -ludev],
+ [AC_MSG_ERROR([Missing udev library!])])],
+   [AC_MSG_ERROR([Missing /usr/include/libudev.h])])
+
 # Checks for libwrap library.
 AC_MSG_CHECKING([whether to use the libwrap (TCP wrappers) library])
 AC_ARG_WITH([tcp-wrappers],
diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.h 
b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
index 5af59d4..d313e12 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.h
+++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
@@ -30,6 +30,15 @@
 #define USBIP_HOST_DRV_NAMEusbip-host
 #define USBIP_VHCI_DRV_NAMEvhci_hcd
 
+/* sysfs constants */
+#define SYSFS_MNT_PATH /sys
+#define SYSFS_BUS_NAME bus
+#define SYSFS_BUS_TYPE usb
+#define SYSFS_DRIVERS_NAME drivers
+
+#define SYSFS_PATH_MAX 256
+#define SYSFS_BUS_ID_SIZE  32
+
 extern int usbip_use_syslog;
 extern int usbip_use_stderr;
 extern int usbip_use_debug ;
diff --git a/drivers/staging/usbip/userspace/src/Makefile.am 
b/drivers/staging/usbip/userspace/src/Makefile.am
index b4f8c4b..6c91bcb 100644
--- a/drivers/staging/usbip/userspace/src/Makefile.am
+++ b/drivers/staging/usbip/userspace/src/Makefile.am
@@ -6,7 +6,8 @@ sbin_PROGRAMS := usbip usbipd
 
 usbip_SOURCES := usbip.h utils.h usbip.c utils.c usbip_network.c \
 usbip_attach.c usbip_detach.c usbip_list.c \
-usbip_bind.c usbip_unbind.c usbip_port.c
+usbip_bind.c usbip_unbind.c usbip_port.c \
+sysfs_utils.c
 
 
 usbipd_SOURCES := usbip_network.h usbipd.c usbip_network.c
diff --git a/drivers/staging/usbip/userspace/src/sysfs_utils.c 
b/drivers/staging/usbip/userspace/src/sysfs_utils.c
new file mode 100644
index 000..36ac88e
--- /dev/null
+++ b/drivers/staging/usbip/userspace/src/sysfs_utils.c
@@ -0,0 +1,31 @@
+#include sys/types.h
+#include sys/stat.h
+#include fcntl.h
+#include errno.h
+
+#include sysfs_utils.h
+#include usbip_common.h
+
+int write_sysfs_attribute(const char *attr_path, const char *new_value,
+ size_t len)
+{
+   int fd;
+   int length;
+
+   fd = open(attr_path, O_WRONLY);
+   if (fd  0) {
+   dbg(error opening attribute %s, attr_path);
+   return -1;
+   }
+
+   length = write(fd, new_value, len);
+   if (length  0) {
+   dbg(error writing to attribute %s, attr_path);
+   close(fd);
+   return -1;
+   }
+
+   close(fd);
+
+   return 0;
+}
diff --git a/drivers/staging/usbip/userspace/src/sysfs_utils.h 
b/drivers/staging/usbip/userspace/src/sysfs_utils.h
new file mode 100644
index 000..32ac1d1
--- /dev/null
+++ b/drivers/staging/usbip/userspace/src/sysfs_utils.h
@@ -0,0 +1,8 @@
+
+#ifndef __SYSFS_UTILS_H
+#define __SYSFS_UTILS_H
+
+int write_sysfs_attribute(const char *attr_path, const char *new_value,
+ size_t len);
+
+#endif
diff --git a/drivers/staging/usbip/userspace/src/usbip_bind.c 
b/drivers/staging/usbip/userspace/src/usbip_bind.c
index 8cfd2db..fa46141 100644
--- a/drivers/staging/usbip/userspace/src/usbip_bind.c
+++ b/drivers/staging/usbip/userspace/src/usbip_bind.c
@@ -16,7 +16,7 @@
  * along with this program. If not, see http://www.gnu.org/licenses/.
  */
 
-#include sysfs/libsysfs.h
+#include libudev.h
 
 #include errno.h
 #include stdio.h
@@ -28,6 +28,7 @@
 #include usbip_common.h
 #include utils.h
 #include usbip.h
+#include sysfs_utils.h

[PATCH 02/18] staging: usbip: userspace: remove useless libsysfs includes

2014-03-08 Thread Valentina Manea
This patch removes useless libsysfs.h includes in various
userspace files.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/src/usbip_attach.c  | 1 -
 drivers/staging/usbip/userspace/src/usbip_detach.c  | 2 --
 drivers/staging/usbip/userspace/src/usbip_network.h | 1 -
 3 files changed, 4 deletions(-)

diff --git a/drivers/staging/usbip/userspace/src/usbip_attach.c 
b/drivers/staging/usbip/userspace/src/usbip_attach.c
index 0858411..716a79e 100644
--- a/drivers/staging/usbip/userspace/src/usbip_attach.c
+++ b/drivers/staging/usbip/userspace/src/usbip_attach.c
@@ -17,7 +17,6 @@
  */
 
 #include sys/stat.h
-#include sysfs/libsysfs.h
 
 #include limits.h
 #include stdint.h
diff --git a/drivers/staging/usbip/userspace/src/usbip_detach.c 
b/drivers/staging/usbip/userspace/src/usbip_detach.c
index 13308df..05c6d15 100644
--- a/drivers/staging/usbip/userspace/src/usbip_detach.c
+++ b/drivers/staging/usbip/userspace/src/usbip_detach.c
@@ -16,8 +16,6 @@
  * along with this program. If not, see http://www.gnu.org/licenses/.
  */
 
-#include sysfs/libsysfs.h
-
 #include ctype.h
 #include limits.h
 #include stdint.h
diff --git a/drivers/staging/usbip/userspace/src/usbip_network.h 
b/drivers/staging/usbip/userspace/src/usbip_network.h
index f19ae19..c1e875c 100644
--- a/drivers/staging/usbip/userspace/src/usbip_network.h
+++ b/drivers/staging/usbip/userspace/src/usbip_network.h
@@ -10,7 +10,6 @@
 #endif
 
 #include sys/types.h
-#include sysfs/libsysfs.h
 
 #include stdint.h
 
-- 
1.8.1.2

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


[PATCH 00/18] Resend of usbip-utils migration patches and various other fixes

2014-03-08 Thread Valentina Manea
This is a resend of the patches sent a few days ago, including
the migration of USB/IP userspace side to use libudev instead
of libsysfs and various other fixes, all ordered in a big patch
series.

The patches have been modified according to received feedback.

Valentina Manea (18):
  staging: usbip: userspace: migrate usbip_bind to libudev
  staging: usbip: userspace: remove useless libsysfs includes
  staging: usbip: userspace: migrate usbip_unbind to libudev
  staging: usbip: userspace: migrate usbip_list to libudev
  staging: usbip: userspace: re-add interface information listing
  staging: usbip: userspace: add new list API
  staging: usbip: userspace: move sysfs_utils to libsrc
  staging: usbip: userspace: migrate usbip_host_driver to libudev
  staging: usbip: userspace: remove class device infrastructure in
vhci_driver
  staging: usbip: userspace: migrate vhci_driver to libudev
  staging: usbip: userspace: remove libsysfs flag and autoconf check
  staging: usbip: userspace: update dependencies in README
  staging: usbip: userspace: increase version to 2.0
  staging: usbip: let client choose device configuration
  staging: usbip: trigger driver probing after unbinding from usbip-host
  staging: usbip: claim ports used by shared devices
  staging: usbip: userspace: don't throw error when trying to read
configuration specific attributes
  staging: usbip: userspace: add hwdata as optional dependency in README

 drivers/staging/usbip/stub.h   |   1 +
 drivers/staging/usbip/stub_dev.c   |  33 +-
 drivers/staging/usbip/stub_main.c  |  39 +++
 drivers/staging/usbip/stub_rx.c|  26 +-
 drivers/staging/usbip/userspace/README |   8 +-
 drivers/staging/usbip/userspace/configure.ac   |  12 +-
 drivers/staging/usbip/userspace/libsrc/Makefile.am |   3 +-
 drivers/staging/usbip/userspace/libsrc/list.h  | 136 
 .../staging/usbip/userspace/libsrc/sysfs_utils.c   |  31 ++
 .../staging/usbip/userspace/libsrc/sysfs_utils.h   |   8 +
 .../staging/usbip/userspace/libsrc/usbip_common.c  |  91 +++---
 .../staging/usbip/userspace/libsrc/usbip_common.h  |  15 +-
 .../usbip/userspace/libsrc/usbip_host_driver.c | 285 +
 .../usbip/userspace/libsrc/usbip_host_driver.h |   7 +-
 .../staging/usbip/userspace/libsrc/vhci_driver.c   | 346 -
 .../staging/usbip/userspace/libsrc/vhci_driver.h   |  14 +-
 drivers/staging/usbip/userspace/src/Makefile.am|   1 -
 drivers/staging/usbip/userspace/src/usbip_attach.c |   1 -
 drivers/staging/usbip/userspace/src/usbip_bind.c   | 149 -
 drivers/staging/usbip/userspace/src/usbip_detach.c |   2 -
 drivers/staging/usbip/userspace/src/usbip_list.c   | 153 -
 .../staging/usbip/userspace/src/usbip_network.h|   1 -
 drivers/staging/usbip/userspace/src/usbip_unbind.c | 110 +++
 drivers/staging/usbip/userspace/src/usbipd.c   |  30 +-
 drivers/staging/usbip/userspace/src/utils.c|  48 +--
 drivers/usb/core/hub.c |   2 +
 drivers/usb/core/usb.h |   4 -
 include/linux/usb.h|   7 +
 28 files changed, 676 insertions(+), 887 deletions(-)
 create mode 100644 drivers/staging/usbip/userspace/libsrc/list.h
 create mode 100644 drivers/staging/usbip/userspace/libsrc/sysfs_utils.c
 create mode 100644 drivers/staging/usbip/userspace/libsrc/sysfs_utils.h

-- 
1.8.1.2

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


[PATCH v2] staging: usbip: claim ports used by shared devices

2014-03-05 Thread Valentina Manea
A device should not be able to be used concurrently both by
the server and the client. Claiming the port used by the
shared device ensures no interface drivers bind to it and
that it is not usable from the server.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
Changes since v1:
* add commit description
* move struct dev_state definition back to usb/core/devio.c

 drivers/staging/usbip/stub_dev.c | 22 ++
 drivers/usb/core/hub.c   |  2 ++
 drivers/usb/core/usb.h   |  4 
 include/linux/usb.h  |  7 +++
 4 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index ee899f0..952743c 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -339,6 +339,7 @@ static int stub_probe(struct usb_device *udev)
const char *udev_busid = dev_name(udev-dev);
int err = 0;
struct bus_id_priv *busid_priv;
+   int rc;
 
dev_dbg(udev-dev, Enter\n);
 
@@ -388,6 +389,18 @@ static int stub_probe(struct usb_device *udev)
busid_priv-sdev = sdev;
busid_priv-udev = udev;
 
+   /*
+* Claim this hub port.
+* It doesn't matter what value we pass as owner
+* (struct dev_state) as long as it is unique.
+*/
+   rc = usb_hub_claim_port(udev-parent, udev-portnum,
+   (struct dev_state *) udev);
+   if (rc) {
+   dev_dbg(udev-dev, unable to claim port\n);
+   return rc;
+   }
+
err = stub_add_files(udev-dev);
if (err) {
dev_err(udev-dev, stub_add_files for %s\n, udev_busid);
@@ -424,6 +437,7 @@ static void stub_disconnect(struct usb_device *udev)
struct stub_device *sdev;
const char *udev_busid = dev_name(udev-dev);
struct bus_id_priv *busid_priv;
+   int rc;
 
dev_dbg(udev-dev, Enter\n);
 
@@ -448,6 +462,14 @@ static void stub_disconnect(struct usb_device *udev)
 */
stub_remove_files(udev-dev);
 
+   /* release port */
+   rc = usb_hub_release_port(udev-parent, udev-portnum,
+ (struct dev_state *) udev);
+   if (rc) {
+   dev_dbg(udev-dev, unable to release port\n);
+   return;
+   }
+
/* If usb reset is called from event handler */
if (busid_priv-sdev-ud.eh == current)
return;
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 64ea219..e484933 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1819,6 +1819,7 @@ int usb_hub_claim_port(struct usb_device *hdev, unsigned 
port1,
*powner = owner;
return rc;
 }
+EXPORT_SYMBOL_GPL(usb_hub_claim_port);
 
 int usb_hub_release_port(struct usb_device *hdev, unsigned port1,
 struct dev_state *owner)
@@ -1834,6 +1835,7 @@ int usb_hub_release_port(struct usb_device *hdev, 
unsigned port1,
*powner = NULL;
return rc;
 }
+EXPORT_SYMBOL_GPL(usb_hub_release_port);
 
 void usb_hub_release_all_ports(struct usb_device *hdev, struct dev_state 
*owner)
 {
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 8238577..222bbd2 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -57,10 +57,6 @@ extern int usb_match_device(struct usb_device *dev,
 extern void usb_forced_unbind_intf(struct usb_interface *intf);
 extern void usb_rebind_intf(struct usb_interface *intf);
 
-extern int usb_hub_claim_port(struct usb_device *hdev, unsigned port,
-   struct dev_state *owner);
-extern int usb_hub_release_port(struct usb_device *hdev, unsigned port,
-   struct dev_state *owner);
 extern void usb_hub_release_all_ports(struct usb_device *hdev,
struct dev_state *owner);
 extern bool usb_device_is_owned(struct usb_device *udev);
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 22de4af..140a6a3 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -366,6 +366,8 @@ struct usb_bus {
 #endif
 };
 
+struct dev_state;
+
 /* --- */
 
 struct usb_tt;
@@ -749,6 +751,11 @@ extern struct usb_host_interface *usb_find_alt_setting(
unsigned int iface_num,
unsigned int alt_num);
 
+/* port claiming functions */
+int usb_hub_claim_port(struct usb_device *hdev, unsigned port1,
+   struct dev_state *owner);
+int usb_hub_release_port(struct usb_device *hdev, unsigned port1,
+   struct dev_state *owner);
 
 /**
  * usb_make_path - returns stable device path in the usb tree
-- 
1.8.1.2

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


Re: [PATCH 01/12] staging: usbip: userspace: migrate usbip_bind to libudev

2014-03-05 Thread Valentina Manea
On Wed, Mar 5, 2014 at 12:15 PM, Dan Carpenter dan.carpen...@oracle.com wrote:
 On Wed, Mar 05, 2014 at 12:42:59PM +0300, Dan Carpenter wrote:
 On Tue, Mar 04, 2014 at 09:10:41PM +0200, Valentina Manea wrote:
  diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.h 
  b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
  index 2cb81b3..565ac78 100644
  --- a/drivers/staging/usbip/userspace/libsrc/usbip_common.h
  +++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
  @@ -29,6 +29,15 @@
   #define USBIP_HOST_DRV_NAMEusbip-host
   #define USBIP_VHCI_DRV_NAMEvhci_hcd
 
  +/* sysfs constants */
  +#define SYSFS_MNT_PATH /sys
  +#define SYSFS_BUS_NAME bus
  +#define SYSFS_BUS_TYPE usb
  +#define SYSFS_DRIVERS_NAME drivers

 What on earth???  I don't even want to review any further than this.

 Groan  No.  no no no no no.


 I overreacted.  This stuff was already in the original code, and this
 change just moves it around.

 Fine fine.  These patch set seem ok with me.

 regards,
 dan carpenter



Indeed, there are improvements than can be made to the code but
I figured doing them all in just one patch series would be a step too big.
This should be work for future patches.

Thanks for your feedback.

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


Re: [PATCH] staging: usbip: userspace: increase version to 2.0

2014-03-05 Thread Valentina Manea
On Tue, Mar 4, 2014 at 9:20 PM, Greg KH gre...@linuxfoundation.org wrote:
 On Tue, Mar 04, 2014 at 09:16:39PM +0200, Valentina Manea wrote:
 Signed-off-by: Valentina Manea valentina.mane...@gmail.com
 ---
  drivers/staging/usbip/userspace/configure.ac | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/drivers/staging/usbip/userspace/configure.ac 
 b/drivers/staging/usbip/userspace/configure.ac
 index 25bf160..607d05c 100644
 --- a/drivers/staging/usbip/userspace/configure.ac
 +++ b/drivers/staging/usbip/userspace/configure.ac
 @@ -1,7 +1,7 @@
  dnl Process this file with autoconf to produce a configure script.

  AC_PREREQ(2.59)
 -AC_INIT([usbip-utils], [1.1.1], [linux-usb@vger.kernel.org])
 +AC_INIT([usbip-utils], [2.0], [linux-usb@vger.kernel.org])

 Why?

 What does this mean?  What warrents the version change?  Why have a
 version at all?

 thanks,

 greg k-h

This was part of an effort to refresh USB/IP by moving userspace out
of kernel.git.
Since some major changes have been made (libudev migration), Andy (cc'ed) and me
thought it was worth to be promoted to version 2.0.

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


[PATCH 12/12] staging: usbip: userspace: update dependencies in README

2014-03-04 Thread Valentina Manea
Add libudev as dependency and remove libsysfs.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/README | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/usbip/userspace/README 
b/drivers/staging/usbip/userspace/README
index 00a1658..6ead290 100644
--- a/drivers/staging/usbip/userspace/README
+++ b/drivers/staging/usbip/userspace/README
@@ -9,8 +9,8 @@
 - USB/IP device drivers
Found in the staging directory of the Linux kernel.
 
-- sysfsutils = 2.0.0
-   sysfsutils library
+- libudev = 2.0
+   libudev library
 
 - libwrap0-dev
tcp wrapper library
-- 
1.8.1.2

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


[PATCH 06/12] staging: usbip: userspace: add new list API

2014-03-04 Thread Valentina Manea
Add a new list API from CCAN.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/libsrc/Makefile.am |   3 +-
 .../staging/usbip/userspace/libsrc/build_assert.h  |  40 ++
 .../staging/usbip/userspace/libsrc/check_type.h|  64 +++
 .../staging/usbip/userspace/libsrc/container_of.h  | 109 
 drivers/staging/usbip/userspace/libsrc/list.c  |  43 ++
 drivers/staging/usbip/userspace/libsrc/list.h  | 613 +
 6 files changed, 871 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/usbip/userspace/libsrc/build_assert.h
 create mode 100644 drivers/staging/usbip/userspace/libsrc/check_type.h
 create mode 100644 drivers/staging/usbip/userspace/libsrc/container_of.h
 create mode 100644 drivers/staging/usbip/userspace/libsrc/list.c
 create mode 100644 drivers/staging/usbip/userspace/libsrc/list.h

diff --git a/drivers/staging/usbip/userspace/libsrc/Makefile.am 
b/drivers/staging/usbip/userspace/libsrc/Makefile.am
index 4921189..294270b 100644
--- a/drivers/staging/usbip/userspace/libsrc/Makefile.am
+++ b/drivers/staging/usbip/userspace/libsrc/Makefile.am
@@ -4,4 +4,5 @@ libusbip_la_LDFLAGS  = -version-info @LIBUSBIP_VERSION@
 
 lib_LTLIBRARIES := libusbip.la
 libusbip_la_SOURCES := names.c names.h usbip_host_driver.c usbip_host_driver.h 
\
-  usbip_common.c usbip_common.h vhci_driver.c vhci_driver.h
+  usbip_common.c usbip_common.h vhci_driver.c 
vhci_driver.h \
+  list.c list.h build_assert.h check_type.h container_of.h
diff --git a/drivers/staging/usbip/userspace/libsrc/build_assert.h 
b/drivers/staging/usbip/userspace/libsrc/build_assert.h
new file mode 100644
index 000..b9ecd84
--- /dev/null
+++ b/drivers/staging/usbip/userspace/libsrc/build_assert.h
@@ -0,0 +1,40 @@
+/* CC0 (Public domain) - see LICENSE file for details */
+#ifndef CCAN_BUILD_ASSERT_H
+#define CCAN_BUILD_ASSERT_H
+
+/**
+ * BUILD_ASSERT - assert a build-time dependency.
+ * @cond: the compile-time condition which must be true.
+ *
+ * Your compile will fail if the condition isn't true, or can't be evaluated
+ * by the compiler.  This can only be used within a function.
+ *
+ * Example:
+ * #include stddef.h
+ * ...
+ * static char *foo_to_char(struct foo *foo)
+ * {
+ * // This code needs string to be at start of foo.
+ * BUILD_ASSERT(offsetof(struct foo, string) == 0);
+ * return (char *)foo;
+ * }
+ */
+#define BUILD_ASSERT(cond) \
+   do { (void) sizeof(char [1 - 2*!(cond)]); } while(0)
+
+/**
+ * BUILD_ASSERT_OR_ZERO - assert a build-time dependency, as an expression.
+ * @cond: the compile-time condition which must be true.
+ *
+ * Your compile will fail if the condition isn't true, or can't be evaluated
+ * by the compiler.  This can be used in an expression: its value is 0.
+ *
+ * Example:
+ * #define foo_to_char(foo)\
+ *  ((char *)(foo) \
+ *   + BUILD_ASSERT_OR_ZERO(offsetof(struct foo, string) == 0))
+ */
+#define BUILD_ASSERT_OR_ZERO(cond) \
+   (sizeof(char [1 - 2*!(cond)]) - 1)
+
+#endif /* CCAN_BUILD_ASSERT_H */
diff --git a/drivers/staging/usbip/userspace/libsrc/check_type.h 
b/drivers/staging/usbip/userspace/libsrc/check_type.h
new file mode 100644
index 000..a39cc41
--- /dev/null
+++ b/drivers/staging/usbip/userspace/libsrc/check_type.h
@@ -0,0 +1,64 @@
+/* CC0 (Public domain) - see LICENSE file for details */
+#ifndef CCAN_CHECK_TYPE_H
+#define CCAN_CHECK_TYPE_H
+#include config.h
+
+/**
+ * check_type - issue a warning or build failure if type is not correct.
+ * @expr: the expression whose type we should check (not evaluated).
+ * @type: the exact type we expect the expression to be.
+ *
+ * This macro is usually used within other macros to try to ensure that a macro
+ * argument is of the expected type.  No type promotion of the expression is
+ * done: an unsigned int is not the same as an int!
+ *
+ * check_type() always evaluates to 0.
+ *
+ * If your compiler does not support typeof, then the best we can do is fail
+ * to compile if the sizes of the types are unequal (a less complete check).
+ *
+ * Example:
+ * // They should always pass a 64-bit value to _set_some_value!
+ * #define set_some_value(expr)\
+ * _set_some_value((check_type((expr), uint64_t), (expr)))
+ */
+
+/**
+ * check_types_match - issue a warning or build failure if types are not same.
+ * @expr1: the first expression (not evaluated).
+ * @expr2: the second expression (not evaluated).
+ *
+ * This macro is usually used within other macros to try to ensure that
+ * arguments are of identical types.  No type promotion of the expressions is
+ * done: an unsigned int is not the same as an int!
+ *
+ * check_types_match() always evaluates to 0.
+ *
+ * If your compiler does not support typeof

[PATCH 09/12] staging: usbip: userspace: remove class device infrastructure in vhci_driver

2014-03-04 Thread Valentina Manea
The class device lists were used only when being initialized,
being populated and being destroyed. They had no real meaning
and thus the code was useless.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 .../staging/usbip/userspace/libsrc/vhci_driver.c   | 178 -
 .../staging/usbip/userspace/libsrc/vhci_driver.h   |   4 -
 2 files changed, 182 deletions(-)

diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c 
b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
index d5839a5..73a163aa 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
@@ -28,26 +28,6 @@ imported_device_init(struct usbip_imported_device *idev, 
char *busid)
read_usb_device(sudev, idev-udev);
udev_device_unref(sudev);
 
-   /* add class devices of this imported device */
-   struct usbip_class_device *cdev;
-   dlist_for_each_data(vhci_driver-cdev_list, cdev,
-   struct usbip_class_device) {
-   if (!strncmp(cdev-dev_path, idev-udev.path,
-strlen(idev-udev.path))) {
-   struct usbip_class_device *new_cdev;
-   /*
-* alloc and copy because dlist is linked
-* from only one list
-*/
-   new_cdev = calloc(1, sizeof(*new_cdev));
-   if (!new_cdev)
-   goto err;
-
-   memcpy(new_cdev, cdev, sizeof(*new_cdev));
-   dlist_unshift(idev-cdev_list, (void *) new_cdev);
-   }
-   }
-
return idev;
 
 err:
@@ -103,12 +83,6 @@ static int parse_status(char *value)
idev-busnum= (devid  16);
idev-devnum= (devid  0x);
 
-   idev-cdev_list = dlist_new(sizeof(struct 
usbip_class_device));
-   if (!idev-cdev_list) {
-   dbg(dlist_new failed);
-   return -1;
-   }
-
if (idev-status != VDEV_ST_NULL
 idev-status != VDEV_ST_NOTASSIGNED) {
idev = imported_device_init(idev, lbusid);
@@ -132,118 +106,6 @@ static int parse_status(char *value)
return 0;
 }
 
-
-static int check_usbip_device(struct sysfs_class_device *cdev)
-{
-   /* /sys/class/video4linux/video0/device */
-   char class_path[SYSFS_PATH_MAX];
-   /* /sys/devices/platform/vhci_hcd/usb6/6-1:1.1 */
-   char dev_path[SYSFS_PATH_MAX];
-   int ret;
-   struct usbip_class_device *usbip_cdev;
-
-   snprintf(class_path, sizeof(class_path), %s/device, cdev-path);
-
-   ret = sysfs_get_link(class_path, dev_path, sizeof(dev_path));
-   if (ret == 0) {
-   if (!strncmp(dev_path, vhci_driver-hc_device-path,
-strlen(vhci_driver-hc_device-path))) {
-   /* found usbip device */
-   usbip_cdev = calloc(1, sizeof(*usbip_cdev));
-   if (!usbip_cdev) {
-   dbg(calloc failed);
-   return -1;
-   }
-   dlist_unshift(vhci_driver-cdev_list, usbip_cdev);
-   strncpy(usbip_cdev-class_path, class_path,
-   sizeof(usbip_cdev-class_path));
-   strncpy(usbip_cdev-dev_path, dev_path,
-   sizeof(usbip_cdev-dev_path));
-   dbg(found: %s %s, class_path, dev_path);
-   }
-   }
-
-   return 0;
-}
-
-
-static int search_class_for_usbip_device(char *cname)
-{
-   struct sysfs_class *class;
-   struct dlist *cdev_list;
-   struct sysfs_class_device *cdev;
-   int ret = 0;
-
-   class = sysfs_open_class(cname);
-   if (!class) {
-   dbg(sysfs_open_class failed);
-   return -1;
-   }
-
-   dbg(class: %s, class-name);
-
-   cdev_list = sysfs_get_class_devices(class);
-   if (!cdev_list)
-   /* nothing */
-   goto out;
-
-   dlist_for_each_data(cdev_list, cdev, struct sysfs_class_device) {
-   dbg(cdev: %s, cdev-name);
-   ret = check_usbip_device(cdev);
-   if (ret  0)
-   goto out;
-   }
-
-out:
-   sysfs_close_class(class);
-
-   return ret;
-}
-
-
-static int refresh_class_device_list(void)
-{
-   int ret;
-   struct dlist *cname_list;
-   char *cname;
-   char sysfs_mntpath[SYSFS_PATH_MAX];
-   char class_path[SYSFS_PATH_MAX];
-
-   ret = sysfs_get_mnt_path(sysfs_mntpath, SYSFS_PATH_MAX);
-   if (ret  0) {
-   dbg(sysfs_get_mnt_path failed);
-   return -1

[PATCH 08/12] staging: usbip: userspace: migrate usbip_host_driver to libudev

2014-03-04 Thread Valentina Manea
This patch modifies usbip_host_driver to use libudev.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 .../staging/usbip/userspace/libsrc/usbip_common.c  |  74 ++
 .../staging/usbip/userspace/libsrc/usbip_common.h  |   5 +-
 .../usbip/userspace/libsrc/usbip_host_driver.c | 282 ++---
 .../usbip/userspace/libsrc/usbip_host_driver.h |   7 +-
 .../staging/usbip/userspace/libsrc/vhci_driver.c   |  22 +-
 drivers/staging/usbip/userspace/src/usbipd.c   |  10 +-
 6 files changed, 138 insertions(+), 262 deletions(-)

diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.c 
b/drivers/staging/usbip/userspace/libsrc/usbip_common.c
index 6620d18..8d675a9 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.c
+++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.c
@@ -2,6 +2,7 @@
  * Copyright (C) 2005-2007 Takahiro Hirofuchi
  */
 
+#include libudev.h
 #include usbip_common.h
 #include names.h
 
@@ -12,6 +13,8 @@ int usbip_use_syslog;
 int usbip_use_stderr;
 int usbip_use_debug;
 
+extern struct udev *udev_context;
+
 struct speed_string {
int num;
char *speed;
@@ -111,75 +114,48 @@ void dump_usb_device(struct usbip_usb_device *udev)
 }
 
 
-int read_attr_value(struct sysfs_device *dev, const char *name,
+int read_attr_value(struct udev_device *dev, const char *name,
const char *format)
 {
-   char attrpath[SYSFS_PATH_MAX];
-   struct sysfs_attribute *attr;
+   const char *attr;
int num = 0;
int ret;
 
-   snprintf(attrpath, sizeof(attrpath), %s/%s, dev-path, name);
-
-   attr = sysfs_open_attribute(attrpath);
+   attr = udev_device_get_sysattr_value(dev, name);
if (!attr) {
-   dbg(sysfs_open_attribute failed: %s, attrpath);
-   return 0;
-   }
-
-   ret = sysfs_read_attribute(attr);
-   if (ret  0) {
-   dbg(sysfs_read_attribute failed);
+   dbg(udev_device_get_sysattr_value failed);
goto err;
}
 
-   ret = sscanf(attr-value, format, num);
+   ret = sscanf(attr, format, num);
if (ret  1) {
dbg(sscanf failed);
goto err;
}
 
 err:
-   sysfs_close_attribute(attr);
 
return num;
 }
 
 
-int read_attr_speed(struct sysfs_device *dev)
+int read_attr_speed(struct udev_device *dev)
 {
-   char attrpath[SYSFS_PATH_MAX];
-   struct sysfs_attribute *attr;
-   char speed[100];
-   int ret;
+   const char *speed;
 
-   snprintf(attrpath, sizeof(attrpath), %s/%s, dev-path, speed);
-
-   attr = sysfs_open_attribute(attrpath);
-   if (!attr) {
-   dbg(sysfs_open_attribute failed: %s, attrpath);
-   return 0;
-   }
-
-   ret = sysfs_read_attribute(attr);
-   if (ret  0) {
-   dbg(sysfs_read_attribute failed);
+   speed = udev_device_get_sysattr_value(dev, speed);
+   if (!speed) {
+   dbg(udev_device_get_sysattr_value failed);
goto err;
}
 
-   ret = sscanf(attr-value, %99s\n, speed);
-   if (ret  1) {
-   dbg(sscanf failed);
-   goto err;
-   }
-err:
-   sysfs_close_attribute(attr);
-
for (int i = 0; speed_strings[i].speed != NULL; i++) {
if (!strcmp(speed, speed_strings[i].speed))
return speed_strings[i].num;
}
 
+err:
+
return USB_SPEED_UNKNOWN;
 }
 
@@ -190,9 +166,10 @@ err:
} while (0)
 
 
-int read_usb_device(struct sysfs_device *sdev, struct usbip_usb_device *udev)
+int read_usb_device(struct udev_device *sdev, struct usbip_usb_device *udev)
 {
uint32_t busnum, devnum;
+   const char *path, *name;
 
READ_ATTR(udev, uint8_t,  sdev, bDeviceClass,   %02x\n);
READ_ATTR(udev, uint8_t,  sdev, bDeviceSubClass,%02x\n);
@@ -209,10 +186,13 @@ int read_usb_device(struct sysfs_device *sdev, struct 
usbip_usb_device *udev)
READ_ATTR(udev, uint8_t,  sdev, devnum, %d\n);
udev-speed = read_attr_speed(sdev);
 
-   strncpy(udev-path,  sdev-path,  SYSFS_PATH_MAX);
-   strncpy(udev-busid, sdev-name, SYSFS_BUS_ID_SIZE);
+   path = udev_device_get_syspath(sdev);
+   name = udev_device_get_sysname(sdev);
 
-   sscanf(sdev-name, %u-%u, busnum, devnum);
+   strncpy(udev-path,  path,  SYSFS_PATH_MAX);
+   strncpy(udev-busid, name, SYSFS_BUS_ID_SIZE);
+
+   sscanf(name, %u-%u, busnum, devnum);
udev-busnum = busnum;
 
return 0;
@@ -222,13 +202,13 @@ int read_usb_interface(struct usbip_usb_device *udev, int 
i,
   struct usbip_usb_interface *uinf)
 {
char busid[SYSFS_BUS_ID_SIZE];
-   struct sysfs_device *sif;
+   struct udev_device *sif;
 
sprintf(busid, %s:%d.%d, udev-busid, udev-bConfigurationValue, i);
 
-   sif = sysfs_open_device(usb, busid

[PATCH 10/12] staging: usbip: userspace: migrate vhci_driver to libudev

2014-03-04 Thread Valentina Manea
This patch migrates vhci_driver to libudev.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 .../staging/usbip/userspace/libsrc/usbip_common.h  |   1 -
 .../staging/usbip/userspace/libsrc/vhci_driver.c   | 154 ++---
 .../staging/usbip/userspace/libsrc/vhci_driver.h   |   5 +-
 3 files changed, 44 insertions(+), 116 deletions(-)

diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.h 
b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
index 9c11060..c4a72c3 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.h
+++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
@@ -5,7 +5,6 @@
 #ifndef __USBIP_COMMON_H
 #define __USBIP_COMMON_H
 
-#include sysfs/libsysfs.h
 #include libudev.h
 
 #include stdint.h
diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c 
b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
index 73a163aa..e7839a0 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
@@ -7,6 +7,7 @@
 #include limits.h
 #include netdb.h
 #include libudev.h
+#include sysfs_utils.h
 
 #undef  PROGNAME
 #define PROGNAME libusbip
@@ -36,7 +37,7 @@ err:
 
 
 
-static int parse_status(char *value)
+static int parse_status(const char *value)
 {
int ret = 0;
char *c;
@@ -108,42 +109,33 @@ static int parse_status(char *value)
 
 static int refresh_imported_device_list(void)
 {
-   struct sysfs_attribute *attr_status;
+   const char *attr_status;
 
-
-   attr_status = sysfs_get_device_attr(vhci_driver-hc_device, status);
+   attr_status = udev_device_get_sysattr_value(vhci_driver-hc_device,
+  status);
if (!attr_status) {
-   dbg(sysfs_get_device_attr(\status\) failed: %s,
-   vhci_driver-hc_device-name);
+   dbg(udev_device_get_sysattr_value failed);
return -1;
}
 
-   dbg(name: %s  path: %s  len: %d  method: %d  value: %s,
-   attr_status-name, attr_status-path, attr_status-len,
-   attr_status-method, attr_status-value);
-
-   return parse_status(attr_status-value);
+   return parse_status(attr_status);
 }
 
 static int get_nports(void)
 {
char *c;
int nports = 0;
-   struct sysfs_attribute *attr_status;
+   const char *attr_status;
 
-   attr_status = sysfs_get_device_attr(vhci_driver-hc_device, status);
+   attr_status = udev_device_get_sysattr_value(vhci_driver-hc_device,
+  status);
if (!attr_status) {
-   dbg(sysfs_get_device_attr(\status\) failed: %s,
-   vhci_driver-hc_device-name);
+   dbg(udev_device_get_sysattr_value failed);
return -1;
}
 
-   dbg(name: %s  path: %s  len: %d  method: %d  value: %s,
-   attr_status-name, attr_status-path, attr_status-len,
-   attr_status-method, attr_status-value);
-
/* skip a header line */
-   c = strchr(attr_status-value, '\n');
+   c = strchr(attr_status, '\n');
if (!c)
return 0;
c++;
@@ -160,50 +152,6 @@ static int get_nports(void)
return nports;
 }
 
-static int get_hc_busid(char *sysfs_mntpath, char *hc_busid)
-{
-   struct sysfs_driver *sdriver;
-   char sdriver_path[SYSFS_PATH_MAX];
-
-   struct sysfs_device *hc_dev;
-   struct dlist *hc_devs;
-
-   int found = 0;
-
-   snprintf(sdriver_path, SYSFS_PATH_MAX, %s/%s/%s/%s/%s, sysfs_mntpath,
-   SYSFS_BUS_NAME, USBIP_VHCI_BUS_TYPE, SYSFS_DRIVERS_NAME,
-   USBIP_VHCI_DRV_NAME);
-
-   sdriver = sysfs_open_driver_path(sdriver_path);
-   if (!sdriver) {
-   dbg(sysfs_open_driver_path failed: %s, sdriver_path);
-   dbg(make sure  USBIP_CORE_MOD_NAME .ko and 
-   USBIP_VHCI_DRV_NAME .ko are loaded!);
-   return -1;
-   }
-
-   hc_devs = sysfs_get_driver_devices(sdriver);
-   if (!hc_devs) {
-   dbg(sysfs_get_driver failed);
-   goto err;
-   }
-
-   /* assume only one vhci_hcd */
-   dlist_for_each_data(hc_devs, hc_dev, struct sysfs_device) {
-   strncpy(hc_busid, hc_dev-bus_id, SYSFS_BUS_ID_SIZE);
-   found = 1;
-   }
-
-err:
-   sysfs_close_driver(sdriver);
-
-   if (found)
-   return 0;
-
-   dbg(%s not found, hc_busid);
-   return -1;
-}
-
 /*
  * Read the given port's record.
  *
@@ -215,7 +163,6 @@ err:
  */
 static int read_record(int rhport, char *host, unsigned long host_len,
char *port, unsigned long port_len, char *busid)
-
 {
int part;
FILE *file;
@@ -272,36 +219,21 @@ static int read_record(int rhport, char *host, unsigned 
long host_len,
 
 int usbip_vhci_driver_open(void)
 {
-   int ret;
-   char hc_busid[SYSFS_BUS_ID_SIZE

[PATCH 07/12] staging: usbip: userspace: move sysfs_utils to libsrc

2014-03-04 Thread Valentina Manea
Since it offers a API to both usbip tools and libusbip,
it is more appropriate to be place in the library.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/libsrc/Makefile.am |  3 +-
 .../staging/usbip/userspace/libsrc/sysfs_utils.c   | 36 ++
 .../staging/usbip/userspace/libsrc/sysfs_utils.h   |  8 +
 drivers/staging/usbip/userspace/src/Makefile.am|  3 +-
 drivers/staging/usbip/userspace/src/sysfs_utils.c  | 36 --
 drivers/staging/usbip/userspace/src/sysfs_utils.h  |  8 -
 6 files changed, 47 insertions(+), 47 deletions(-)
 create mode 100644 drivers/staging/usbip/userspace/libsrc/sysfs_utils.c
 create mode 100644 drivers/staging/usbip/userspace/libsrc/sysfs_utils.h
 delete mode 100644 drivers/staging/usbip/userspace/src/sysfs_utils.c
 delete mode 100644 drivers/staging/usbip/userspace/src/sysfs_utils.h

diff --git a/drivers/staging/usbip/userspace/libsrc/Makefile.am 
b/drivers/staging/usbip/userspace/libsrc/Makefile.am
index 294270b..b4c7631 100644
--- a/drivers/staging/usbip/userspace/libsrc/Makefile.am
+++ b/drivers/staging/usbip/userspace/libsrc/Makefile.am
@@ -5,4 +5,5 @@ libusbip_la_LDFLAGS  = -version-info @LIBUSBIP_VERSION@
 lib_LTLIBRARIES := libusbip.la
 libusbip_la_SOURCES := names.c names.h usbip_host_driver.c usbip_host_driver.h 
\
   usbip_common.c usbip_common.h vhci_driver.c 
vhci_driver.h \
-  list.c list.h build_assert.h check_type.h container_of.h
+  list.c list.h build_assert.h check_type.h container_of.h 
\
+  sysfs_utils.c sysfs_utils.h
diff --git a/drivers/staging/usbip/userspace/libsrc/sysfs_utils.c 
b/drivers/staging/usbip/userspace/libsrc/sysfs_utils.c
new file mode 100644
index 000..2c362d1
--- /dev/null
+++ b/drivers/staging/usbip/userspace/libsrc/sysfs_utils.c
@@ -0,0 +1,36 @@
+#include sys/types.h
+#include sys/stat.h
+#include fcntl.h
+#include errno.h
+
+#include sysfs_utils.h
+#include usbip_common.h
+
+int write_sysfs_attribute(const char *attr_path, const char *new_value,
+ size_t len)
+{
+   int fd;
+   int length;
+
+   if (attr_path == NULL || new_value == NULL || len == 0) {
+   dbg(Invalid values provided for attribute %s., attr_path);
+   errno = EINVAL;
+   return -1;
+   }
+
+   if ((fd = open(attr_path, O_WRONLY))  0) {
+   dbg(Error opening attribute %s., attr_path);
+   return -1;
+   }
+
+   length = write(fd, new_value, len);
+   if (length  0) {
+   dbg(Error writing to attribute %s., attr_path);
+   close(fd);
+   return -1;
+   }
+
+   close(fd);
+
+   return 0;
+}
diff --git a/drivers/staging/usbip/userspace/libsrc/sysfs_utils.h 
b/drivers/staging/usbip/userspace/libsrc/sysfs_utils.h
new file mode 100644
index 000..32ac1d1
--- /dev/null
+++ b/drivers/staging/usbip/userspace/libsrc/sysfs_utils.h
@@ -0,0 +1,8 @@
+
+#ifndef __SYSFS_UTILS_H
+#define __SYSFS_UTILS_H
+
+int write_sysfs_attribute(const char *attr_path, const char *new_value,
+ size_t len);
+
+#endif
diff --git a/drivers/staging/usbip/userspace/src/Makefile.am 
b/drivers/staging/usbip/userspace/src/Makefile.am
index 6c91bcb..b4f8c4b 100644
--- a/drivers/staging/usbip/userspace/src/Makefile.am
+++ b/drivers/staging/usbip/userspace/src/Makefile.am
@@ -6,8 +6,7 @@ sbin_PROGRAMS := usbip usbipd
 
 usbip_SOURCES := usbip.h utils.h usbip.c utils.c usbip_network.c \
 usbip_attach.c usbip_detach.c usbip_list.c \
-usbip_bind.c usbip_unbind.c usbip_port.c \
-sysfs_utils.c
+usbip_bind.c usbip_unbind.c usbip_port.c
 
 
 usbipd_SOURCES := usbip_network.h usbipd.c usbip_network.c
diff --git a/drivers/staging/usbip/userspace/src/sysfs_utils.c 
b/drivers/staging/usbip/userspace/src/sysfs_utils.c
deleted file mode 100644
index 2c362d1..000
--- a/drivers/staging/usbip/userspace/src/sysfs_utils.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include sys/types.h
-#include sys/stat.h
-#include fcntl.h
-#include errno.h
-
-#include sysfs_utils.h
-#include usbip_common.h
-
-int write_sysfs_attribute(const char *attr_path, const char *new_value,
- size_t len)
-{
-   int fd;
-   int length;
-
-   if (attr_path == NULL || new_value == NULL || len == 0) {
-   dbg(Invalid values provided for attribute %s., attr_path);
-   errno = EINVAL;
-   return -1;
-   }
-
-   if ((fd = open(attr_path, O_WRONLY))  0) {
-   dbg(Error opening attribute %s., attr_path);
-   return -1;
-   }
-
-   length = write(fd, new_value, len);
-   if (length  0) {
-   dbg(Error writing to attribute %s., attr_path);
-   close(fd);
-   return -1;
-   }
-
-   close(fd

[PATCH 03/12] staging: usbip: userspace: migrate usbip_unbind to libudev

2014-03-04 Thread Valentina Manea
This patch modifies usbip_unbind to use libudev.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/src/usbip_unbind.c | 92 +++---
 1 file changed, 29 insertions(+), 63 deletions(-)

diff --git a/drivers/staging/usbip/userspace/src/usbip_unbind.c 
b/drivers/staging/usbip/userspace/src/usbip_unbind.c
index cace878..4776068 100644
--- a/drivers/staging/usbip/userspace/src/usbip_unbind.c
+++ b/drivers/staging/usbip/userspace/src/usbip_unbind.c
@@ -16,7 +16,7 @@
  * along with this program. If not, see http://www.gnu.org/licenses/.
  */
 
-#include sysfs/libsysfs.h
+#include libudev.h
 
 #include errno.h
 #include stdio.h
@@ -27,6 +27,7 @@
 #include usbip_common.h
 #include utils.h
 #include usbip.h
+#include sysfs_utils.h
 
 static const char usbip_unbind_usage_string[] =
usbip unbind args\n
@@ -41,92 +42,57 @@ void usbip_unbind_usage(void)
 static int unbind_device(char *busid)
 {
char bus_type[] = usb;
-   struct sysfs_driver *usbip_host_drv;
-   struct sysfs_device *dev;
-   struct dlist *devlist;
-   int verified = 0;
int rc, ret = -1;
 
char attr_name[] = unbind;
-   char sysfs_mntpath[SYSFS_PATH_MAX];
char unbind_attr_path[SYSFS_PATH_MAX];
-   struct sysfs_attribute *unbind_attr;
-
-   /* verify the busid device is using usbip-host */
-   usbip_host_drv = sysfs_open_driver(bus_type, USBIP_HOST_DRV_NAME);
-   if (!usbip_host_drv) {
-   err(could not open %s driver: %s, USBIP_HOST_DRV_NAME,
-   strerror(errno));
-   return -1;
-   }
 
-   devlist = sysfs_get_driver_devices(usbip_host_drv);
-   if (!devlist) {
-   err(%s is not in use by any devices, USBIP_HOST_DRV_NAME);
-   goto err_close_usbip_host_drv;
-   }
+   struct udev *udev;
+   struct udev_device *dev;
+   const char *driver;
 
-   dlist_for_each_data(devlist, dev, struct sysfs_device) {
-   if (!strncmp(busid, dev-name, strlen(busid)) 
-   !strncmp(dev-driver_name, USBIP_HOST_DRV_NAME,
-strlen(USBIP_HOST_DRV_NAME))) {
-   verified = 1;
-   break;
-   }
-   }
+   /* Create libudev context. */
+   udev = udev_new();
 
-   if (!verified) {
-   err(device on busid %s is not using %s, busid,
-   USBIP_HOST_DRV_NAME);
-   goto err_close_usbip_host_drv;
+   /* Check whether the device with this bus ID exists. */
+   dev = udev_device_new_from_subsystem_sysname(udev, usb, busid);
+   if (!dev) {
+   err(Device with the specified bus ID does not exist.);
+   goto err_close_udev;
}
 
-   /*
-* NOTE: A read and write of an attribute value of the device busid
-* refers to must be done to start probing. That way a rebind of the
-* default driver for the device occurs.
-*
-* This seems very hackish and adds a lot of pointless code. I think it
-* should be done in the kernel by the driver after del_match_busid is
-* finished!
-*/
-
-   rc = sysfs_get_mnt_path(sysfs_mntpath, SYSFS_PATH_MAX);
-   if (rc  0) {
-   err(sysfs must be mounted: %s, strerror(errno));
-   return -1;
+   /* Check whether the device is using usbip-host driver. */
+   driver = udev_device_get_driver(dev);
+   if (!driver || strcmp(driver, usbip-host)) {
+   err(Device is not bound to usbip-host driver.);
+   goto err_close_udev;
}
 
+   /* Unbind device from driver. */
snprintf(unbind_attr_path, sizeof(unbind_attr_path), 
%s/%s/%s/%s/%s/%s,
-sysfs_mntpath, SYSFS_BUS_NAME, bus_type, SYSFS_DRIVERS_NAME,
+SYSFS_MNT_PATH, SYSFS_BUS_NAME, bus_type, SYSFS_DRIVERS_NAME,
 USBIP_HOST_DRV_NAME, attr_name);
+   dbg(unbind attribute path: %s, unbind_attr_path);
 
-   /* read a device attribute */
-   unbind_attr = sysfs_open_attribute(unbind_attr_path);
-   if (!unbind_attr) {
-   err(could not open %s/%s: %s, busid, attr_name,
-   strerror(errno));
-   return -1;
+   rc = write_sysfs_attribute(unbind_attr_path, busid, strlen(busid));
+   if (rc  0) {
+   dbg(Error unbinding device %s from driver., busid);
+   goto err_close_udev;
}
 
-   /* notify driver of unbind */
+   /* Notify driver of unbind. */
rc = modify_match_busid(busid, 0);
if (rc  0) {
err(unable to unbind device on %s, busid);
+   goto err_close_udev;
}
 
-   rc = sysfs_write_attribute(unbind_attr, busid,
-  SYSFS_BUS_ID_SIZE);
-   if (rc  0) {
-   dbg(bind driver at %s failed

[PATCH 02/12] staging: usbip: userspace: remove useless libsysfs includes

2014-03-04 Thread Valentina Manea
This patch removes useless libsysfs.h includes in various
userspace files.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/src/usbip_attach.c  | 1 -
 drivers/staging/usbip/userspace/src/usbip_detach.c  | 2 --
 drivers/staging/usbip/userspace/src/usbip_network.h | 1 -
 3 files changed, 4 deletions(-)

diff --git a/drivers/staging/usbip/userspace/src/usbip_attach.c 
b/drivers/staging/usbip/userspace/src/usbip_attach.c
index 0858411..716a79e 100644
--- a/drivers/staging/usbip/userspace/src/usbip_attach.c
+++ b/drivers/staging/usbip/userspace/src/usbip_attach.c
@@ -17,7 +17,6 @@
  */
 
 #include sys/stat.h
-#include sysfs/libsysfs.h
 
 #include limits.h
 #include stdint.h
diff --git a/drivers/staging/usbip/userspace/src/usbip_detach.c 
b/drivers/staging/usbip/userspace/src/usbip_detach.c
index 13308df..05c6d15 100644
--- a/drivers/staging/usbip/userspace/src/usbip_detach.c
+++ b/drivers/staging/usbip/userspace/src/usbip_detach.c
@@ -16,8 +16,6 @@
  * along with this program. If not, see http://www.gnu.org/licenses/.
  */
 
-#include sysfs/libsysfs.h
-
 #include ctype.h
 #include limits.h
 #include stdint.h
diff --git a/drivers/staging/usbip/userspace/src/usbip_network.h 
b/drivers/staging/usbip/userspace/src/usbip_network.h
index f19ae19..c1e875c 100644
--- a/drivers/staging/usbip/userspace/src/usbip_network.h
+++ b/drivers/staging/usbip/userspace/src/usbip_network.h
@@ -10,7 +10,6 @@
 #endif
 
 #include sys/types.h
-#include sysfs/libsysfs.h
 
 #include stdint.h
 
-- 
1.8.1.2

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


[PATCH 05/12] staging: usbip: userspace: re-add interface information listing

2014-03-04 Thread Valentina Manea
This was deleted in the driver conversion patch. It didn't need
to be deleted; showing more information is ok.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/src/usbip_list.c | 20 +++-
 drivers/staging/usbip/userspace/src/usbipd.c | 16 +++-
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/usbip/userspace/src/usbip_list.c 
b/drivers/staging/usbip/userspace/src/usbip_list.c
index 2255107..7e1820a 100644
--- a/drivers/staging/usbip/userspace/src/usbip_list.c
+++ b/drivers/staging/usbip/userspace/src/usbip_list.c
@@ -52,8 +52,9 @@ static int get_exported_devices(char *host, int sockfd)
struct op_devlist_reply reply;
uint16_t code = OP_REP_DEVLIST;
struct usbip_usb_device udev;
+   struct usbip_usb_interface uintf;
unsigned int i;
-   int rc;
+   int rc, j;
 
rc = usbip_net_send_op_common(sockfd, OP_REQ_DEVLIST, 0);
if (rc  0) {
@@ -103,6 +104,23 @@ static int get_exported_devices(char *host, int sockfd)
printf(%11s: %s\n, , udev.path);
printf(%11s: %s\n, , class_name);
 
+   for (j = 0; j  udev.bNumInterfaces; j++) {
+   rc = usbip_net_recv(sockfd, uintf, sizeof(uintf));
+   if (rc  0) {
+   dbg(usbip_net_recv failed: usbip_usb_intf[%d],
+   j);
+
+   return -1;
+   }
+   usbip_net_pack_usb_interface(0, uintf);
+
+   usbip_names_get_class(class_name, sizeof(class_name),
+   uintf.bInterfaceClass,
+   uintf.bInterfaceSubClass,
+   uintf.bInterfaceProtocol);
+   printf(%11s: %2d - %s\n, , j, class_name);
+   }
+
printf(\n);
}
 
diff --git a/drivers/staging/usbip/userspace/src/usbipd.c 
b/drivers/staging/usbip/userspace/src/usbipd.c
index c2b3ced..b2230f7 100644
--- a/drivers/staging/usbip/userspace/src/usbipd.c
+++ b/drivers/staging/usbip/userspace/src/usbipd.c
@@ -159,8 +159,9 @@ static int send_reply_devlist(int connfd)
 {
struct usbip_exported_device *edev;
struct usbip_usb_device pdu_udev;
+   struct usbip_usb_interface pdu_uinf;
struct op_devlist_reply reply;
-   int rc;
+   int rc, i;
 
reply.ndev = 0;
/* number of exported devices */
@@ -194,6 +195,19 @@ static int send_reply_devlist(int connfd)
dbg(usbip_net_send failed: pdu_udev);
return -1;
}
+
+   for (i = 0; i  edev-udev.bNumInterfaces; i++) {
+   dump_usb_interface(edev-uinf[i]);
+   memcpy(pdu_uinf, edev-uinf[i], sizeof(pdu_uinf));
+   usbip_net_pack_usb_interface(1, pdu_uinf);
+
+   rc = usbip_net_send(connfd, pdu_uinf,
+   sizeof(pdu_uinf));
+   if (rc  0) {
+   dbg(usbip_net_send failed: pdu_uinf);
+   return -1;
+   }
+   }
}
 
return 0;
-- 
1.8.1.2

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


[PATCH 01/12] staging: usbip: userspace: migrate usbip_bind to libudev

2014-03-04 Thread Valentina Manea
This patch adds autoconf check for libudev and migrates
usbip_bind to the new library.

libsysfs will still be used until all userspace is modified.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/configure.ac   |   6 +
 .../staging/usbip/userspace/libsrc/usbip_common.h  |   9 ++
 drivers/staging/usbip/userspace/src/Makefile.am|   3 +-
 drivers/staging/usbip/userspace/src/sysfs_utils.c  |  36 +
 drivers/staging/usbip/userspace/src/sysfs_utils.h  |   8 ++
 drivers/staging/usbip/userspace/src/usbip_bind.c   | 149 +
 drivers/staging/usbip/userspace/src/utils.c|  51 +++
 7 files changed, 136 insertions(+), 126 deletions(-)
 create mode 100644 drivers/staging/usbip/userspace/src/sysfs_utils.c
 create mode 100644 drivers/staging/usbip/userspace/src/sysfs_utils.h

diff --git a/drivers/staging/usbip/userspace/configure.ac 
b/drivers/staging/usbip/userspace/configure.ac
index 0ee5d92..a5193c6 100644
--- a/drivers/staging/usbip/userspace/configure.ac
+++ b/drivers/staging/usbip/userspace/configure.ac
@@ -50,6 +50,12 @@ AC_CHECK_HEADER([sysfs/libsysfs.h],
  [AC_MSG_ERROR([Missing sysfs2 library!])])],
[AC_MSG_ERROR([Missing /usr/include/sysfs/libsysfs.h])])
 
+AC_CHECK_HEADER([libudev.h],
+   [AC_CHECK_LIB([udev], [udev_new],
+ [LIBS=$LIBS -ludev],
+ [AC_MSG_ERROR([Missing udev library!])])],
+   [AC_MSG_ERROR([Missing /usr/include/libudev.h])])
+
 # Checks for libwrap library.
 AC_MSG_CHECKING([whether to use the libwrap (TCP wrappers) library])
 AC_ARG_WITH([tcp-wrappers],
diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.h 
b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
index 2cb81b3..565ac78 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.h
+++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
@@ -29,6 +29,15 @@
 #define USBIP_HOST_DRV_NAMEusbip-host
 #define USBIP_VHCI_DRV_NAMEvhci_hcd
 
+/* sysfs constants */
+#define SYSFS_MNT_PATH /sys
+#define SYSFS_BUS_NAME bus
+#define SYSFS_BUS_TYPE usb
+#define SYSFS_DRIVERS_NAME drivers
+
+#define SYSFS_PATH_MAX 256
+#define SYSFS_BUS_ID_SIZE  32
+
 extern int usbip_use_syslog;
 extern int usbip_use_stderr;
 extern int usbip_use_debug ;
diff --git a/drivers/staging/usbip/userspace/src/Makefile.am 
b/drivers/staging/usbip/userspace/src/Makefile.am
index b4f8c4b..6c91bcb 100644
--- a/drivers/staging/usbip/userspace/src/Makefile.am
+++ b/drivers/staging/usbip/userspace/src/Makefile.am
@@ -6,7 +6,8 @@ sbin_PROGRAMS := usbip usbipd
 
 usbip_SOURCES := usbip.h utils.h usbip.c utils.c usbip_network.c \
 usbip_attach.c usbip_detach.c usbip_list.c \
-usbip_bind.c usbip_unbind.c usbip_port.c
+usbip_bind.c usbip_unbind.c usbip_port.c \
+sysfs_utils.c
 
 
 usbipd_SOURCES := usbip_network.h usbipd.c usbip_network.c
diff --git a/drivers/staging/usbip/userspace/src/sysfs_utils.c 
b/drivers/staging/usbip/userspace/src/sysfs_utils.c
new file mode 100644
index 000..2c362d1
--- /dev/null
+++ b/drivers/staging/usbip/userspace/src/sysfs_utils.c
@@ -0,0 +1,36 @@
+#include sys/types.h
+#include sys/stat.h
+#include fcntl.h
+#include errno.h
+
+#include sysfs_utils.h
+#include usbip_common.h
+
+int write_sysfs_attribute(const char *attr_path, const char *new_value,
+ size_t len)
+{
+   int fd;
+   int length;
+
+   if (attr_path == NULL || new_value == NULL || len == 0) {
+   dbg(Invalid values provided for attribute %s., attr_path);
+   errno = EINVAL;
+   return -1;
+   }
+
+   if ((fd = open(attr_path, O_WRONLY))  0) {
+   dbg(Error opening attribute %s., attr_path);
+   return -1;
+   }
+
+   length = write(fd, new_value, len);
+   if (length  0) {
+   dbg(Error writing to attribute %s., attr_path);
+   close(fd);
+   return -1;
+   }
+
+   close(fd);
+
+   return 0;
+}
diff --git a/drivers/staging/usbip/userspace/src/sysfs_utils.h 
b/drivers/staging/usbip/userspace/src/sysfs_utils.h
new file mode 100644
index 000..32ac1d1
--- /dev/null
+++ b/drivers/staging/usbip/userspace/src/sysfs_utils.h
@@ -0,0 +1,8 @@
+
+#ifndef __SYSFS_UTILS_H
+#define __SYSFS_UTILS_H
+
+int write_sysfs_attribute(const char *attr_path, const char *new_value,
+ size_t len);
+
+#endif
diff --git a/drivers/staging/usbip/userspace/src/usbip_bind.c 
b/drivers/staging/usbip/userspace/src/usbip_bind.c
index 8cfd2db..d122089 100644
--- a/drivers/staging/usbip/userspace/src/usbip_bind.c
+++ b/drivers/staging/usbip/userspace/src/usbip_bind.c
@@ -16,7 +16,7 @@
  * along with this program. If not, see http://www.gnu.org/licenses/.
  */
 
-#include sysfs/libsysfs.h

[PATCH 04/12] staging: usbip: userspace: migrate usbip_list to libudev

2014-03-04 Thread Valentina Manea
This patch modifies usbip_list to use libudev.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/src/usbip_list.c | 137 +--
 1 file changed, 51 insertions(+), 86 deletions(-)

diff --git a/drivers/staging/usbip/userspace/src/usbip_list.c 
b/drivers/staging/usbip/userspace/src/usbip_list.c
index 8864fa2..2255107 100644
--- a/drivers/staging/usbip/userspace/src/usbip_list.c
+++ b/drivers/staging/usbip/userspace/src/usbip_list.c
@@ -17,7 +17,7 @@
  */
 
 #include sys/types.h
-#include sysfs/libsysfs.h
+#include libudev.h
 
 #include errno.h
 #include stdbool.h
@@ -133,8 +133,8 @@ static int list_exported_devices(char *host)
return 0;
 }
 
-static void print_device(char *busid, char *vendor, char *product,
-bool parsable)
+static void print_device(const char *busid, const char *vendor,
+const char *product, bool parsable)
 {
if (parsable)
printf(busid=%s#usbid=%.4s:%.4s#, busid, vendor, product);
@@ -148,106 +148,71 @@ static void print_product_name(char *product_name, bool 
parsable)
printf(   %s\n, product_name);
 }
 
-static void print_interface(char *busid, char *driver, bool parsable)
-{
-   if (parsable)
-   printf(%s=%s#, busid, driver);
-   else
-   printf(%9s%s - %s\n, , busid, driver);
-}
-
-static int is_device(void *x)
-{
-   struct sysfs_attribute *devpath;
-   struct sysfs_device *dev = x;
-   int ret = 0;
-
-   devpath = sysfs_get_device_attr(dev, devpath);
-   if (devpath  *devpath-value != '0')
-   ret = 1;
-
-   return ret;
-}
-
-static int devcmp(void *a, void *b)
-{
-   return strcmp(a, b);
-}
-
 static int list_devices(bool parsable)
 {
-   char bus_type[] = usb;
-   char busid[SYSFS_BUS_ID_SIZE];
+   struct udev *udev;
+   struct udev_enumerate *enumerate;
+   struct udev_list_entry *devices, *dev_list_entry;
+   struct udev_device *dev;
+   const char *path;
+   const char *idVendor;
+   const char *idProduct;
+   const char *bConfValue;
+   const char *bNumIntfs;
+   const char *busid;
char product_name[128];
-   struct sysfs_bus *ubus;
-   struct sysfs_device *dev;
-   struct sysfs_device *intf;
-   struct sysfs_attribute *idVendor;
-   struct sysfs_attribute *idProduct;
-   struct sysfs_attribute *bConfValue;
-   struct sysfs_attribute *bNumIntfs;
-   struct dlist *devlist;
-   int i;
int ret = -1;
 
-   ubus = sysfs_open_bus(bus_type);
-   if (!ubus) {
-   err(could not open %s bus: %s, bus_type, strerror(errno));
-   return -1;
-   }
-
-   devlist = sysfs_get_bus_devices(ubus);
-   if (!devlist) {
-   err(could not get %s bus devices: %s, bus_type,
-   strerror(errno));
-   goto err_out;
-   }
-
-   /* remove interfaces and root hubs from device list */
-   dlist_filter_sort(devlist, is_device, devcmp);
-
-   if (!parsable) {
-   printf(Local USB devices\n);
-   printf(=\n);
-   }
-   dlist_for_each_data(devlist, dev, struct sysfs_device) {
-   idVendor   = sysfs_get_device_attr(dev, idVendor);
-   idProduct  = sysfs_get_device_attr(dev, idProduct);
-   bConfValue = sysfs_get_device_attr(dev, bConfigurationValue);
-   bNumIntfs  = sysfs_get_device_attr(dev, bNumInterfaces);
+   /* Create libudev context. */
+   udev = udev_new();
+
+   /* Create libudev device enumeration. */
+   enumerate = udev_enumerate_new(udev);
+
+   /* Take only USB devices that are not hubs and do not have
+* the bInterfaceNumber attribute, i.e. are not interfaces.
+*/
+   udev_enumerate_add_match_subsystem(enumerate, usb);
+   udev_enumerate_add_nomatch_sysattr(enumerate, bDeviceClass, 09);
+   udev_enumerate_add_nomatch_sysattr(enumerate, bInterfaceNumber, NULL);
+   udev_enumerate_scan_devices(enumerate);
+
+   devices = udev_enumerate_get_list_entry(enumerate);
+
+   /* Show information about each device. */
+   udev_list_entry_foreach(dev_list_entry, devices) {
+   path = udev_list_entry_get_name(dev_list_entry);
+   dev = udev_device_new_from_syspath(udev, path);
+
+   /* Get device information. */
+   idVendor = udev_device_get_sysattr_value(dev, idVendor);
+   idProduct = udev_device_get_sysattr_value(dev, idProduct);
+   bConfValue = udev_device_get_sysattr_value(dev, 
bConfigurationValue);
+   bNumIntfs = udev_device_get_sysattr_value(dev, 
bNumInterfaces);
+   busid = udev_device_get_sysname(dev);
if (!idVendor || !idProduct || !bConfValue || !bNumIntfs) {
-   err(problem getting

[PATCH] staging: usbip: userspace: increase version to 2.0

2014-03-04 Thread Valentina Manea
Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/usbip/userspace/configure.ac 
b/drivers/staging/usbip/userspace/configure.ac
index 25bf160..607d05c 100644
--- a/drivers/staging/usbip/userspace/configure.ac
+++ b/drivers/staging/usbip/userspace/configure.ac
@@ -1,7 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.59)
-AC_INIT([usbip-utils], [1.1.1], [linux-usb@vger.kernel.org])
+AC_INIT([usbip-utils], [2.0], [linux-usb@vger.kernel.org])
 AC_DEFINE([USBIP_VERSION], [0x0111], [binary-coded decimal version number])
 
 CURRENT=0
-- 
1.8.1.2

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


[PATCH] staging: usbip: let client choose device configuration

2014-03-04 Thread Valentina Manea
Since usbip-host is now a device driver and the client
has full access to the shared device, it makes sense to
let the client choose device configuration.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/stub_dev.c | 10 +-
 drivers/staging/usbip/stub_rx.c  | 26 +++---
 2 files changed, 8 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index 60a3e3f..1bd13cf 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -337,7 +337,7 @@ static int stub_probe(struct usb_device *udev)
 {
struct stub_device *sdev = NULL;
const char *udev_busid = dev_name(udev-dev);
-   int err = 0, config;
+   int err = 0;
struct bus_id_priv *busid_priv;
 
dev_dbg(udev-dev, Enter\n);
@@ -383,14 +383,6 @@ static int stub_probe(struct usb_device *udev)
 
busid_priv-shutdown_busid = 0;
 
-   config = usb_choose_configuration(udev);
-   if (config = 0) {
-   err = usb_set_configuration(udev, config);
-   if (err  err != -ENODEV)
-   dev_err(udev-dev, can't set config #%d, error %d\n,
-   config, err);
-   }
-
/* set private data to usb_device */
dev_set_drvdata(udev-dev, sdev);
busid_priv-sdev = sdev;
diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/staging/usbip/stub_rx.c
index 76e44d9..e0b6d6b 100644
--- a/drivers/staging/usbip/stub_rx.c
+++ b/drivers/staging/usbip/stub_rx.c
@@ -142,31 +142,19 @@ static int tweak_set_interface_cmd(struct urb *urb)
 
 static int tweak_set_configuration_cmd(struct urb *urb)
 {
+   struct stub_priv *priv = (struct stub_priv *) urb-context;
+   struct stub_device *sdev = priv-sdev;
struct usb_ctrlrequest *req;
__u16 config;
+   int err;
 
req = (struct usb_ctrlrequest *) urb-setup_packet;
config = le16_to_cpu(req-wValue);
 
-   /*
-* I have never seen a multi-config device. Very rare.
-* For most devices, this will be called to choose a default
-* configuration only once in an initialization phase.
-*
-* set_configuration may change a device configuration and its device
-* drivers will be unbound and assigned for a new device configuration.
-* This means this usbip driver will be also unbound when called, then
-* eventually reassigned to the device as far as driver matching
-* condition is kept.
-*
-* Unfortunately, an existing usbip connection will be dropped
-* due to this driver unbinding. So, skip here.
-* A user may need to set a special configuration value before
-* exporting the device.
-*/
-   dev_info(urb-dev-dev, usb_set_configuration %d to %s... skip!\n,
-config, dev_name(urb-dev-dev));
-
+   err = usb_set_configuration(sdev-udev, config);
+   if (err  err != -ENODEV)
+   dev_err(sdev-udev-dev, can't set config #%d, error %d\n,
+   config, err);
return 0;
 }
 
-- 
1.8.1.2

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


[PATCH] staging: usbip: trigger driver probing after unbinding from usbip-host

2014-03-04 Thread Valentina Manea
A sysfs attribute is used to announce kernel space that a
new driver probing session should be triggered for the just
unbinded device.

In order to have the address of struct device associated to this
USB device, a new member has been added to struct bus_id_priv.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/stub.h   |  1 +
 drivers/staging/usbip/stub_dev.c   |  1 +
 drivers/staging/usbip/stub_main.c  | 39 ++
 drivers/staging/usbip/userspace/src/usbip_unbind.c | 18 --
 4 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/usbip/stub.h b/drivers/staging/usbip/stub.h
index 82e539a..266e2b0 100644
--- a/drivers/staging/usbip/stub.h
+++ b/drivers/staging/usbip/stub.h
@@ -86,6 +86,7 @@ struct bus_id_priv {
char status;
int interf_count;
struct stub_device *sdev;
+   struct usb_device *udev;
char shutdown_busid;
 };
 
diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index 1bd13cf..ee899f0 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -386,6 +386,7 @@ static int stub_probe(struct usb_device *udev)
/* set private data to usb_device */
dev_set_drvdata(udev-dev, sdev);
busid_priv-sdev = sdev;
+   busid_priv-udev = udev;
 
err = stub_add_files(udev-dev);
if (err) {
diff --git a/drivers/staging/usbip/stub_main.c 
b/drivers/staging/usbip/stub_main.c
index bd7b83a..9c5832a 100644
--- a/drivers/staging/usbip/stub_main.c
+++ b/drivers/staging/usbip/stub_main.c
@@ -19,6 +19,7 @@
 
 #include linux/string.h
 #include linux/module.h
+#include linux/device.h
 
 #include usbip_common.h
 #include stub.h
@@ -187,6 +188,34 @@ static ssize_t store_match_busid(struct device_driver 
*dev, const char *buf,
 static DRIVER_ATTR(match_busid, S_IRUSR | S_IWUSR, show_match_busid,
   store_match_busid);
 
+static ssize_t rebind_store(struct device_driver *dev, const char *buf,
+size_t count)
+{
+   int ret;
+   int len;
+   struct bus_id_priv *bid;
+
+   /* buf length should be less that BUSID_SIZE */
+   len = strnlen(buf, BUSID_SIZE);
+
+   if (!(len  BUSID_SIZE))
+   return -EINVAL;
+
+   bid = get_busid_priv(buf);
+   if (!bid)
+   return -ENODEV;
+
+   ret = device_attach(bid-udev-dev);
+   if (ret  0) {
+   dev_err(bid-udev-dev, rebind failed\n);
+   return ret;
+   }
+
+   return count;
+}
+
+static DRIVER_ATTR_WO(rebind);
+
 static struct stub_priv *stub_priv_pop_from_listhead(struct list_head 
*listhead)
 {
struct stub_priv *priv, *tmp;
@@ -267,6 +296,13 @@ static int __init usbip_host_init(void)
goto err_create_file;
}
 
+   ret = driver_create_file(stub_driver.drvwrap.driver,
+driver_attr_rebind);
+   if (ret) {
+   pr_err(driver_create_file failed\n);
+   goto err_create_file;
+   }
+
pr_info(DRIVER_DESC  v USBIP_VERSION \n);
return ret;
 
@@ -282,6 +318,9 @@ static void __exit usbip_host_exit(void)
driver_remove_file(stub_driver.drvwrap.driver,
   driver_attr_match_busid);
 
+   driver_remove_file(stub_driver.drvwrap.driver,
+  driver_attr_rebind);
+
/*
 * deregister() calls stub_disconnect() for all devices. Device
 * specific data is cleared in stub_disconnect().
diff --git a/drivers/staging/usbip/userspace/src/usbip_unbind.c 
b/drivers/staging/usbip/userspace/src/usbip_unbind.c
index 4776068..ba0a563 100644
--- a/drivers/staging/usbip/userspace/src/usbip_unbind.c
+++ b/drivers/staging/usbip/userspace/src/usbip_unbind.c
@@ -44,8 +44,10 @@ static int unbind_device(char *busid)
char bus_type[] = usb;
int rc, ret = -1;
 
-   char attr_name[] = unbind;
+   char unbind_attr_name[] = unbind;
char unbind_attr_path[SYSFS_PATH_MAX];
+   char rebind_attr_name[] = rebind;
+   char rebind_attr_path[SYSFS_PATH_MAX];
 
struct udev *udev;
struct udev_device *dev;
@@ -71,7 +73,7 @@ static int unbind_device(char *busid)
/* Unbind device from driver. */
snprintf(unbind_attr_path, sizeof(unbind_attr_path), 
%s/%s/%s/%s/%s/%s,
 SYSFS_MNT_PATH, SYSFS_BUS_NAME, bus_type, SYSFS_DRIVERS_NAME,
-USBIP_HOST_DRV_NAME, attr_name);
+USBIP_HOST_DRV_NAME, unbind_attr_name);
dbg(unbind attribute path: %s, unbind_attr_path);
 
rc = write_sysfs_attribute(unbind_attr_path, busid, strlen(busid));
@@ -87,6 +89,18 @@ static int unbind_device(char *busid)
goto err_close_udev;
}
 
+   /* Trigger new probing. */
+   snprintf(rebind_attr_path, sizeof(unbind_attr_path

[PATCH] staging: usbip: claim ports used by shared devices

2014-03-04 Thread Valentina Manea
Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/stub_dev.c | 22 ++
 drivers/usb/core/devio.c | 17 -
 drivers/usb/core/hub.c   |  2 ++
 drivers/usb/core/usb.h   |  6 +-
 include/linux/usb.h  | 23 +++
 5 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index ee899f0..952743c 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -339,6 +339,7 @@ static int stub_probe(struct usb_device *udev)
const char *udev_busid = dev_name(udev-dev);
int err = 0;
struct bus_id_priv *busid_priv;
+   int rc;
 
dev_dbg(udev-dev, Enter\n);
 
@@ -388,6 +389,18 @@ static int stub_probe(struct usb_device *udev)
busid_priv-sdev = sdev;
busid_priv-udev = udev;
 
+   /*
+* Claim this hub port.
+* It doesn't matter what value we pass as owner
+* (struct dev_state) as long as it is unique.
+*/
+   rc = usb_hub_claim_port(udev-parent, udev-portnum,
+   (struct dev_state *) udev);
+   if (rc) {
+   dev_dbg(udev-dev, unable to claim port\n);
+   return rc;
+   }
+
err = stub_add_files(udev-dev);
if (err) {
dev_err(udev-dev, stub_add_files for %s\n, udev_busid);
@@ -424,6 +437,7 @@ static void stub_disconnect(struct usb_device *udev)
struct stub_device *sdev;
const char *udev_busid = dev_name(udev-dev);
struct bus_id_priv *busid_priv;
+   int rc;
 
dev_dbg(udev-dev, Enter\n);
 
@@ -448,6 +462,14 @@ static void stub_disconnect(struct usb_device *udev)
 */
stub_remove_files(udev-dev);
 
+   /* release port */
+   rc = usb_hub_release_port(udev-parent, udev-portnum,
+ (struct dev_state *) udev);
+   if (rc) {
+   dev_dbg(udev-dev, unable to release port\n);
+   return;
+   }
+
/* If usb reset is called from event handler */
if (busid_priv-sdev-ud.eh == current)
return;
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 90e18f6..a91dc1f 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -62,23 +62,6 @@
 /* Mutual exclusion for removal, open, and release */
 DEFINE_MUTEX(usbfs_mutex);
 
-struct dev_state {
-   struct list_head list;  /* state list */
-   struct usb_device *dev;
-   struct file *file;
-   spinlock_t lock;/* protects the async urb lists */
-   struct list_head async_pending;
-   struct list_head async_completed;
-   wait_queue_head_t wait; /* wake up if a request completed */
-   unsigned int discsignr;
-   struct pid *disc_pid;
-   const struct cred *cred;
-   void __user *disccontext;
-   unsigned long ifclaimed;
-   u32 secid;
-   u32 disabled_bulk_eps;
-};
-
 struct async {
struct list_head asynclist;
struct dev_state *ps;
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 64ea219..e484933 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1819,6 +1819,7 @@ int usb_hub_claim_port(struct usb_device *hdev, unsigned 
port1,
*powner = owner;
return rc;
 }
+EXPORT_SYMBOL_GPL(usb_hub_claim_port);
 
 int usb_hub_release_port(struct usb_device *hdev, unsigned port1,
 struct dev_state *owner)
@@ -1834,6 +1835,7 @@ int usb_hub_release_port(struct usb_device *hdev, 
unsigned port1,
*powner = NULL;
return rc;
 }
+EXPORT_SYMBOL_GPL(usb_hub_release_port);
 
 void usb_hub_release_all_ports(struct usb_device *hdev, struct dev_state 
*owner)
 {
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 8238577..79a5e76 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -1,8 +1,8 @@
 #include linux/pm.h
 #include linux/acpi.h
+#include linux/usb.h
 
 struct usb_hub_descriptor;
-struct dev_state;
 
 /* Functions local to drivers/usb/core/ */
 
@@ -57,10 +57,6 @@ extern int usb_match_device(struct usb_device *dev,
 extern void usb_forced_unbind_intf(struct usb_interface *intf);
 extern void usb_rebind_intf(struct usb_interface *intf);
 
-extern int usb_hub_claim_port(struct usb_device *hdev, unsigned port,
-   struct dev_state *owner);
-extern int usb_hub_release_port(struct usb_device *hdev, unsigned port,
-   struct dev_state *owner);
 extern void usb_hub_release_all_ports(struct usb_device *hdev,
struct dev_state *owner);
 extern bool usb_device_is_owned(struct usb_device *udev);
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 22de4af..e0843a4 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -366,6 +366,24 @@ struct usb_bus {
 #endif
 };
 
+struct dev_state

[PATCH] staging: usbip: userspace: don't throw error when trying to read configuration specific attributes

2014-03-04 Thread Valentina Manea
When a device has just been bound to usbip-host but the client hasn't
set a configuration on it, certain attributes will not exist. Don't
treat this as an error.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/libsrc/usbip_common.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.c 
b/drivers/staging/usbip/userspace/libsrc/usbip_common.c
index 8d675a9..ac32a36 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.c
+++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.c
@@ -127,10 +127,23 @@ int read_attr_value(struct udev_device *dev, const char 
*name,
goto err;
}
 
+   /* The client chooses the device configuration
+* when attaching it so right after being bound
+* to usbip-host on the server the device will
+* have no configuration.
+* Therefore, attributes such as bConfigurationValue
+* and bNumInterfaces will not exist and sscanf will
+* fail. Check for these cases and don't treat them
+* as errors.
+*/
+
ret = sscanf(attr, format, num);
if (ret  1) {
-   dbg(sscanf failed);
-   goto err;
+   if (strcmp(name, bConfigurationValue) 
+   strcmp(name, bNumInterfaces)) {
+   dbg(sscanf failed);
+   goto err;
+   }
}
 
 err:
-- 
1.8.1.2

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


[PATCH] staging: usbip: userspace: add hwdata as optional dependency in README

2014-03-04 Thread Valentina Manea
This is an optional dependency since USB/IP can fully work without
it. However, it is needed to display device information such as
vendor.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/userspace/README | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/usbip/userspace/README 
b/drivers/staging/usbip/userspace/README
index 6ead290..f528ba4 100644
--- a/drivers/staging/usbip/userspace/README
+++ b/drivers/staging/usbip/userspace/README
@@ -19,6 +19,10 @@
 
 - libtool, automake = 1.9, autoconf = 2.5.0, pkg-config
 
+[Optional]
+- hwdata
+Contains USB device identification data.
+
 
 [Install]
 0. Generate configuration scripts.
-- 
1.8.1.2

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


Re: [OPW] USB subsystem questions

2014-02-18 Thread Valentina Manea
Hi,

On Sun, Feb 16, 2014 at 12:42 AM, Alan Stern st...@rowland.harvard.edu wrote:

 That's true when it is invoked from userspace.  It can also be invoked
 directly by a kernel driver; in that case no file is needed.


I managed to get it working but I think what I did is rather flawed.

The problem is where I get that struct dev_state *owner parameter
from. The closest to this I found to be the filelist member in struct
usb_device. So I got the owner as:

owner = list_entry(udev-filelist.next, struct dev_state, list);

This works but that list is supposed to be the list of open files for
that device. No files are opened in this case. Should I initialize a
struct dev_state variable similary to usbdev_open()?

Unrelated to this, USB/IP still has a problem when the device is no
longer shared. In this case, the device should be rebound to the old
drivers and be used normally. While resetting the configuration
triggers a new binding process for interface drivers, on the core
level, where usbip-host driver is, the device remains unbound.
One hack-ish way to solve this would be to manually rebind the device
to the old driver.
Is there any better way to trigger a new driver binding at core level?

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


Re: /dev entry of USB device not disappearing after detach

2014-02-15 Thread Valentina Manea
On Fri, Feb 14, 2014 at 8:21 PM, Greg KH gre...@linuxfoundation.org wrote:

 Also, the kernel is the one now responsible for managing the /dev node
 creation/removal, through devtmpfs, there shouldn't be any hotplug
 scripts involved in this process, so I doubt it's a userspace issue.

 you do have CONFIG_DEVTMPFS enabled in your kernel, right?


Hi Greg,

It seems I did not have CONFIG_DEVTMPFS and, with this option, the bug
is no longer reproducible. Since, as I've read, devtmpfs has replaced
tmpfs, there's no point in further debugging.

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


Re: [OPW] USB subsystem questions

2014-02-15 Thread Valentina Manea
On Sat, Feb 1, 2014 at 12:00 AM, Alan Stern st...@rowland.harvard.edu wrote:
 On Fri, 31 Jan 2014, Sarah Sharp wrote:

 Why exactly do you want the device to not show up in /dev?  I would
 think what you really want is for the device drivers on the server side
 to not bind to the device, since the client side drivers should be bound
 to them instead.

 I believe there is a mechanism for usbfs drivers to mark a port as
 claimed.  Perhaps the stub driver could do the same?  Alan Stern would
 have deals on that.

 That might be good enough.  The stub driver could claim the port that
 the device is plugged into by calling usb_hub_claim_port (you would
 have to EXPORT this function first).  This would prevent the server
 system from automatically binding drivers to the device's interfaces
 whenever the client system changed the device's configuration.


Hi,

Thank you both for your replies, I managed to solve the /dev issues,
it seems it was related to tmpfs.

Related to the port claim mechanism, as far as I can see,
usb_hub_claim_port is called from a ioctl and, thus, needs a file to
be called for.
As I read, usbfs has been deprecated and /sys and /dev/bus/usb are
used instead. However, I can't figure out which file to use. I tried
claming a port from userspace using ioctl on /dev/bus/usb/001/001
(since it's the only file that looks like a device file corresponding
to hub usb1, to which the USB device to be shared is attached). I get
Operation not permitted when doing this.

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


[PATCH] staging: usbip: convert usbip-host driver to usb_device_driver

2014-01-23 Thread Valentina Manea
This driver was previously an interface driver. Since USB/IP
exports a whole device, not just an interface, it would make
sense to be a device driver.

This patch also modifies the way userspace sees and uses a
shared device - dealing with interfaces is no longer required.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
 drivers/staging/usbip/stub.h   |   2 +-
 drivers/staging/usbip/stub_dev.c   | 150 -
 drivers/staging/usbip/stub_main.c  |   6 +-
 drivers/staging/usbip/stub_rx.c|   2 +-
 .../usbip/userspace/libsrc/usbip_host_driver.c |  50 ++-
 drivers/staging/usbip/userspace/src/usbip_bind.c   | 142 ---
 drivers/staging/usbip/userspace/src/usbip_list.c   |  19 +--
 drivers/staging/usbip/userspace/src/usbip_unbind.c |  51 ++-
 drivers/staging/usbip/userspace/src/usbipd.c   |  15 ---
 drivers/usb/core/generic.c |   1 +
 drivers/usb/core/message.c |   1 +
 include/linux/usb.h|   4 +
 12 files changed, 148 insertions(+), 295 deletions(-)

diff --git a/drivers/staging/usbip/stub.h b/drivers/staging/usbip/stub.h
index a73e437..82e539a 100644
--- a/drivers/staging/usbip/stub.h
+++ b/drivers/staging/usbip/stub.h
@@ -93,7 +93,7 @@ struct bus_id_priv {
 extern struct kmem_cache *stub_priv_cache;
 
 /* stub_dev.c */
-extern struct usb_driver stub_driver;
+extern struct usb_device_driver stub_driver;
 
 /* stub_main.c */
 struct bus_id_priv *get_busid_priv(const char *busid);
diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index 76a1ff0..b0bfd34 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -279,21 +279,19 @@ static void stub_device_unusable(struct usbip_device *ud)
  *
  * Allocates and initializes a new stub_device struct.
  */
-static struct stub_device *stub_device_alloc(struct usb_device *udev,
-struct usb_interface *interface)
+static struct stub_device *stub_device_alloc(struct usb_device *udev)
 {
struct stub_device *sdev;
-   int busnum = interface_to_busnum(interface);
-   int devnum = interface_to_devnum(interface);
+   int busnum = udev-bus-busnum;
+   int devnum = udev-devnum;
 
-   dev_dbg(interface-dev, allocating stub device);
+   dev_dbg(udev-dev, allocating stub device);
 
/* yes, it's a new device */
sdev = kzalloc(sizeof(struct stub_device), GFP_KERNEL);
if (!sdev)
return NULL;
 
-   sdev-interface = usb_get_intf(interface);
sdev-udev = usb_get_dev(udev);
 
/*
@@ -322,7 +320,7 @@ static struct stub_device *stub_device_alloc(struct 
usb_device *udev,
 
usbip_start_eh(sdev-ud);
 
-   dev_dbg(interface-dev, register new interface\n);
+   dev_dbg(udev-dev, register new device\n);
 
return sdev;
 }
@@ -332,32 +330,20 @@ static void stub_device_free(struct stub_device *sdev)
kfree(sdev);
 }
 
-/*
- * If a usb device has multiple active interfaces, this driver is bound to all
- * the active interfaces. However, usbip exports *a* usb device (i.e., not *an*
- * active interface). Currently, a userland program must ensure that it
- * looks at the usbip's sysfs entries of only the first active interface.
- *
- * TODO: use struct usb_device_driver to bind a usb device.
- * However, it seems it is not fully supported in mainline kernel yet
- * (2.6.19.2).
- */
-static int stub_probe(struct usb_interface *interface,
- const struct usb_device_id *id)
+static int stub_probe(struct usb_device *udev)
 {
-   struct usb_device *udev = interface_to_usbdev(interface);
struct stub_device *sdev = NULL;
-   const char *udev_busid = dev_name(interface-dev.parent);
-   int err = 0;
+   const char *udev_busid = dev_name(udev-dev);
+   int err = 0, config;
struct bus_id_priv *busid_priv;
 
-   dev_dbg(interface-dev, Enter\n);
+   dev_dbg(udev-dev, Enter\n);
 
/* check we should claim or not by busid_table */
busid_priv = get_busid_priv(udev_busid);
if (!busid_priv || (busid_priv-status == STUB_BUSID_REMOV) ||
(busid_priv-status == STUB_BUSID_OTHER)) {
-   dev_info(interface-dev,
+   dev_info(udev-dev,
%s is not in match_busid table... skip!\n,
udev_busid);
 
@@ -383,60 +369,36 @@ static int stub_probe(struct usb_interface *interface,
return -ENODEV;
}
 
-   if (busid_priv-status == STUB_BUSID_ALLOC) {
-   sdev = busid_priv-sdev;
-   if (!sdev)
-   return -ENODEV;
-
-   busid_priv-interf_count++;
-   dev_info(interface-dev,
-   usbip-host: register new interface (bus %u dev %u ifn 
%u)\n

Re: [PATCH] staging: usbip: convert usbip-host driver to usb_device_driver

2014-01-23 Thread Valentina Manea
On Thu, Jan 23, 2014 at 9:09 PM, Greg KH gre...@linuxfoundation.org wrote:
 On Thu, Jan 23, 2014 at 08:36:46PM +0200, Valentina Manea wrote:
 This driver was previously an interface driver. Since USB/IP
 exports a whole device, not just an interface, it would make
 sense to be a device driver.

 This patch also modifies the way userspace sees and uses a
 shared device - dealing with interfaces is no longer required.

 In what way is this modified?  What is now different?


1. The usbip_status file is no longer created for interface 0, but for
the whole device (such as
/sys/devices/pci:00/:00:01.2/usb1/1-1/usbip_status).
2. Per interface information, such as interface class or protocol, is
no longer sent/received. Only device specific information is
transmitted.
3. Since the driver was moved one level below in the USB architecture,
there is no need to bind/unbind each interface, just the device as a
whole.


 Please make both of these EXPORT_SYMBOL_GPL(), like the rest of the USB
 symbols are.

Will fix in V2.

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


[PATCH v2] staging: usbip: convert usbip-host driver to usb_device_driver

2014-01-23 Thread Valentina Manea
This driver was previously an interface driver. Since USB/IP
exports a whole device, not just an interface, it would make
sense to be a device driver.

This patch also modifies the way userspace sees and uses a
shared device:

* the usbip_status file is no longer created for interface 0, but for
the whole device (such as
/sys/devices/pci:00/:00:01.2/usb1/1-1/usbip_status).
* per interface information, such as interface class or protocol, is
no longer sent/received; only device specific information is
transmitted.
* since the driver was moved one level below in the USB architecture,
there is no need to bind/unbind each interface, just the device as a
whole.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
Changes since v1:
* add extra information to the commit message
* remove a comment that was no longer available
* export USB functions as GPL

 drivers/staging/usbip/stub.h   |   2 +-
 drivers/staging/usbip/stub_dev.c   | 150 -
 drivers/staging/usbip/stub_main.c  |   6 +-
 drivers/staging/usbip/stub_rx.c|   2 +-
 .../usbip/userspace/libsrc/usbip_host_driver.c |  51 ++-
 drivers/staging/usbip/userspace/src/usbip_bind.c   | 142 ---
 drivers/staging/usbip/userspace/src/usbip_list.c   |  19 +--
 drivers/staging/usbip/userspace/src/usbip_unbind.c |  51 ++-
 drivers/staging/usbip/userspace/src/usbipd.c   |  15 ---
 drivers/usb/core/generic.c |   1 +
 drivers/usb/core/message.c |   1 +
 include/linux/usb.h|   4 +
 12 files changed, 148 insertions(+), 296 deletions(-)

diff --git a/drivers/staging/usbip/stub.h b/drivers/staging/usbip/stub.h
index a73e437..82e539a 100644
--- a/drivers/staging/usbip/stub.h
+++ b/drivers/staging/usbip/stub.h
@@ -93,7 +93,7 @@ struct bus_id_priv {
 extern struct kmem_cache *stub_priv_cache;
 
 /* stub_dev.c */
-extern struct usb_driver stub_driver;
+extern struct usb_device_driver stub_driver;
 
 /* stub_main.c */
 struct bus_id_priv *get_busid_priv(const char *busid);
diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index 76a1ff0..b0bfd34 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -279,21 +279,19 @@ static void stub_device_unusable(struct usbip_device *ud)
  *
  * Allocates and initializes a new stub_device struct.
  */
-static struct stub_device *stub_device_alloc(struct usb_device *udev,
-struct usb_interface *interface)
+static struct stub_device *stub_device_alloc(struct usb_device *udev)
 {
struct stub_device *sdev;
-   int busnum = interface_to_busnum(interface);
-   int devnum = interface_to_devnum(interface);
+   int busnum = udev-bus-busnum;
+   int devnum = udev-devnum;
 
-   dev_dbg(interface-dev, allocating stub device);
+   dev_dbg(udev-dev, allocating stub device);
 
/* yes, it's a new device */
sdev = kzalloc(sizeof(struct stub_device), GFP_KERNEL);
if (!sdev)
return NULL;
 
-   sdev-interface = usb_get_intf(interface);
sdev-udev = usb_get_dev(udev);
 
/*
@@ -322,7 +320,7 @@ static struct stub_device *stub_device_alloc(struct 
usb_device *udev,
 
usbip_start_eh(sdev-ud);
 
-   dev_dbg(interface-dev, register new interface\n);
+   dev_dbg(udev-dev, register new device\n);
 
return sdev;
 }
@@ -332,32 +330,20 @@ static void stub_device_free(struct stub_device *sdev)
kfree(sdev);
 }
 
-/*
- * If a usb device has multiple active interfaces, this driver is bound to all
- * the active interfaces. However, usbip exports *a* usb device (i.e., not *an*
- * active interface). Currently, a userland program must ensure that it
- * looks at the usbip's sysfs entries of only the first active interface.
- *
- * TODO: use struct usb_device_driver to bind a usb device.
- * However, it seems it is not fully supported in mainline kernel yet
- * (2.6.19.2).
- */
-static int stub_probe(struct usb_interface *interface,
- const struct usb_device_id *id)
+static int stub_probe(struct usb_device *udev)
 {
-   struct usb_device *udev = interface_to_usbdev(interface);
struct stub_device *sdev = NULL;
-   const char *udev_busid = dev_name(interface-dev.parent);
-   int err = 0;
+   const char *udev_busid = dev_name(udev-dev);
+   int err = 0, config;
struct bus_id_priv *busid_priv;
 
-   dev_dbg(interface-dev, Enter\n);
+   dev_dbg(udev-dev, Enter\n);
 
/* check we should claim or not by busid_table */
busid_priv = get_busid_priv(udev_busid);
if (!busid_priv || (busid_priv-status == STUB_BUSID_REMOV) ||
(busid_priv-status == STUB_BUSID_OTHER)) {
-   dev_info(interface-dev,
+   dev_info

Re: [PATCH] staging: usbip: convert usbip-host driver to usb_device_driver

2014-01-23 Thread Valentina Manea
 If you don't bind the interfaces, they will naturally bind to their
 normal drivers on the host.  You probably don't want that to happen.
 (Although, at the moment, I don't see how you can prevent it.)


That's true but, the way I see USB/IP general use case, the drivers
from the host the device is physically attached to won't even be
actually used, since the host doesn't use the device. However, I can't
think of a way to enforce this.

 Also, in your patch, stub_probe() calls usb_choose_configuration().
 Shouldn't that be done by the client, since the client now has access
 to the entire device?

I think the normal user just wants things *to work*. Surely, for
advanced user an option for choosing the configuration could be added
but I, personally, don't see it as a necessity at this point.

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


[PATCH v3] staging: usbip: convert usbip-host driver to usb_device_driver

2014-01-23 Thread Valentina Manea
This driver was previously an interface driver. Since USB/IP
exports a whole device, not just an interface, it would make
sense to be a device driver.

This patch also modifies the way userspace sees and uses a
shared device:

* the usbip_status file is no longer created for interface 0, but for
the whole device (such as
/sys/devices/pci:00/:00:01.2/usb1/1-1/usbip_status).
* per interface information, such as interface class or protocol, is
no longer sent/received; only device specific information is
transmitted.
* since the driver was moved one level below in the USB architecture,
there is no need to bind/unbind each interface, just the device as a
whole.

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
Changes since v2:
* re-add check for empty device list

 drivers/staging/usbip/stub.h   |   2 +-
 drivers/staging/usbip/stub_dev.c   | 150 -
 drivers/staging/usbip/stub_main.c  |   6 +-
 drivers/staging/usbip/stub_rx.c|   2 +-
 .../usbip/userspace/libsrc/usbip_host_driver.c |  45 +++
 drivers/staging/usbip/userspace/src/usbip_bind.c   | 142 ---
 drivers/staging/usbip/userspace/src/usbip_list.c   |  19 +--
 drivers/staging/usbip/userspace/src/usbip_unbind.c |  51 ++-
 drivers/staging/usbip/userspace/src/usbipd.c   |  15 ---
 drivers/usb/core/generic.c |   1 +
 drivers/usb/core/message.c |   1 +
 include/linux/usb.h|   4 +
 12 files changed, 150 insertions(+), 288 deletions(-)

diff --git a/drivers/staging/usbip/stub.h b/drivers/staging/usbip/stub.h
index a73e437..82e539a 100644
--- a/drivers/staging/usbip/stub.h
+++ b/drivers/staging/usbip/stub.h
@@ -93,7 +93,7 @@ struct bus_id_priv {
 extern struct kmem_cache *stub_priv_cache;
 
 /* stub_dev.c */
-extern struct usb_driver stub_driver;
+extern struct usb_device_driver stub_driver;
 
 /* stub_main.c */
 struct bus_id_priv *get_busid_priv(const char *busid);
diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index 76a1ff0..b0bfd34 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -279,21 +279,19 @@ static void stub_device_unusable(struct usbip_device *ud)
  *
  * Allocates and initializes a new stub_device struct.
  */
-static struct stub_device *stub_device_alloc(struct usb_device *udev,
-struct usb_interface *interface)
+static struct stub_device *stub_device_alloc(struct usb_device *udev)
 {
struct stub_device *sdev;
-   int busnum = interface_to_busnum(interface);
-   int devnum = interface_to_devnum(interface);
+   int busnum = udev-bus-busnum;
+   int devnum = udev-devnum;
 
-   dev_dbg(interface-dev, allocating stub device);
+   dev_dbg(udev-dev, allocating stub device);
 
/* yes, it's a new device */
sdev = kzalloc(sizeof(struct stub_device), GFP_KERNEL);
if (!sdev)
return NULL;
 
-   sdev-interface = usb_get_intf(interface);
sdev-udev = usb_get_dev(udev);
 
/*
@@ -322,7 +320,7 @@ static struct stub_device *stub_device_alloc(struct 
usb_device *udev,
 
usbip_start_eh(sdev-ud);
 
-   dev_dbg(interface-dev, register new interface\n);
+   dev_dbg(udev-dev, register new device\n);
 
return sdev;
 }
@@ -332,32 +330,20 @@ static void stub_device_free(struct stub_device *sdev)
kfree(sdev);
 }
 
-/*
- * If a usb device has multiple active interfaces, this driver is bound to all
- * the active interfaces. However, usbip exports *a* usb device (i.e., not *an*
- * active interface). Currently, a userland program must ensure that it
- * looks at the usbip's sysfs entries of only the first active interface.
- *
- * TODO: use struct usb_device_driver to bind a usb device.
- * However, it seems it is not fully supported in mainline kernel yet
- * (2.6.19.2).
- */
-static int stub_probe(struct usb_interface *interface,
- const struct usb_device_id *id)
+static int stub_probe(struct usb_device *udev)
 {
-   struct usb_device *udev = interface_to_usbdev(interface);
struct stub_device *sdev = NULL;
-   const char *udev_busid = dev_name(interface-dev.parent);
-   int err = 0;
+   const char *udev_busid = dev_name(udev-dev);
+   int err = 0, config;
struct bus_id_priv *busid_priv;
 
-   dev_dbg(interface-dev, Enter\n);
+   dev_dbg(udev-dev, Enter\n);
 
/* check we should claim or not by busid_table */
busid_priv = get_busid_priv(udev_busid);
if (!busid_priv || (busid_priv-status == STUB_BUSID_REMOV) ||
(busid_priv-status == STUB_BUSID_OTHER)) {
-   dev_info(interface-dev,
+   dev_info(udev-dev,
%s is not in match_busid table... skip!\n

[PATCH] staging: usbip: userspace: add support for viewing imported devices

2014-01-07 Thread Valentina Manea
As of Matt Mooney's major refactoring in 2011, usbip port
option was left out. Add support for this option in
a manner similar to the old implementation.

Sample output:

Imported USB devices

Port 00: Port in Use at Full Speed(12Mbps)
   unknown vendor : unknown product (1687:6211)
   2-1 - usbip://192.168.122.152:3240/1-1
   - remote bus/dev 001/002

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
Reviewed-by: Ilija Hadzic ihad...@research.bell-labs.com
---
Resubmitting this patch as I still didn't get any reply from Greg
after 2 weeks.

 .../staging/usbip/userspace/libsrc/vhci_driver.c   | 67 ++
 .../staging/usbip/userspace/libsrc/vhci_driver.h   |  2 +
 drivers/staging/usbip/userspace/src/Makefile.am|  2 +-
 drivers/staging/usbip/userspace/src/usbip.c|  6 ++
 drivers/staging/usbip/userspace/src/usbip.h|  1 +
 drivers/staging/usbip/userspace/src/usbip_port.c   | 57 ++
 6 files changed, 134 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/usbip/userspace/src/usbip_port.c

diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c 
b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
index 241006a..209df9b 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
@@ -4,6 +4,8 @@
 
 #include usbip_common.h
 #include vhci_driver.h
+#include limits.h
+#include netdb.h
 
 #undef  PROGNAME
 #define PROGNAME libusbip
@@ -337,6 +339,29 @@ err:
return -1;
 }
 
+static int read_record(int rhport, char *host, char *port, char *busid)
+{
+   FILE *file;
+   char path[PATH_MAX+1];
+
+   snprintf(path, PATH_MAX, VHCI_STATE_PATH/port%d, rhport);
+
+   file = fopen(path, r);
+   if (!file) {
+   err(fopen);
+   return -1;
+   }
+
+   if (fscanf(file, %s %s %s\n, host, port, busid) != 3) {
+   err(fscanf);
+   fclose(file);
+   return -1;
+   }
+
+   fclose(file);
+
+   return 0;
+}
 
 /* -- */
 
@@ -535,3 +560,45 @@ int usbip_vhci_detach_device(uint8_t port)
 
return 0;
 }
+
+int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev)
+{
+   char product_name[100];
+   char host[NI_MAXHOST] = unknown host;
+   char serv[NI_MAXSERV] = unknown port;
+   char remote_busid[SYSFS_BUS_ID_SIZE];
+   int ret;
+   int read_record_error = 0;
+
+   if (idev-status == VDEV_ST_NULL || idev-status == VDEV_ST_NOTASSIGNED)
+   return 0;
+
+   ret = read_record(idev-port, host, serv, remote_busid);
+   if (ret) {
+   err(read_record);
+   read_record_error = 1;
+   }
+
+   printf(Port %02d: %s at %s\n, idev-port,
+  usbip_status_string(idev-status),
+  usbip_speed_string(idev-udev.speed));
+
+   usbip_names_get_product(product_name, sizeof(product_name),
+   idev-udev.idVendor, idev-udev.idProduct);
+
+   printf(   %s\n,  product_name);
+
+   if (!read_record_error) {
+   printf(%10s - usbip://%s:%s/%s\n, idev-udev.busid,
+  host, serv, remote_busid);
+   printf(%10s - remote bus/dev %03d/%03d\n,  ,
+  idev-busnum, idev-devnum);
+   } else {
+   printf(%10s - unknown host, remote port and remote busid\n,
+  idev-udev.busid);
+   printf(%10s - remote bus/dev %03d/%03d\n,  ,
+  idev-busnum, idev-devnum);
+   }
+
+   return 0;
+}
diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h 
b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
index 89949aa..e071f80 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
@@ -64,4 +64,6 @@ int usbip_vhci_attach_device(uint8_t port, int sockfd, 
uint8_t busnum,
 
 int usbip_vhci_detach_device(uint8_t port);
 
+int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev);
+
 #endif /* __VHCI_DRIVER_H */
diff --git a/drivers/staging/usbip/userspace/src/Makefile.am 
b/drivers/staging/usbip/userspace/src/Makefile.am
index a113003..b4f8c4b 100644
--- a/drivers/staging/usbip/userspace/src/Makefile.am
+++ b/drivers/staging/usbip/userspace/src/Makefile.am
@@ -6,7 +6,7 @@ sbin_PROGRAMS := usbip usbipd
 
 usbip_SOURCES := usbip.h utils.h usbip.c utils.c usbip_network.c \
 usbip_attach.c usbip_detach.c usbip_list.c \
-usbip_bind.c usbip_unbind.c
+usbip_bind.c usbip_unbind.c usbip_port.c
 
 
 usbipd_SOURCES := usbip_network.h usbipd.c usbip_network.c
diff --git a/drivers/staging/usbip/userspace/src/usbip.c 
b/drivers/staging/usbip/userspace/src/usbip.c
index 04a5f20..d7599d9 100644
--- a/drivers/staging

[PATCH v3] staging: usbip: userspace: add support for viewing imported devices

2013-12-24 Thread Valentina Manea
As of Matt Mooney's major refactoring in 2011, usbip port
option was left out. Add support for this option in
a manner similar to the old implementation.

Sample output:

Imported USB devices

Port 00: Port in Use at Full Speed(12Mbps)
   unknown vendor : unknown product (1687:6211)
   2-1 - usbip://192.168.122.152:3240/1-1
   - remote bus/dev 001/002

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
Changes since v2:
* fix trailing whitespace error
* change commit title to reflect that this is a userspace patch

 .../staging/usbip/userspace/libsrc/vhci_driver.c   | 67 ++
 .../staging/usbip/userspace/libsrc/vhci_driver.h   |  2 +
 drivers/staging/usbip/userspace/src/Makefile.am|  2 +-
 drivers/staging/usbip/userspace/src/usbip.c|  6 ++
 drivers/staging/usbip/userspace/src/usbip.h|  1 +
 drivers/staging/usbip/userspace/src/usbip_port.c   | 57 ++
 6 files changed, 134 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/usbip/userspace/src/usbip_port.c

diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c 
b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
index 241006a..209df9b 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
@@ -4,6 +4,8 @@
 
 #include usbip_common.h
 #include vhci_driver.h
+#include limits.h
+#include netdb.h
 
 #undef  PROGNAME
 #define PROGNAME libusbip
@@ -337,6 +339,29 @@ err:
return -1;
 }
 
+static int read_record(int rhport, char *host, char *port, char *busid)
+{
+   FILE *file;
+   char path[PATH_MAX+1];
+
+   snprintf(path, PATH_MAX, VHCI_STATE_PATH/port%d, rhport);
+
+   file = fopen(path, r);
+   if (!file) {
+   err(fopen);
+   return -1;
+   }
+
+   if (fscanf(file, %s %s %s\n, host, port, busid) != 3) {
+   err(fscanf);
+   fclose(file);
+   return -1;
+   }
+
+   fclose(file);
+
+   return 0;
+}
 
 /* -- */
 
@@ -535,3 +560,45 @@ int usbip_vhci_detach_device(uint8_t port)
 
return 0;
 }
+
+int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev)
+{
+   char product_name[100];
+   char host[NI_MAXHOST] = unknown host;
+   char serv[NI_MAXSERV] = unknown port;
+   char remote_busid[SYSFS_BUS_ID_SIZE];
+   int ret;
+   int read_record_error = 0;
+
+   if (idev-status == VDEV_ST_NULL || idev-status == VDEV_ST_NOTASSIGNED)
+   return 0;
+
+   ret = read_record(idev-port, host, serv, remote_busid);
+   if (ret) {
+   err(read_record);
+   read_record_error = 1;
+   }
+
+   printf(Port %02d: %s at %s\n, idev-port,
+  usbip_status_string(idev-status),
+  usbip_speed_string(idev-udev.speed));
+
+   usbip_names_get_product(product_name, sizeof(product_name),
+   idev-udev.idVendor, idev-udev.idProduct);
+
+   printf(   %s\n,  product_name);
+
+   if (!read_record_error) {
+   printf(%10s - usbip://%s:%s/%s\n, idev-udev.busid,
+  host, serv, remote_busid);
+   printf(%10s - remote bus/dev %03d/%03d\n,  ,
+  idev-busnum, idev-devnum);
+   } else {
+   printf(%10s - unknown host, remote port and remote busid\n,
+  idev-udev.busid);
+   printf(%10s - remote bus/dev %03d/%03d\n,  ,
+  idev-busnum, idev-devnum);
+   }
+
+   return 0;
+}
diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h 
b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
index 89949aa..e071f80 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
@@ -64,4 +64,6 @@ int usbip_vhci_attach_device(uint8_t port, int sockfd, 
uint8_t busnum,
 
 int usbip_vhci_detach_device(uint8_t port);
 
+int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev);
+
 #endif /* __VHCI_DRIVER_H */
diff --git a/drivers/staging/usbip/userspace/src/Makefile.am 
b/drivers/staging/usbip/userspace/src/Makefile.am
index a113003..b4f8c4b 100644
--- a/drivers/staging/usbip/userspace/src/Makefile.am
+++ b/drivers/staging/usbip/userspace/src/Makefile.am
@@ -6,7 +6,7 @@ sbin_PROGRAMS := usbip usbipd
 
 usbip_SOURCES := usbip.h utils.h usbip.c utils.c usbip_network.c \
 usbip_attach.c usbip_detach.c usbip_list.c \
-usbip_bind.c usbip_unbind.c
+usbip_bind.c usbip_unbind.c usbip_port.c
 
 
 usbipd_SOURCES := usbip_network.h usbipd.c usbip_network.c
diff --git a/drivers/staging/usbip/userspace/src/usbip.c 
b/drivers/staging/usbip/userspace/src/usbip.c
index 04a5f20..d7599d9 100644
--- a/drivers/staging/usbip

[PATCH v2] staging: usbip: add support for viewing imported devices

2013-12-23 Thread Valentina Manea
As of Matt Mooney's major refactoring in 2011, usbip port
option was left out. Add support for this option in
a manner similar to the old implementation.

Sample output:

Imported USB devices

Port 00: Port in Use at Full Speed(12Mbps)
   unknown vendor : unknown product (1687:6211)
   2-1 - usbip://192.168.122.152:3240/1-1
   - remote bus/dev 001/002

Signed-off-by: Valentina Manea valentina.mane...@gmail.com
---
Changes since v1:
* remove devid from the printed info
* arrange formatting a bit
* don't bail out when port file doesn't exist, just print whatever info 
is available
* replace void cast with __attribute__((unused)) 

 .../staging/usbip/userspace/libsrc/vhci_driver.c   | 67 ++
 .../staging/usbip/userspace/libsrc/vhci_driver.h   |  2 +
 drivers/staging/usbip/userspace/src/Makefile.am|  2 +-
 drivers/staging/usbip/userspace/src/usbip.c|  6 ++
 drivers/staging/usbip/userspace/src/usbip.h|  1 +
 drivers/staging/usbip/userspace/src/usbip_port.c   | 57 ++
 6 files changed, 134 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/usbip/userspace/src/usbip_port.c

diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c 
b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
index 241006a..65ea5cf 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
@@ -4,6 +4,8 @@
 
 #include usbip_common.h
 #include vhci_driver.h
+#include limits.h
+#include netdb.h
 
 #undef  PROGNAME
 #define PROGNAME libusbip
@@ -337,6 +339,29 @@ err:
return -1;
 }
 
+static int read_record(int rhport, char *host, char *port, char *busid)
+{
+   FILE *file;
+   char path[PATH_MAX+1];
+
+   snprintf(path, PATH_MAX, VHCI_STATE_PATH/port%d, rhport);
+
+   file = fopen(path, r);
+   if (!file) {
+   err(fopen);
+   return -1;
+   }
+
+   if (fscanf(file, %s %s %s\n, host, port, busid) != 3) {
+   err(fscanf);
+   fclose(file);
+   return -1;
+   }
+
+   fclose(file);
+
+   return 0;
+}
 
 /* -- */
 
@@ -535,3 +560,45 @@ int usbip_vhci_detach_device(uint8_t port)
 
return 0;
 }
+
+int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev)
+{
+   char product_name[100];
+   char host[NI_MAXHOST] = unknown host;
+   char serv[NI_MAXSERV] = unknown port;
+   char remote_busid[SYSFS_BUS_ID_SIZE];
+   int ret;
+   int read_record_error = 0;
+
+   if (idev-status == VDEV_ST_NULL || idev-status == VDEV_ST_NOTASSIGNED)
+   return 0;
+
+   ret = read_record(idev-port, host, serv, remote_busid);
+   if (ret) {
+   err(read_record);
+   read_record_error = 1;
+   }
+
+   printf(Port %02d: %s at %s\n, idev-port,
+  usbip_status_string(idev-status),
+  usbip_speed_string(idev-udev.speed));
+
+   usbip_names_get_product(product_name, sizeof(product_name),
+   idev-udev.idVendor, idev-udev.idProduct);
+
+   printf(   %s\n,  product_name);
+
+   if (!read_record_error) {
+   printf(%10s - usbip://%s:%s/%s\n, idev-udev.busid,
+  host, serv, remote_busid);
+   printf(%10s - remote bus/dev %03d/%03d\n,  ,
+  idev-busnum, idev-devnum);
+   } else {
+   printf(%10s - unknown host, remote port and remote busid\n,
+  idev-udev.busid); 
+   printf(%10s - remote bus/dev %03d/%03d\n,  ,
+  idev-busnum, idev-devnum);
+   }
+
+   return 0;
+}
diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h 
b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
index 89949aa..e071f80 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
@@ -64,4 +64,6 @@ int usbip_vhci_attach_device(uint8_t port, int sockfd, 
uint8_t busnum,
 
 int usbip_vhci_detach_device(uint8_t port);
 
+int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev);
+
 #endif /* __VHCI_DRIVER_H */
diff --git a/drivers/staging/usbip/userspace/src/Makefile.am 
b/drivers/staging/usbip/userspace/src/Makefile.am
index a113003..b4f8c4b 100644
--- a/drivers/staging/usbip/userspace/src/Makefile.am
+++ b/drivers/staging/usbip/userspace/src/Makefile.am
@@ -6,7 +6,7 @@ sbin_PROGRAMS := usbip usbipd
 
 usbip_SOURCES := usbip.h utils.h usbip.c utils.c usbip_network.c \
 usbip_attach.c usbip_detach.c usbip_list.c \
-usbip_bind.c usbip_unbind.c
+usbip_bind.c usbip_unbind.c usbip_port.c
 
 
 usbipd_SOURCES := usbip_network.h usbipd.c usbip_network.c
diff --git a/drivers/staging/usbip/userspace