aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/uapi/linux/usb/functionfs.h2
-rw-r--r--tools/usb/Makefile6
-rw-r--r--tools/usb/ffs-test.c20
3 files changed, 24 insertions, 4 deletions
diff --git a/include/uapi/linux/usb/functionfs.h b/include/uapi/linux/usb/functionfs.h
index 2a4b4a72a4f9..ecb3a31f7ca6 100644
--- a/include/uapi/linux/usb/functionfs.h
+++ b/include/uapi/linux/usb/functionfs.h
@@ -53,7 +53,7 @@ struct usb_endpoint_descriptor_no_audio {
53 * structure. Any flags that are not recognised cause the whole block to be 53 * structure. Any flags that are not recognised cause the whole block to be
54 * rejected with -ENOSYS. 54 * rejected with -ENOSYS.
55 * 55 *
56 * Legacy descriptors format: 56 * Legacy descriptors format (deprecated as of 3.14):
57 * 57 *
58 * | off | name | type | description | 58 * | off | name | type | description |
59 * |-----+-----------+--------------+--------------------------------------| 59 * |-----+-----------+--------------+--------------------------------------|
diff --git a/tools/usb/Makefile b/tools/usb/Makefile
index acf2165c04e6..d576b3bac3cf 100644
--- a/tools/usb/Makefile
+++ b/tools/usb/Makefile
@@ -6,7 +6,11 @@ WARNINGS = -Wall -Wextra
6CFLAGS = $(WARNINGS) -g -I../include 6CFLAGS = $(WARNINGS) -g -I../include
7LDFLAGS = $(PTHREAD_LIBS) 7LDFLAGS = $(PTHREAD_LIBS)
8 8
9all: testusb ffs-test 9all: testusb ffs-test ffs-test-legacy
10
11ffs-test-legacy: ffs-test.c
12 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) -DUSE_LEGACY_DESC_HEAD
13
10%: %.c 14%: %.c
11 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) 15 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
12 16
diff --git a/tools/usb/ffs-test.c b/tools/usb/ffs-test.c
index fe1e66b6ef40..74b353d9eb50 100644
--- a/tools/usb/ffs-test.c
+++ b/tools/usb/ffs-test.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * ffs-test.c.c -- user mode filesystem api for usb composite function 2 * ffs-test.c -- user mode filesystem api for usb composite function
3 * 3 *
4 * Copyright (C) 2010 Samsung Electronics 4 * Copyright (C) 2010 Samsung Electronics
5 * Author: Michal Nazarewicz <mina86@mina86.com> 5 * Author: Michal Nazarewicz <mina86@mina86.com>
@@ -21,6 +21,8 @@
21 21
22/* $(CROSS_COMPILE)cc -Wall -Wextra -g -o ffs-test ffs-test.c -lpthread */ 22/* $(CROSS_COMPILE)cc -Wall -Wextra -g -o ffs-test ffs-test.c -lpthread */
23 23
24/* Uncomment to make the tool use legacy FFS descriptor headers. */
25/* #define USE_LEGACY_DESC_HEAD */
24 26
25#define _BSD_SOURCE /* for endian.h */ 27#define _BSD_SOURCE /* for endian.h */
26 28
@@ -106,7 +108,15 @@ static void _msg(unsigned level, const char *fmt, ...)
106/******************** Descriptors and Strings *******************************/ 108/******************** Descriptors and Strings *******************************/
107 109
108static const struct { 110static const struct {
109 struct usb_functionfs_descs_head header; 111 struct {
112 __le32 magic;
113 __le32 length;
114#ifndef USE_LEGACY_DESC_HEAD
115 __le32 flags;
116#endif
117 __le32 fs_count;
118 __le32 hs_count;
119 } __attribute__((packed)) header;
110 struct { 120 struct {
111 struct usb_interface_descriptor intf; 121 struct usb_interface_descriptor intf;
112 struct usb_endpoint_descriptor_no_audio sink; 122 struct usb_endpoint_descriptor_no_audio sink;
@@ -114,7 +124,13 @@ static const struct {
114 } __attribute__((packed)) fs_descs, hs_descs; 124 } __attribute__((packed)) fs_descs, hs_descs;
115} __attribute__((packed)) descriptors = { 125} __attribute__((packed)) descriptors = {
116 .header = { 126 .header = {
127#ifdef USE_LEGACY_DESC_HEAD
117 .magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC), 128 .magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC),
129#else
130 .magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2),
131 .flags = cpu_to_le32(FUNCTIONFS_HAS_FS_DESC |
132 FUNCTIONFS_HAS_HS_DESC),
133#endif
118 .length = cpu_to_le32(sizeof descriptors), 134 .length = cpu_to_le32(sizeof descriptors),
119 .fs_count = 3, 135 .fs_count = 3,
120 .hs_count = 3, 136 .hs_count = 3,