2014-02-28 00:27:34

by Shuah Khan

[permalink] [raw]
Subject: [PATCH 0/3] staging/usbip: add new uapi header usbip.h

usbip userspace has duplicated enum definition to report usbip device
status maintained by the kernel. Adding an usbip uapi header file will
define the kernel - userspace interface for this device status.

Shuah Khan (3):
staging/usbip: add uapi header to export usbip kernel interfaces
staging/usbip: change usbip to include new uapi usbip.h
staging/usbip: change usbip userspace to include new uapi usbip.h

drivers/staging/usbip/usbip_common.h | 19 ++------------
.../staging/usbip/userspace/libsrc/usbip_common.h | 20 +++------------
include/uapi/linux/Kbuild | 1 +
include/uapi/linux/usbip.h | 26 ++++++++++++++++++++
4 files changed, 32 insertions(+), 34 deletions(-)
create mode 100644 include/uapi/linux/usbip.h

--
1.7.10.4


2014-02-28 00:27:35

by Shuah Khan

[permalink] [raw]
Subject: [PATCH 2/3] staging/usbip: change usbip to include new uapi usbip.h

usbip userspace has duplicated enum definition to report usbip device
status maintained by the kernel. A new uapi usbip.h now defines the
usbip device status for kernel and userspace to use. Change usbip
kernel space to include uapi usbip.h for usbip device status.

Signed-off-by: Shuah Khan <[email protected]>
---
drivers/staging/usbip/usbip_common.h | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/usbip/usbip_common.h b/drivers/staging/usbip/usbip_common.h
index 7e6c543..846ef5b 100644
--- a/drivers/staging/usbip/usbip_common.h
+++ b/drivers/staging/usbip/usbip_common.h
@@ -29,6 +29,7 @@
#include <linux/types.h>
#include <linux/usb.h>
#include <linux/wait.h>
+#include <uapi/linux/usbip.h>

#define USBIP_VERSION "1.0.0"

@@ -235,22 +236,6 @@ enum usbip_side {
USBIP_STUB,
};

-enum usbip_status {
- /* sdev is available. */
- SDEV_ST_AVAILABLE = 0x01,
- /* sdev is now used. */
- SDEV_ST_USED,
- /* sdev is unusable because of a fatal error. */
- SDEV_ST_ERROR,
-
- /* vdev does not connect a remote device. */
- VDEV_ST_NULL,
- /* vdev is used, but the USB address is not assigned yet */
- VDEV_ST_NOTASSIGNED,
- VDEV_ST_USED,
- VDEV_ST_ERROR
-};
-
/* event handler */
#define USBIP_EH_SHUTDOWN (1 << 0)
#define USBIP_EH_BYE (1 << 1)
@@ -271,7 +256,7 @@ enum usbip_status {
/* a common structure for stub_device and vhci_device */
struct usbip_device {
enum usbip_side side;
- enum usbip_status status;
+ enum usbip_device_status status;

/* lock for status */
spinlock_t lock;
--
1.7.10.4

2014-02-28 00:27:51

by Shuah Khan

[permalink] [raw]
Subject: [PATCH 3/3] staging/usbip: change usbip userspace to include new uapi usbip.h

usbip userspace has duplicated enum definition to report usbip device
status maintained by the kernel. A new uapi usbip.h now defines the
usbip device status for kernel and userspace to use. Change usbip
userspace to include uapi usbip.h for usbip device status.

Signed-off-by: Shuah Khan <[email protected]>
---
.../staging/usbip/userspace/libsrc/usbip_common.h | 20 +++-----------------
1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.h b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
index 2cb81b3..d336f14 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.h
+++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
@@ -15,6 +15,9 @@
#include <syslog.h>
#include <unistd.h>
#include <linux/usb/ch9.h>
+/* this is temporary to build in tree, once usbip.h
+ * appears under linux headers - change it to <linux/usbip.h> */
+#include <../../../../../include/uapi/linux/usbip.h>

#ifndef USBIDS_FILE
#define USBIDS_FILE "/usr/share/hwdata/usb.ids"
@@ -77,23 +80,6 @@ extern int usbip_use_debug ;
abort(); \
} while (0)

-/* FIXME: how to sync with drivers/usbip_common.h ? */
-enum usbip_device_status {
- /* sdev is available. */
- SDEV_ST_AVAILABLE = 0x01,
- /* sdev is now used. */
- SDEV_ST_USED,
- /* sdev is unusable because of a fatal error. */
- SDEV_ST_ERROR,
-
- /* vdev does not connect a remote device. */
- VDEV_ST_NULL,
- /* vdev is used, but the USB address is not assigned yet */
- VDEV_ST_NOTASSIGNED,
- VDEV_ST_USED,
- VDEV_ST_ERROR
-};
-
struct usbip_usb_interface {
uint8_t bInterfaceClass;
uint8_t bInterfaceSubClass;
--
1.7.10.4

2014-02-28 00:28:20

by Shuah Khan

[permalink] [raw]
Subject: [PATCH 1/3] staging/usbip: add uapi header to export usbip kernel interfaces

usbip userspace has duplicated enum definition to report usbip device
status maintained by the kernel. Adding an usbip uapi header file will
define the kernel - userspace interface for this device status.

Signed-off-by: Shuah Khan <[email protected]>
---
include/uapi/linux/Kbuild | 1 +
include/uapi/linux/usbip.h | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+)
create mode 100644 include/uapi/linux/usbip.h

diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index 3ce25b5..4fb4800 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -393,6 +393,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/include/uapi/linux/usbip.h b/include/uapi/linux/usbip.h
new file mode 100644
index 0000000..fa5db30
--- /dev/null
+++ b/include/uapi/linux/usbip.h
@@ -0,0 +1,26 @@
+/*
+ * usbip.h
+ *
+ * USBIP uapi defines and function prototypes etc.
+*/
+
+#ifndef _UAPI_LINUX_USBIP_H
+#define _UAPI_LINUX_USBIP_H
+
+/* usbip device status - exported in usbip device sysfs status */
+enum usbip_device_status {
+ /* sdev is available. */
+ SDEV_ST_AVAILABLE = 0x01,
+ /* sdev is now used. */
+ SDEV_ST_USED,
+ /* sdev is unusable because of a fatal error. */
+ SDEV_ST_ERROR,
+
+ /* vdev does not connect a remote device. */
+ VDEV_ST_NULL,
+ /* vdev is used, but the USB address is not assigned yet */
+ VDEV_ST_NOTASSIGNED,
+ VDEV_ST_USED,
+ VDEV_ST_ERROR
+};
+#endif /* _UAPI_LINUX_USBIP_H */
--
1.7.10.4

2014-02-28 22:14:21

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 1/3] staging/usbip: add uapi header to export usbip kernel interfaces

