diff mbox series

[4/7] rpmsg: char: Introduce __rpmsg_chrdev_create_eptdev function

Message ID 20210323122737.23035-5-arnaud.pouliquen@foss.st.com
State New
Headers show
Series Restructure the rpmsg char and introduce the rpmsg-raw channel | expand

Commit Message

Arnaud POULIQUEN March 23, 2021, 12:27 p.m. UTC
Introduce the __rpmsg_chrdev_create_eptdev internal function that returns
the rpmsg_eptdev context structure.

This patch prepares the introduction of a rpmsg channel device for the
char device. The rpmsg device will need a reference to the context.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>

---
update from [1]
- propagate parent param in rpmsg_chrdev_create_eptdev,
- fix changelog.

[1] https://patchwork.kernel.org/project/linux-remoteproc/patch/20210219111501.14261-14-arnaud.pouliquen@foss.st.com/
---
 drivers/rpmsg/rpmsg_char.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

Comments

Mathieu Poirier April 9, 2021, 5:53 p.m. UTC | #1
On Tue, Mar 23, 2021 at 01:27:34PM +0100, Arnaud Pouliquen wrote:
> Introduce the __rpmsg_chrdev_create_eptdev internal function that returns

> the rpmsg_eptdev context structure.

> 

> This patch prepares the introduction of a rpmsg channel device for the

> char device. The rpmsg device will need a reference to the context.

> 

> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>

> 

> ---

> update from [1]

> - propagate parent param in rpmsg_chrdev_create_eptdev,

> - fix changelog.

> 

> [1] https://patchwork.kernel.org/project/linux-remoteproc/patch/20210219111501.14261-14-arnaud.pouliquen@foss.st.com/

> ---

>  drivers/rpmsg/rpmsg_char.c | 21 +++++++++++++++++----

>  1 file changed, 17 insertions(+), 4 deletions(-)

> 

> diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c

> index 5d4a768002ce..7f6d46078179 100644

> --- a/drivers/rpmsg/rpmsg_char.c

> +++ b/drivers/rpmsg/rpmsg_char.c

> @@ -325,7 +325,8 @@ static void rpmsg_eptdev_release_device(struct device *dev)

>  	kfree(eptdev);

>  }

>  

> -int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent,

> +static struct rpmsg_eptdev *__rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev,

> +							 struct device *parent,

>  			       struct rpmsg_channel_info chinfo, struct class *rpmsg_class)


Please fix:

static struct rpmsg_eptdev *
__rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent,
                             struct rpmsg_channel_info chinfo, struct class *rpmsg_class)

>  {

>  	struct rpmsg_eptdev *eptdev;

> @@ -334,7 +335,7 @@ int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent

>  

>  	eptdev = kzalloc(sizeof(*eptdev), GFP_KERNEL);

>  	if (!eptdev)

> -		return -ENOMEM;

> +		return ERR_PTR(-ENOMEM);

>  

>  	dev = &eptdev->dev;

>  	eptdev->rpdev = rpdev;

> @@ -378,7 +379,7 @@ int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent

>  		put_device(dev);

>  	}

>  

> -	return ret;

> +	return eptdev;

>  

>  free_ept_ida:

>  	ida_simple_remove(&rpmsg_ept_ida, dev->id);

> @@ -388,7 +389,19 @@ int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent

>  	put_device(dev);

>  	kfree(eptdev);

>  

> -	return ret;

> +	return ERR_PTR(ret);

> +}

> +

> +int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent,

> +			       struct rpmsg_channel_info chinfo,  struct class *rpmsg_class)

> +{

> +	struct rpmsg_eptdev *eptdev;

> +

> +	eptdev = __rpmsg_chrdev_create_eptdev(rpdev, parent, chinfo, rpmsg_class);

> +	if (IS_ERR(eptdev))

> +		return PTR_ERR(eptdev);

> +

> +	return 0;

>  }

>  EXPORT_SYMBOL(rpmsg_chrdev_create_eptdev);

>  

> -- 

> 2.17.1

>
diff mbox series

Patch

diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c
index 5d4a768002ce..7f6d46078179 100644
--- a/drivers/rpmsg/rpmsg_char.c
+++ b/drivers/rpmsg/rpmsg_char.c
@@ -325,7 +325,8 @@  static void rpmsg_eptdev_release_device(struct device *dev)
 	kfree(eptdev);
 }
 
-int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent,
+static struct rpmsg_eptdev *__rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev,
+							 struct device *parent,
 			       struct rpmsg_channel_info chinfo, struct class *rpmsg_class)
 {
 	struct rpmsg_eptdev *eptdev;
@@ -334,7 +335,7 @@  int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent
 
 	eptdev = kzalloc(sizeof(*eptdev), GFP_KERNEL);
 	if (!eptdev)
-		return -ENOMEM;
+		return ERR_PTR(-ENOMEM);
 
 	dev = &eptdev->dev;
 	eptdev->rpdev = rpdev;
@@ -378,7 +379,7 @@  int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent
 		put_device(dev);
 	}
 
-	return ret;
+	return eptdev;
 
 free_ept_ida:
 	ida_simple_remove(&rpmsg_ept_ida, dev->id);
@@ -388,7 +389,19 @@  int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent
 	put_device(dev);
 	kfree(eptdev);
 
-	return ret;
+	return ERR_PTR(ret);
+}
+
+int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent,
+			       struct rpmsg_channel_info chinfo,  struct class *rpmsg_class)
+{
+	struct rpmsg_eptdev *eptdev;
+
+	eptdev = __rpmsg_chrdev_create_eptdev(rpdev, parent, chinfo, rpmsg_class);
+	if (IS_ERR(eptdev))
+		return PTR_ERR(eptdev);
+
+	return 0;
 }
 EXPORT_SYMBOL(rpmsg_chrdev_create_eptdev);