diff mbox series

[net-next,v2,04/17] soc: fsl: qe: add cpm_muram_free_addr() helper

Message ID 20210119150802.19997-5-rasmus.villemoes@prevas.dk (mailing list archive)
State Accepted
Commit 186b8daffb4ec2dabb8a3d93b329b16152a5a100
Delegated to: Netdev Maintainers
Headers show
Series ucc_geth improvements | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count fail Series longer than 15 patches
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 3 maintainers not CCed: linuxppc-dev@lists.ozlabs.org gustavoars@kernel.org linux-arm-kernel@lists.infradead.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 98 this patch: 98
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch warning CHECK: Please use a blank line after function/struct/union/enum declarations
netdev/build_allmodconfig_warn success Errors and warnings before: 97 this patch: 97
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Rasmus Villemoes Jan. 19, 2021, 3:07 p.m. UTC
Add a helper that takes a virtual address rather than the muram
offset. This will be used in a couple of places to avoid having to
store both the offset and the virtual address, as well as removing
NULL checks from the callers.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 drivers/soc/fsl/qe/qe_common.c | 12 ++++++++++++
 include/soc/fsl/qe/qe.h        |  5 +++++
 2 files changed, 17 insertions(+)

Comments

Leo Li Jan. 19, 2021, 6:46 p.m. UTC | #1
On Tue, Jan 19, 2021 at 9:21 AM Rasmus Villemoes
<rasmus.villemoes@prevas.dk> wrote:
>
> Add a helper that takes a virtual address rather than the muram
> offset. This will be used in a couple of places to avoid having to
> store both the offset and the virtual address, as well as removing
> NULL checks from the callers.
>
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>

Acked-by: Li Yang <leoyang.li@nxp.com>

> ---
>  drivers/soc/fsl/qe/qe_common.c | 12 ++++++++++++
>  include/soc/fsl/qe/qe.h        |  5 +++++
>  2 files changed, 17 insertions(+)
>
> diff --git a/drivers/soc/fsl/qe/qe_common.c b/drivers/soc/fsl/qe/qe_common.c
> index 303cc2f5eb4a..448ef7f5321a 100644
> --- a/drivers/soc/fsl/qe/qe_common.c
> +++ b/drivers/soc/fsl/qe/qe_common.c
> @@ -238,3 +238,15 @@ dma_addr_t cpm_muram_dma(void __iomem *addr)
>         return muram_pbase + (addr - muram_vbase);
>  }
>  EXPORT_SYMBOL(cpm_muram_dma);
> +
> +/*
> + * As cpm_muram_free, but takes the virtual address rather than the
> + * muram offset.
> + */
> +void cpm_muram_free_addr(const void __iomem *addr)
> +{
> +       if (!addr)
> +               return;
> +       cpm_muram_free(cpm_muram_offset(addr));
> +}
> +EXPORT_SYMBOL(cpm_muram_free_addr);
> diff --git a/include/soc/fsl/qe/qe.h b/include/soc/fsl/qe/qe.h
> index 8ee3747433c0..66f1afc393d1 100644
> --- a/include/soc/fsl/qe/qe.h
> +++ b/include/soc/fsl/qe/qe.h
> @@ -104,6 +104,7 @@ s32 cpm_muram_alloc_fixed(unsigned long offset, unsigned long size);
>  void __iomem *cpm_muram_addr(unsigned long offset);
>  unsigned long cpm_muram_offset(const void __iomem *addr);
>  dma_addr_t cpm_muram_dma(void __iomem *addr);
> +void cpm_muram_free_addr(const void __iomem *addr);
>  #else
>  static inline s32 cpm_muram_alloc(unsigned long size,
>                                   unsigned long align)
> @@ -135,6 +136,9 @@ static inline dma_addr_t cpm_muram_dma(void __iomem *addr)
>  {
>         return 0;
>  }
> +static inline void cpm_muram_free_addr(const void __iomem *addr)
> +{
> +}
>  #endif /* defined(CONFIG_CPM) || defined(CONFIG_QUICC_ENGINE) */
>
>  /* QE PIO */
> @@ -239,6 +243,7 @@ static inline int qe_alive_during_sleep(void)
>  #define qe_muram_addr cpm_muram_addr
>  #define qe_muram_offset cpm_muram_offset
>  #define qe_muram_dma cpm_muram_dma
> +#define qe_muram_free_addr cpm_muram_free_addr
>
>  #ifdef CONFIG_PPC32
>  #define qe_iowrite8(val, addr)     out_8(addr, val)
> --
> 2.23.0
>
diff mbox series

Patch

diff --git a/drivers/soc/fsl/qe/qe_common.c b/drivers/soc/fsl/qe/qe_common.c
index 303cc2f5eb4a..448ef7f5321a 100644
--- a/drivers/soc/fsl/qe/qe_common.c
+++ b/drivers/soc/fsl/qe/qe_common.c
@@ -238,3 +238,15 @@  dma_addr_t cpm_muram_dma(void __iomem *addr)
 	return muram_pbase + (addr - muram_vbase);
 }
 EXPORT_SYMBOL(cpm_muram_dma);
+
+/*
+ * As cpm_muram_free, but takes the virtual address rather than the
+ * muram offset.
+ */
+void cpm_muram_free_addr(const void __iomem *addr)
+{
+	if (!addr)
+		return;
+	cpm_muram_free(cpm_muram_offset(addr));
+}
+EXPORT_SYMBOL(cpm_muram_free_addr);
diff --git a/include/soc/fsl/qe/qe.h b/include/soc/fsl/qe/qe.h
index 8ee3747433c0..66f1afc393d1 100644
--- a/include/soc/fsl/qe/qe.h
+++ b/include/soc/fsl/qe/qe.h
@@ -104,6 +104,7 @@  s32 cpm_muram_alloc_fixed(unsigned long offset, unsigned long size);
 void __iomem *cpm_muram_addr(unsigned long offset);
 unsigned long cpm_muram_offset(const void __iomem *addr);
 dma_addr_t cpm_muram_dma(void __iomem *addr);
+void cpm_muram_free_addr(const void __iomem *addr);
 #else
 static inline s32 cpm_muram_alloc(unsigned long size,
 				  unsigned long align)
@@ -135,6 +136,9 @@  static inline dma_addr_t cpm_muram_dma(void __iomem *addr)
 {
 	return 0;
 }
+static inline void cpm_muram_free_addr(const void __iomem *addr)
+{
+}
 #endif /* defined(CONFIG_CPM) || defined(CONFIG_QUICC_ENGINE) */
 
 /* QE PIO */
@@ -239,6 +243,7 @@  static inline int qe_alive_during_sleep(void)
 #define qe_muram_addr cpm_muram_addr
 #define qe_muram_offset cpm_muram_offset
 #define qe_muram_dma cpm_muram_dma
+#define qe_muram_free_addr cpm_muram_free_addr
 
 #ifdef CONFIG_PPC32
 #define qe_iowrite8(val, addr)     out_8(addr, val)