xref: /linux/tools/perf/trace/beauty/usbdevfs_ioctl.sh (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1#!/bin/sh
2# SPDX-License-Identifier: LGPL-2.1
3
4[ $# -eq 1 ] && beauty_uapi_linux_dir=$1 || beauty_uapi_linux_dir=tools/perf/trace/beauty/include/uapi/linux/
5
6# also as:
7# #define USBDEVFS_CONNINFO_EX(len)  _IOC(_IOC_READ, 'U', 32, len)
8
9printf "static const char *usbdevfs_ioctl_cmds[] = {\n"
10regex="^#[[:space:]]*define[[:space:]]+USBDEVFS_(\w+)(\(\w+\))?[[:space:]]+_IO[CWR]{0,2}\([[:space:]]*(_IOC_\w+,[[:space:]]*)?'U'[[:space:]]*,[[:space:]]*([[:digit:]]+).*"
11grep -E "$regex" ${beauty_uapi_linux_dir}/usbdevice_fs.h | grep -E -v 'USBDEVFS_\w+32[[:space:]]' | \
12	sed -r "s/$regex/\4 \1/g"	| \
13	sort | xargs printf "\t[%s] = \"%s\",\n"
14printf "};\n\n"
15printf "#if 0\n"
16printf "static const char *usbdevfs_ioctl_32_cmds[] = {\n"
17regex="^#[[:space:]]*define[[:space:]]+USBDEVFS_(\w+)[[:space:]]+_IO[WR]{0,2}\([[:space:]]*'U'[[:space:]]*,[[:space:]]*([[:digit:]]+).*"
18grep -E $regex ${beauty_uapi_linux_dir}/usbdevice_fs.h | grep -E 'USBDEVFS_\w+32[[:space:]]' | \
19	sed -r "s/$regex/\2 \1/g"	| \
20	sort | xargs printf "\t[%s] = \"%s\",\n"
21printf "};\n"
22printf "#endif\n"
23