[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211001101234.4247-7-arnaud.pouliquen@foss.st.com>
Date: Fri, 1 Oct 2021 12:12:33 +0200
From: Arnaud Pouliquen <arnaud.pouliquen@...s.st.com>
To: Bjorn Andersson <bjorn.andersson@...aro.org>,
Ohad Ben-Cohen <ohad@...ery.com>,
Mathieu Poirier <mathieu.poirier@...aro.org>
CC: <linux-remoteproc@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-stm32@...md-mailman.stormreply.com>,
Rob Herring <robh@...nel.org>, Christoph Hellwig <hch@....de>,
Stefano Stabellini <stefanos@...inx.com>,
Bruce Ashfield <bruce.ashfield@...inx.com>,
<arnaud.pouliquen@...s.st.com>
Subject: [RFC PATCH 6/7] remoteproc: virtio: Add helper to create platform device
Add capability to create platform device for the rproc virtio.
This is a step to move forward the management of the rproc virtio
as an independent device.
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@...s.st.com>
---
drivers/remoteproc/remoteproc_internal.h | 15 ++++++++++
drivers/remoteproc/remoteproc_virtio.c | 36 ++++++++++++++++++++++++
2 files changed, 51 insertions(+)
diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h
index 1b963a8912ed..0bb1b14e5136 100644
--- a/drivers/remoteproc/remoteproc_internal.h
+++ b/drivers/remoteproc/remoteproc_internal.h
@@ -39,11 +39,26 @@ int rproc_of_parse_firmware(struct device *dev, int index,
#if IS_ENABLED(CONFIG_REMOTEPROC_VIRTIO)
int rproc_rvdev_add_device(struct rproc_vdev *rvdev);
+struct platform_device *
+rproc_virtio_register_device(struct rproc *rproc, struct rproc_vdev_data *vdev_data);
+void rproc_virtio_unregister_device(struct rproc_vdev *rvdev);
irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id);
void rproc_vdev_release(struct kref *ref);
#else
+static inline struct platform_device *
+rproc_virtio_register_device(struct rproc *rproc, struct rproc_vdev_data *vdev_data)
+{
+ return ERR_PTR(-ENXIO);
+}
+
+static inline void rproc_virtio_unregister_device(struct rproc_vdev *rvdev)
+{
+ /* This shouldn't be possible */
+ WARN_ON(1);
+}
+
int rproc_rvdev_add_device(struct rproc_vdev *rvdev)
{
/* This shouldn't be possible */
diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
index 9b2ab79e4c4c..7188fb8ce40f 100644
--- a/drivers/remoteproc/remoteproc_virtio.c
+++ b/drivers/remoteproc/remoteproc_virtio.c
@@ -574,6 +574,42 @@ void rproc_vdev_release(struct kref *ref)
rproc_rvdev_remove_device(rvdev);
}
+/**
+ * rproc_virtio_register_device() - register a remoteproc virtio device
+ * @rproc: rproc handle to add the remoteproc virtio device to
+ * @vdev_data: platform device data
+ *
+ * Return: 0 on success, and an appropriate error value otherwise
+ */
+struct platform_device *
+rproc_virtio_register_device(struct rproc *rproc, struct rproc_vdev_data *vdev_data)
+{
+ struct device *dev = &rproc->dev;
+ struct platform_device *pdev;
+
+ pdev = platform_device_register_data(dev, "rproc-virtio", vdev_data->index, vdev_data,
+ sizeof(*vdev_data));
+ if (PTR_ERR_OR_ZERO(pdev)) {
+ dev_err(rproc->dev.parent,
+ "failed to create rproc-virtio device\n");
+ }
+
+ return pdev;
+}
+EXPORT_SYMBOL(rproc_virtio_register_device);
+
+/**
+ * rproc_virtio_unregister_device() - unregister a remoteproc virtio device
+ * @rvdev: remote proc virtio handle to unregister
+ *
+ */
+void rproc_virtio_unregister_device(struct rproc_vdev *rvdev)
+{
+ if (rvdev->pdev)
+ platform_device_unregister(rvdev->pdev);
+}
+EXPORT_SYMBOL(rproc_virtio_unregister_device);
+
static int rproc_virtio_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
--
2.17.1
Powered by blists - more mailing lists