mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 13:27:01 +08:00
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:
@@ -35,8 +35,8 @@
|
|||||||
* Pre-processor definitions
|
* Pre-processor definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define RPMSGDEV_NAME_PREFIX "rpdev-"
|
#define RPMSGDEV_NAME_PREFIX "rpdev"
|
||||||
#define RPMSGDEV_NAME_PREFIX_LEN 6
|
#define RPMSGDEV_NAME_PREFIX_LEN 5
|
||||||
|
|
||||||
#define RPMSGDEV_OPEN 1
|
#define RPMSGDEV_OPEN 1
|
||||||
#define RPMSGDEV_CLOSE 2
|
#define RPMSGDEV_CLOSE 2
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ struct rpmsgdev_server_s
|
|||||||
struct rpmsgdev_export_s
|
struct rpmsgdev_export_s
|
||||||
{
|
{
|
||||||
FAR const char *remotecpu; /* The client cpu name */
|
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 */
|
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,
|
msg->header.result = file_open(&dev->file,
|
||||||
&ept->name[RPMSGDEV_NAME_PREFIX_LEN],
|
strchr(ept->name, '/'),
|
||||||
msg->flags, 0);
|
msg->flags, 0);
|
||||||
if (msg->header.result < 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)
|
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);
|
priv->localpath);
|
||||||
rpmsgdev_ns_bind(rdev, priv, buf, RPMSG_ADDR_ANY);
|
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
|
* 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;
|
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->remotecpu = remotecpu;
|
||||||
|
priv->prefix = prefix;
|
||||||
priv->localpath = localpath;
|
priv->localpath = localpath;
|
||||||
|
|
||||||
return rpmsg_register_callback(priv,
|
return rpmsg_register_callback(priv,
|
||||||
@@ -552,6 +556,13 @@ int rpmsgdev_export(FAR const char *remotecpu, FAR const char *localpath)
|
|||||||
NULL);
|
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
|
* Name: rpmsgdev_server_init
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -66,6 +66,9 @@ extern "C"
|
|||||||
#ifdef CONFIG_DEV_RPMSG_SERVER
|
#ifdef CONFIG_DEV_RPMSG_SERVER
|
||||||
int rpmsgdev_server_init(void);
|
int rpmsgdev_server_init(void);
|
||||||
int rpmsgdev_export(FAR const char *remotecpu, FAR const char *localpath);
|
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
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user