From 24c3eea173d33e14afd4d258c40e121bb471850b Mon Sep 17 00:00:00 2001 From: Richard Acayan Date: Mon, 18 Dec 2023 20:02:15 -0500 Subject: [PATCH] fastrpc: hexagonrpcd: reword usage text and print on missing option Remove the brackets around the -f option which imply that it is optional. The default value is a NULL pointer. FastRPC is not specialized to serving files to the DSPs and can do other things such as logging and profiling, pending discovery. Change the description of the program accordingly. Referring to a "FastRPC node" is a bit vague and misses the detail that the program is expecting a path to a file (a device node). Refer to the file as a FastRPC device node so the user can intuitively look for what the program wants. The letter in the -R option was seemingly chosen arbitrarily. Add the word which it originated from ("root") to make it memorable. The INIT_ATTACH and INIT_ATTACH_SNS terms have no meaning in the usage text. They are terms of jargon originating in the userspace API for the Linux kernel driver, as abbreviations of FASTRPC_IOCTL_INIT_ATTACH and FASTRPC_IOCTL_INIT_ATTACH_SNS. It is unclear what the difference is between the two, and SNS is ambiguous with no clear connection to sensors (did Qualcomm design some DSP communication protocol around a Social Networking Service?). Instead of deriving terms used to inform the driver how to interact with the DSP, use the name of the PD ("sensorspd") and describe the effective interaction with the DSP. If the file name for the FastRPC device node is a NULL pointer, then the error message always prints out a NULL pointer, made redundant by the word "invalid". An unspecified device node is an error made by the user, and the usage text should be given to the user instead of an internal diagnosis of invalid usage. --- fastrpc/hexagonrpcd/rpcd.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/fastrpc/hexagonrpcd/rpcd.c b/fastrpc/hexagonrpcd/rpcd.c index b841fb3..ec5ecc0 100644 --- a/fastrpc/hexagonrpcd/rpcd.c +++ b/fastrpc/hexagonrpcd/rpcd.c @@ -143,6 +143,17 @@ err: return ret; } +static void print_usage(const char *argv0) +{ + printf("Usage: %s [options] -f DEVICE\n\n", argv0); + printf("Server for FastRPC remote procedure calls from Qualcomm DSPs\n\n" + "Options:\n" + "\t-d DSP\t\tDSP name (default: adsp)\n" + "\t-f DEVICE\tFastRPC device node to attach to\n" + "\t-R DIR\t\tRoot directory of served files (default: /usr/share/qcom/)\n" + "\t-s\t\tAttach to sensorspd\n"); +} + static void *start_reverse_tunnel(void *data) { struct listener_thread_args *args = data; @@ -244,18 +255,13 @@ int main(int argc, char* argv[]) attach_sns = true; break; default: - printf("Usage: %s [-s] [-f FastRPC node]\n\n", argv[0]); - printf("Qualcomm Hexagon filesystem daemon\n\n" - "\t-d\tDSP libraries subdirectory (default: adsp)\n" - "\t-f\tFastRPC node to attach to\n" - "\t-R\tDirectory of served files (default: /usr/share/qcom/)\n" - "\t-s\tUse INIT_ATTACH_SNS instead of INIT_ATTACH ioctl\n"); + print_usage(argv[0]); return 1; } } if (!fastrpc_node) { - fprintf(stderr, "Invalid FastRPC node: %s\n", fastrpc_node); + print_usage(argv[0]); return 2; }