On Thu, Feb 27, 2014 at 05:27:25PM -0700, Shuah Khan wrote:
> usbip userspace has duplicated enum definition to report usbip device
> status maintained by the kernel. Adding an usbip uapi header file will
> define the kernel - userspace interface for this device status.
>
> Signed-off-by: Shuah Khan <[email protected]>
> ---
> include/uapi/linux/Kbuild | 1 +
> include/uapi/linux/usbip.h | 26 ++++++++++++++++++++++++++
> 2 files changed, 27 insertions(+)
> create mode 100644 include/uapi/linux/usbip.h

Staging code should be self-contained within drivers/staging/

Now I know that a bunch of people are now working on this codebase, and
hopefully it will finally get moved out of staging someday soon, but
until then, I can't add this file in this location, sorry.

Look at how the drivers/staging/android code handles the uapi files, you
should try doing that instead.

thanks,

greg k-h

2014-02-28 22:45:42

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 1/3] staging/usbip: add uapi header to export usbip kernel interfaces

On 02/28/2014 03:15 PM, Greg KH wrote:
> On Thu, Feb 27, 2014 at 05:27:25PM -0700, Shuah Khan wrote:
>> usbip userspace has duplicated enum definition to report usbip device
>> status maintained by the kernel. Adding an usbip uapi header file will
>> define the kernel - userspace interface for this device status.
>>
>> Signed-off-by: Shuah Khan <[email protected]>
>> ---
>> include/uapi/linux/Kbuild | 1 +
>> include/uapi/linux/usbip.h | 26 ++++++++++++++++++++++++++
>> 2 files changed, 27 insertions(+)
>> create mode 100644 include/uapi/linux/usbip.h
>
> Staging code should be self-contained within drivers/staging/
>
> Now I know that a bunch of people are now working on this codebase, and
> hopefully it will finally get moved out of staging someday soon, but
> until then, I can't add this file in this location, sorry.

That makes sense.

>
> Look at how the drivers/staging/android code handles the uapi files, you
> should try doing that instead.
>

I will take a look at how android is handling uapi files and redo this
patch series and resend it. Hope everybody is ok with the code itself,
just the location of the uapi file is the issue, if not please let me
know and give me feedback on the approach.

-- Shuah


--
Shuah Khan
Senior Linux Kernel Developer - Open Source Group
Samsung Research America(Silicon Valley)
[email protected] | (970) 672-0658