aboutsummaryrefslogtreecommitdiffstats
path: root/tools/usb
diff options
context:
space:
mode:
authorMichal Nazarewicz <mina86@mina86.com>2014-05-20 15:38:03 -0400
committerFelipe Balbi <balbi@ti.com>2014-06-19 09:51:35 -0400
commitf2af74123f8c5a735248547f4286a3adc28633c1 (patch)
tree18b2bf16a18b6e4f65f11d42fc0aaa2ec798683e /tools/usb
parent5cd8c48d95c10f729090c89757727e090719fd83 (diff)
tools: ffs-test: convert to new descriptor format fixing compilation error
Commit [ac8dde11: “usb: gadget: f_fs: Add flags to descriptors block”] which introduced a new descriptor format for FunctionFS removed the usb_functionfs_descs_head structure, which is still used by ffs-test. tool. Convert ffs-test by converting it to use the new header format. For testing kernels prior to 3.14 (when the new format was introduced) and parsing of the legacy headers in the new kernels, provide a compilation flag to make the tool use the old format. Finally, include information as to when the legacy FunctionFS headers format has been deprecated (which is also when the new one has been introduced). Reported-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Signed-off-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'tools/usb')
-rw-r--r--tools/usb/Makefile6
-rw-r--r--tools/usb/ffs-test.c20
2 files changed, 23 insertions, 3 deletions
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,