All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: cqhci: introduce get_trans_desc_offset()
@ 2021-05-21  3:44 Yue Hu
  2021-05-24 14:10 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Yue Hu @ 2021-05-21  3:44 UTC (permalink / raw)
  To: adrian.hunter, riteshh, asutoshd, ulf.hansson
  Cc: linux-mmc, linux-kernel, huyue2, zbestahu

From: Yue Hu <huyue2@yulong.com>

The same calculation to get transfer descriptor offset is already used
at 3 different locations. Let's create a new helper to simplify code.

Signed-off-by: Yue Hu <huyue2@yulong.com>
---
 drivers/mmc/host/cqhci-core.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/host/cqhci-core.c b/drivers/mmc/host/cqhci-core.c
index c237b6e..1128dd5 100644
--- a/drivers/mmc/host/cqhci-core.c
+++ b/drivers/mmc/host/cqhci-core.c
@@ -45,17 +45,23 @@ static inline u8 *get_link_desc(struct cqhci_host *cq_host, u8 tag)
 	return desc + cq_host->task_desc_len;
 }
 
+static inline size_t get_trans_desc_offset(struct cqhci_host *cq_host, u8 tag)
+{
+	return cq_host->trans_desc_len * cq_host->mmc->max_segs * tag;
+}
+
 static inline dma_addr_t get_trans_desc_dma(struct cqhci_host *cq_host, u8 tag)
 {
-	return cq_host->trans_desc_dma_base +
-		(cq_host->mmc->max_segs * tag *
-		 cq_host->trans_desc_len);
+	size_t offset = get_trans_desc_offset(cq_host, tag);
+
+	return cq_host->trans_desc_dma_base + offset;
 }
 
 static inline u8 *get_trans_desc(struct cqhci_host *cq_host, u8 tag)
 {
-	return cq_host->trans_desc_base +
-		(cq_host->trans_desc_len * cq_host->mmc->max_segs * tag);
+	size_t offset = get_trans_desc_offset(cq_host, tag);
+
+	return cq_host->trans_desc_base + offset;
 }
 
 static void setup_trans_desc(struct cqhci_host *cq_host, u8 tag)
@@ -194,8 +200,7 @@ static int cqhci_host_alloc_tdl(struct cqhci_host *cq_host)
 
 	cq_host->desc_size = cq_host->slot_sz * cq_host->num_slots;
 
-	cq_host->data_size = cq_host->trans_desc_len * cq_host->mmc->max_segs *
-		cq_host->mmc->cqe_qdepth;
+	cq_host->data_size = get_trans_desc_offset(cq_host, cq_host->mmc->cqe_qdepth);
 
 	pr_debug("%s: cqhci: desc_size: %zu data_sz: %zu slot-sz: %d\n",
 		 mmc_hostname(cq_host->mmc), cq_host->desc_size, cq_host->data_size,
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mmc: cqhci: introduce get_trans_desc_offset()
  2021-05-21  3:44 [PATCH] mmc: cqhci: introduce get_trans_desc_offset() Yue Hu
@ 2021-05-24 14:10 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2021-05-24 14:10 UTC (permalink / raw)
  To: Yue Hu
  Cc: Adrian Hunter, Harjani Ritesh, Asutosh Das, linux-mmc,
	Linux Kernel Mailing List, Yue Hu, zbestahu

On Fri, 21 May 2021 at 05:44, Yue Hu <zbestahu@gmail.com> wrote:
>
> From: Yue Hu <huyue2@yulong.com>
>
> The same calculation to get transfer descriptor offset is already used
> at 3 different locations. Let's create a new helper to simplify code.
>
> Signed-off-by: Yue Hu <huyue2@yulong.com>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/cqhci-core.c | 19 ++++++++++++-------
>  1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/mmc/host/cqhci-core.c b/drivers/mmc/host/cqhci-core.c
> index c237b6e..1128dd5 100644
> --- a/drivers/mmc/host/cqhci-core.c
> +++ b/drivers/mmc/host/cqhci-core.c
> @@ -45,17 +45,23 @@ static inline u8 *get_link_desc(struct cqhci_host *cq_host, u8 tag)
>         return desc + cq_host->task_desc_len;
>  }
>
> +static inline size_t get_trans_desc_offset(struct cqhci_host *cq_host, u8 tag)
> +{
> +       return cq_host->trans_desc_len * cq_host->mmc->max_segs * tag;
> +}
> +
>  static inline dma_addr_t get_trans_desc_dma(struct cqhci_host *cq_host, u8 tag)
>  {
> -       return cq_host->trans_desc_dma_base +
> -               (cq_host->mmc->max_segs * tag *
> -                cq_host->trans_desc_len);
> +       size_t offset = get_trans_desc_offset(cq_host, tag);
> +
> +       return cq_host->trans_desc_dma_base + offset;
>  }
>
>  static inline u8 *get_trans_desc(struct cqhci_host *cq_host, u8 tag)
>  {
> -       return cq_host->trans_desc_base +
> -               (cq_host->trans_desc_len * cq_host->mmc->max_segs * tag);
> +       size_t offset = get_trans_desc_offset(cq_host, tag);
> +
> +       return cq_host->trans_desc_base + offset;
>  }
>
>  static void setup_trans_desc(struct cqhci_host *cq_host, u8 tag)
> @@ -194,8 +200,7 @@ static int cqhci_host_alloc_tdl(struct cqhci_host *cq_host)
>
>         cq_host->desc_size = cq_host->slot_sz * cq_host->num_slots;
>
> -       cq_host->data_size = cq_host->trans_desc_len * cq_host->mmc->max_segs *
> -               cq_host->mmc->cqe_qdepth;
> +       cq_host->data_size = get_trans_desc_offset(cq_host, cq_host->mmc->cqe_qdepth);
>
>         pr_debug("%s: cqhci: desc_size: %zu data_sz: %zu slot-sz: %d\n",
>                  mmc_hostname(cq_host->mmc), cq_host->desc_size, cq_host->data_size,
> --
> 1.9.1
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-24 14:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-21  3:44 [PATCH] mmc: cqhci: introduce get_trans_desc_offset() Yue Hu
2021-05-24 14:10 ` Ulf Hansson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.