2020-03-26 16:51:28

by Rishabh Bhatnagar

[permalink] [raw]
Subject: [PATCH 2/2] remoteproc: core: Register the character device interface

Add the character device during rproc_add. This would create
a character device node at /dev/subsys_<rproc_name>. Userspace
applications can interact with the remote processor using this
interface rather than using sysfs node. To distinguish between
different remote processor nodes the device name has been changed
to include the rproc name appended to "rproc_" string.

Change-Id: I2114f77f8d2b5fd97e281021ec9905ef5c2fb54c
Signed-off-by: Rishabh Bhatnagar <[email protected]>
---
drivers/remoteproc/remoteproc_core.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 097f33e..f657983 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1907,6 +1907,12 @@ int rproc_add(struct rproc *rproc)
struct device *dev = &rproc->dev;
int ret;

+ ret = rproc_char_device_add(rproc);
+ if (ret) {
+ pr_err("error while adding character device\n");
+ return ret;
+ }
+
ret = device_add(dev);
if (ret < 0)
return ret;
@@ -2044,7 +2050,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
return NULL;
}

- dev_set_name(&rproc->dev, "remoteproc%d", rproc->index);
+ dev_set_name(&rproc->dev, "rproc_%s", rproc->name);

atomic_set(&rproc->power, 0);

@@ -2220,6 +2226,7 @@ static int __init remoteproc_init(void)
{
rproc_init_sysfs();
rproc_init_debugfs();
+ rproc_init_cdev();

return 0;
}
@@ -2231,6 +2238,7 @@ static void __exit remoteproc_exit(void)

rproc_exit_debugfs();
rproc_exit_sysfs();
+ rproc_exit_cdev();
}
module_exit(remoteproc_exit);

--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


2020-03-30 22:26:26

by Mathieu Poirier

[permalink] [raw]
Subject: Re: [PATCH 2/2] remoteproc: core: Register the character device interface

On Thu, Mar 26, 2020 at 09:50:40AM -0700, Rishabh Bhatnagar wrote:
> Add the character device during rproc_add. This would create
> a character device node at /dev/subsys_<rproc_name>. Userspace
> applications can interact with the remote processor using this
> interface rather than using sysfs node. To distinguish between
> different remote processor nodes the device name has been changed
> to include the rproc name appended to "rproc_" string.
>
> Change-Id: I2114f77f8d2b5fd97e281021ec9905ef5c2fb54c
> Signed-off-by: Rishabh Bhatnagar <[email protected]>
> ---
> drivers/remoteproc/remoteproc_core.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index 097f33e..f657983 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -1907,6 +1907,12 @@ int rproc_add(struct rproc *rproc)
> struct device *dev = &rproc->dev;
> int ret;
>
> + ret = rproc_char_device_add(rproc);
> + if (ret) {
> + pr_err("error while adding character device\n");
> + return ret;
> + }
> +
> ret = device_add(dev);
> if (ret < 0)
> return ret;
> @@ -2044,7 +2050,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
> return NULL;
> }
>
> - dev_set_name(&rproc->dev, "remoteproc%d", rproc->index);
> + dev_set_name(&rproc->dev, "rproc_%s", rproc->name);

Unfortunately you can't do that. The name of the remoteproc in sysfs is visible
by users and a lot of scripts will fail because of this change.

>
> atomic_set(&rproc->power, 0);
>
> @@ -2220,6 +2226,7 @@ static int __init remoteproc_init(void)
> {
> rproc_init_sysfs();
> rproc_init_debugfs();
> + rproc_init_cdev();
>
> return 0;
> }
> @@ -2231,6 +2238,7 @@ static void __exit remoteproc_exit(void)
>
> rproc_exit_debugfs();
> rproc_exit_sysfs();
> + rproc_exit_cdev();
> }
> module_exit(remoteproc_exit);
>
> --
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project