drivers/rpmsg: add slash check for sepical rpmsg dev

rpmsgdev match name too long, so add prefix

Signed-off-by: rongyichang <rongyichang@xiaomi.com>
This commit is contained in:
rongyichang
2024-10-10 14:19:18 +08:00
committed by Xiang Xiao
parent ea1e38ef92
commit 0b544d3359
3 changed files with 19 additions and 5 deletions
+2 -2
View File
@@ -35,8 +35,8 @@
* Pre-processor definitions
****************************************************************************/
#define RPMSGDEV_NAME_PREFIX "rpdev-"
#define RPMSGDEV_NAME_PREFIX_LEN 6
#define RPMSGDEV_NAME_PREFIX "rpdev"
#define RPMSGDEV_NAME_PREFIX_LEN 5
#define RPMSGDEV_OPEN 1
#define RPMSGDEV_CLOSE 2
+14 -3
View File
@@ -73,6 +73,7 @@ struct rpmsgdev_server_s
struct rpmsgdev_export_s
{
FAR const char *remotecpu; /* The client cpu name */
FAR const char *prefix; /* The device prefix */
FAR const char *localpath; /* The device path in the server cpu */
};
@@ -160,7 +161,7 @@ static int rpmsgdev_open_handler(FAR struct rpmsg_endpoint *ept,
}
msg->header.result = file_open(&dev->file,
&ept->name[RPMSGDEV_NAME_PREFIX_LEN],
strchr(ept->name, '/'),
msg->flags, 0);
if (msg->header.result < 0)
{
@@ -522,7 +523,7 @@ static void rpmsgdev_server_created(FAR struct rpmsg_device *rdev,
if (strcmp(priv->remotecpu, rpmsg_get_cpuname(rdev)) == 0)
{
snprintf(buf, sizeof(buf), "%s%s", RPMSGDEV_NAME_PREFIX,
snprintf(buf, sizeof(buf), "%s%s", priv->prefix,
priv->localpath);
rpmsgdev_ns_bind(rdev, priv, buf, RPMSG_ADDR_ANY);
}
@@ -532,7 +533,9 @@ static void rpmsgdev_server_created(FAR struct rpmsg_device *rdev,
* Public Functions
****************************************************************************/
int rpmsgdev_export(FAR const char *remotecpu, FAR const char *localpath)
int rpmsgdev_export_with_prefix(FAR const char *remotecpu,
FAR const char *prefix,
FAR const char *localpath)
{
FAR struct rpmsgdev_export_s *priv;
@@ -543,6 +546,7 @@ int rpmsgdev_export(FAR const char *remotecpu, FAR const char *localpath)
}
priv->remotecpu = remotecpu;
priv->prefix = prefix;
priv->localpath = localpath;
return rpmsg_register_callback(priv,
@@ -552,6 +556,13 @@ int rpmsgdev_export(FAR const char *remotecpu, FAR const char *localpath)
NULL);
}
int rpmsgdev_export(FAR const char *remotecpu, FAR const char *localpath)
{
return rpmsgdev_export_with_prefix(remotecpu,
RPMSGDEV_NAME_PREFIX,
localpath);
}
/****************************************************************************
* Name: rpmsgdev_server_init
*
+3
View File
@@ -66,6 +66,9 @@ extern "C"
#ifdef CONFIG_DEV_RPMSG_SERVER
int rpmsgdev_server_init(void);
int rpmsgdev_export(FAR const char *remotecpu, FAR const char *localpath);
int rpmsgdev_export_with_prefix(FAR const char *remotecpu,
FAR const char *prefix,
FAR const char *localpath);
#endif
/****************************************************************************