فهرست منبع

msm: ADSPRPC: Use PD type enums instead of magic numbers

Currently PD type is getting updated with some magic numbers. Add
enum with different PD type information and use these types instead
of magic numbers for better code readability.

Change-Id: I20eb03726cabfcc88589be215c3c967b608a9cdb
Acked-by: Ekansh Gupta <[email protected]>
Signed-off-by: Vamsi Krishna Gattupalli <[email protected]>
Vamsi Krishna Gattupalli 2 سال پیش
والد
کامیت
e1f8f88b4b
2فایلهای تغییر یافته به همراه14 افزوده شده و 7 حذف شده
  1. 6 6
      dsp/adsprpc.c
  2. 8 1
      dsp/adsprpc_shared.h

+ 6 - 6
dsp/adsprpc.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 /* Uncomment this block to log an error on every VERIFY failure */
@@ -137,7 +137,7 @@
 #endif
 
 /*
- * ctxid of every message is OR-ed with fl->pd (0/1/2) before
+ * ctxid of every message is OR-ed with fastrpc_remote_pd_type before
  * it is sent to DSP. So mask 2 LSBs to retrieve actual context
  */
 #define CONTEXT_PD_CHECK (3)
@@ -3593,10 +3593,10 @@ static int fastrpc_init_attach_process(struct fastrpc_file *fl,
 	ioctl.job = NULL;
 
 	if (init->flags == FASTRPC_INIT_ATTACH)
-		fl->pd = 0;
+		fl->pd = FASTRPC_ROOT_PD;
 	else if (init->flags == FASTRPC_INIT_ATTACH_SENSORS)
 		/* Setting to 2 will route the message to sensorsPD */
-		fl->pd = 2;
+		fl->pd = FASTRPC_SENSORS_PD;
 
 	err = fastrpc_internal_invoke(fl, FASTRPC_MODE_PARALLEL, KERNEL_MSG_WITH_ZERO_PID, &ioctl);
 	if (err)
@@ -3662,7 +3662,7 @@ static int fastrpc_init_create_dynamic_process(struct fastrpc_file *fl,
 	inbuf.pgid = fl->tgid;
 	inbuf.namelen = strlen(current->comm) + 1;
 	inbuf.filelen = init->filelen;
-	fl->pd = 1;
+	fl->pd = FASTRPC_USER_PD;
 
 	if (uproc->attrs & FASTRPC_MODE_UNSIGNED_MODULE)
 		fl->is_unsigned_pd = true;
@@ -3899,7 +3899,7 @@ static int fastrpc_init_create_static_process(struct fastrpc_file *fl,
 		goto bail;
 	}
 
-	fl->pd = 1;
+	fl->pd = FASTRPC_USER_PD;
 	inbuf.pgid = fl->tgid;
 	inbuf.namelen = init->filelen;
 	inbuf.pageslen = 0;

+ 8 - 1
dsp/adsprpc_shared.h

@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  */
 #ifndef ADSPRPC_SHARED_H
 #define ADSPRPC_SHARED_H
@@ -678,6 +678,13 @@ enum fastrpc_msg_type {
 	KERNEL_MSG_WITH_NONZERO_PID,
 };
 
+/* Fastrpc remote pd type */
+enum fastrpc_remote_pd_type {
+	FASTRPC_ROOT_PD = 0,
+	FASTRPC_USER_PD,
+	FASTRPC_SENSORS_PD,
+};
+
 #define DSPSIGNAL_TIMEOUT_NONE 0xffffffff
 #define DSPSIGNAL_NUM_SIGNALS 1024