Re: [PATCH v2 4/7] rpmsg: char: Introduce __rpmsg_chrdev_create_eptdev function
From: Mathieu Poirier
Date: Wed Apr 21 2021 - 13:45:43 EST
On Wed, Apr 21, 2021 at 11:43:29AM -0600, Mathieu Poirier wrote:
> On Tue, Apr 13, 2021 at 03:44:55PM +0200, 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@xxxxxxxxxxx>
> >
> > ---
> > update from V1
> > - fix __rpmsg_chrdev_create_eptdev function header indentation.
> >
> > ---
> > drivers/rpmsg/rpmsg_char.c | 23 ++++++++++++++++++-----
> > 1 file changed, 18 insertions(+), 5 deletions(-)
>
> Reviewed-by: Mathieu Poirier <mathieu.poirier@xxxxxxxxxx>
>
Please excuse the brain-bug here - this RB was destined to patch 3/7. I am not sure
about this patch yet (see comment in 5/7).
> >
> > diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c
> > index 21ef9d9eccd7..a64249d83172 100644
> > --- a/drivers/rpmsg/rpmsg_char.c
> > +++ b/drivers/rpmsg/rpmsg_char.c
> > @@ -323,8 +323,9 @@ static void rpmsg_eptdev_release_device(struct device *dev)
> > kfree(eptdev);
> > }
> >
> > -int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent,
> > - struct rpmsg_channel_info chinfo, struct class *rpmsg_class)
> > +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;
> > struct device *dev;
> > @@ -332,7 +333,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;
> > @@ -376,7 +377,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);
> > @@ -386,7 +387,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
> >