Skip to content

Commit fb4679f

Browse files
quic-lxu5gregkh
authored andcommitted
misc: fastrpc: Cleanup the domain names
Currently the domain ids are added for each instance of domains, this is totally not scalable approach. Clean this mess and create domain ids for only domains not its instances. Co-developed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Reviewed-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com> Signed-off-by: Ling Xu <quic_lxu5@quicinc.com> Signed-off-by: Srinivas Kandagatla <srini@kernel.org> Link: https://lore.kernel.org/r/20250912131302.303199-4-srini@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d81c041 commit fb4679f

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

drivers/misc/fastrpc.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
#define MDSP_DOMAIN_ID (1)
2828
#define SDSP_DOMAIN_ID (2)
2929
#define CDSP_DOMAIN_ID (3)
30-
#define CDSP1_DOMAIN_ID (4)
31-
#define FASTRPC_DEV_MAX 5 /* adsp, mdsp, slpi, cdsp, cdsp1 */
3230
#define FASTRPC_MAX_SESSIONS 14
3331
#define FASTRPC_MAX_VMIDS 16
3432
#define FASTRPC_ALIGN 128
@@ -106,8 +104,6 @@
106104

107105
#define miscdev_to_fdevice(d) container_of(d, struct fastrpc_device, miscdev)
108106

109-
static const char *domains[FASTRPC_DEV_MAX] = { "adsp", "mdsp",
110-
"sdsp", "cdsp", "cdsp1" };
111107
struct fastrpc_phy_page {
112108
u64 addr; /* physical address */
113109
u64 size; /* size of contiguous region */
@@ -2243,6 +2239,20 @@ static int fastrpc_device_register(struct device *dev, struct fastrpc_channel_ct
22432239
return err;
22442240
}
22452241

2242+
static int fastrpc_get_domain_id(const char *domain)
2243+
{
2244+
if (!strncmp(domain, "adsp", 4))
2245+
return ADSP_DOMAIN_ID;
2246+
else if (!strncmp(domain, "cdsp", 4))
2247+
return CDSP_DOMAIN_ID;
2248+
else if (!strncmp(domain, "mdsp", 4))
2249+
return MDSP_DOMAIN_ID;
2250+
else if (!strncmp(domain, "sdsp", 4))
2251+
return SDSP_DOMAIN_ID;
2252+
2253+
return -EINVAL;
2254+
}
2255+
22462256
static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
22472257
{
22482258
struct device *rdev = &rpdev->dev;
@@ -2258,15 +2268,10 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
22582268
return err;
22592269
}
22602270

2261-
for (i = 0; i < FASTRPC_DEV_MAX; i++) {
2262-
if (!strcmp(domains[i], domain)) {
2263-
domain_id = i;
2264-
break;
2265-
}
2266-
}
2271+
domain_id = fastrpc_get_domain_id(domain);
22672272

22682273
if (domain_id < 0) {
2269-
dev_info(rdev, "FastRPC Invalid Domain ID %d\n", domain_id);
2274+
dev_info(rdev, "FastRPC Domain %s not supported\n", domain);
22702275
return -EINVAL;
22712276
}
22722277

@@ -2313,21 +2318,20 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
23132318
case ADSP_DOMAIN_ID:
23142319
case MDSP_DOMAIN_ID:
23152320
case SDSP_DOMAIN_ID:
2316-
/* Unsigned PD offloading is only supported on CDSP and CDSP1 */
2321+
/* Unsigned PD offloading is only supported on CDSP */
23172322
data->unsigned_support = false;
2318-
err = fastrpc_device_register(rdev, data, secure_dsp, domains[domain_id]);
2323+
err = fastrpc_device_register(rdev, data, secure_dsp, domain);
23192324
if (err)
23202325
goto err_free_data;
23212326
break;
23222327
case CDSP_DOMAIN_ID:
2323-
case CDSP1_DOMAIN_ID:
23242328
data->unsigned_support = true;
23252329
/* Create both device nodes so that we can allow both Signed and Unsigned PD */
2326-
err = fastrpc_device_register(rdev, data, true, domains[domain_id]);
2330+
err = fastrpc_device_register(rdev, data, true, domain);
23272331
if (err)
23282332
goto err_free_data;
23292333

2330-
err = fastrpc_device_register(rdev, data, false, domains[domain_id]);
2334+
err = fastrpc_device_register(rdev, data, false, domain);
23312335
if (err)
23322336
goto err_deregister_fdev;
23332337
break;

0 commit comments

Comments
 (0)