lkml.org 
[lkml]   [2020]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC 07/18] remoteproc: Add component bind/unbind for virtio platform
    Date
    Add component to declare bind and unbind functions. Theses functions
    are used to ensure that the remoteproc virtio device is probed
    and registered as a subdev of the rproc device before rproc
    request the the prepare and start of the subdevice.

    Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
    ---
    drivers/remoteproc/remoteproc_virtio.c | 23 +++++++++++++++++++----
    1 file changed, 19 insertions(+), 4 deletions(-)

    diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
    index 2a0f33ccd929..e1d7371d2d64 100644
    --- a/drivers/remoteproc/remoteproc_virtio.c
    +++ b/drivers/remoteproc/remoteproc_virtio.c
    @@ -10,6 +10,7 @@
    * Brian Swetland <swetland@google.com>
    */

    +#include <linux/component.h>
    #include <linux/dma-mapping.h>
    #include <linux/export.h>
    #include <linux/module.h>
    @@ -426,7 +427,8 @@ static const struct rproc_subdev rproc_virtio_subdev = {
    .stop = rproc_vitio_stop
    };

    -static int rproc_virtio_bind(struct device *dev)
    +static int rproc_virtio_bind(struct device *dev, struct device *master,
    + void *data)
    {
    struct rproc_vdev *rvdev = dev_get_drvdata(dev);
    struct rproc *rproc = rvdev->rproc;
    @@ -483,7 +485,8 @@ static int rproc_virtio_bind(struct device *dev)
    return ret;
    }

    -static void rproc_virtio_unbind(struct device *dev)
    +static void rproc_virtio_unbind(struct device *dev, struct device *master,
    + void *data)
    {
    struct rproc_vdev *rvdev = dev_get_drvdata(dev);
    struct rproc *rproc = rvdev->rproc;
    @@ -504,6 +507,11 @@ static void rproc_virtio_unbind(struct device *dev)
    dev_dbg(dev, "virtio dev %d unbound\n", rvdev->index);
    }

    +static const struct component_ops rproc_virtio_ops = {
    + .bind = rproc_virtio_bind,
    + .unbind = rproc_virtio_unbind,
    +};
    +
    static int rproc_virtio_probe(struct platform_device *pdev)
    {
    struct device *dev = &pdev->dev;
    @@ -548,14 +556,21 @@ static int rproc_virtio_probe(struct platform_device *pdev)

    platform_set_drvdata(pdev, rvdev);

    + ret = component_add(&pdev->dev, &rproc_virtio_ops);
    + if (ret)
    + return ret;
    +
    rproc_register_rvdev(rproc, rvdev);

    - return rproc_virtio_bind(dev);
    + return 0;
    }

    static int rproc_virtio_remove(struct platform_device *pdev)
    {
    - rproc_virtio_unbind(&pdev->dev);
    + struct rproc_vdev *rvdev = dev_get_drvdata(&pdev->dev);
    +
    + component_del(&pdev->dev, &rproc_virtio_ops);
    + rproc_unregister_rvdev(rvdev);

    return 0;
    }
    --
    2.17.1
    \
     
     \ /
      Last update: 2020-04-16 18:14    [W:4.260 / U:0.012 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site