Several remoteproc drivers open-code the same ioremap_wc() and iounmap() callbacks for carveout mappings. Add subsystem-private helpers in remoteproc_internal.h so those drivers can share the same implementation.
Signed-off-by: Ben Levinsky <[email protected]> --- drivers/remoteproc/remoteproc_internal.h | 26 +++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 0a5e15744b1d..3724a47a9748 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -12,8 +12,9 @@ #ifndef REMOTEPROC_INTERNAL_H #define REMOTEPROC_INTERNAL_H -#include <linux/irqreturn.h> #include <linux/firmware.h> +#include <linux/io.h> +#include <linux/irqreturn.h> struct rproc; @@ -122,6 +123,29 @@ rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...); void rproc_add_rvdev(struct rproc *rproc, struct rproc_vdev *rvdev); void rproc_remove_rvdev(struct rproc_vdev *rvdev); +static inline int rproc_mem_entry_ioremap_wc(struct rproc *rproc, + struct rproc_mem_entry *mem) +{ + void __iomem *va; + + va = ioremap_wc(mem->dma, mem->len); + if (!va) + return -ENOMEM; + + mem->va = (__force void *)va; + mem->is_iomem = true; + + return 0; +} + +static inline int rproc_mem_entry_iounmap(struct rproc *rproc, + struct rproc_mem_entry *mem) +{ + iounmap((__force __iomem void *)mem->va); + + return 0; +} + static inline int rproc_prepare_device(struct rproc *rproc) { if (rproc->ops->prepare) -- 2.34.1

