Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3458924pxj; Mon, 24 May 2021 07:14:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdEOsyKIjymOPDO2CVw5RT49MyZJLvthFWsLxZpmZW037c7QE4y4QRV68uVzwX+zeEFWdI X-Received: by 2002:a05:6e02:caf:: with SMTP id 15mr15664701ilg.3.1621865644667; Mon, 24 May 2021 07:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621865644; cv=none; d=google.com; s=arc-20160816; b=HWXuVH9nqsyNtTuvMcPMa1aIlgWB9lx9c4KT5eAPlIjZtcdAAeqcBKrCGzxAyDWVfX cdP6sb848zQBnsuKOc5EF9QloXGfRFsrbu1rUIX1XeKgMjsiBvkGTwxSJr0CqbJMys1k /96635PYGeF8WSXNAiaWSH/czi+cL/rpfkL9dboeYNDVjL3qUY7sY3QCWmIOx9BR80fJ kfMUHEJwGHS2a8LV+ZIiYi2UO1cLl2MVV7/eoB2IQB0Dw7R9pPeRNaW854a335QI5/Wr tWwy2KKNAjJh/JFBr0FXYM1lcQz2XxSGC66oY7+XZ2g8PcJpYbiIK4Cw3m1a4OMN4Q4y KmuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=g9YMGxXWO3gw0lQ0MfPopfjRGds3L9RPAtVucI8oBh8=; b=RjwFNGAiobRA0ws1JEZIFEcZ8ZlpCT+GLvpHuHfdStPH8jjD+NuX4hPHFSxYmkAKXJ MO9s5XHbQWAqe0WagRT1ch5J3I7I8vCeQd4w8JMCaONeTYufcl+XRQEdF8snmtDdZC9c onmA/nuytDqYbe3hRtCsaItZ+Co2F5WREfi8nu/3lWwIgyjxuvE1HH8s80yXwkFEeRY9 FYGc40jP+3Sk/7JLeL20+zHvCBnWq7SeP/NodHfTCuHLcfMfIvOhjiLpNdm0jt3shpu6 BdF3mCaQzBBQLVfsglUy4vucybIUcX3RbyF9DkQ9rgT7n66s1Hv2D5BObIE2XZADnZyv 8OlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QtGD1DYP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v17si15198977jat.82.2021.05.24.07.13.51; Mon, 24 May 2021 07:14:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QtGD1DYP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233069AbhEXONK (ORCPT + 99 others); Mon, 24 May 2021 10:13:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232921AbhEXOMz (ORCPT ); Mon, 24 May 2021 10:12:55 -0400 Received: from mail-vs1-xe29.google.com (mail-vs1-xe29.google.com [IPv6:2607:f8b0:4864:20::e29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BDD3C06138B for ; Mon, 24 May 2021 07:11:26 -0700 (PDT) Received: by mail-vs1-xe29.google.com with SMTP id o192so14283032vsd.7 for ; Mon, 24 May 2021 07:11:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=g9YMGxXWO3gw0lQ0MfPopfjRGds3L9RPAtVucI8oBh8=; b=QtGD1DYPGBFNv8H5o2auNhCqeNje2IV/YM/PBcelPMC5UV8XxqWGu7GXpfiJRCVnzq WxLxargTpqSF2/NatjiW5zKmHYbem4i4ioFqno6XfOIxIzm+OGM5+Zf0cJNzGxwvxTki BpJQq9zMpm4S2H7n2TS2i5waSARq92xas+rvm8tlQPoIEd60AFrMFb5wusacSxskhq4z D0dBJmMkpsyDkqSSyzqaXv+XyNBDgmosENFi/ahz+3syNlrg26pX7mFUfYnQUZ+LeG/e ZL0aS+Jb8aK5XJBbQh4/9sd9bPPWiuNmkweyF6GBz5+k6egoozwtSI/CQpTXHt4w6j/H bI/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=g9YMGxXWO3gw0lQ0MfPopfjRGds3L9RPAtVucI8oBh8=; b=lwNfFLP7cAEpgwdPN5WyTU0qbSsH2Qrp3b0zRtq7GE1QSb0JhjlxEW3jmosTy+oPrc 5/qIShjaK6Z0iPSOhpLmChn5G+22/tHy+PGCeb0Ucy8RxwxtQK/L5YGcDz1vLO7I8JPa mr7U6O49MtyO7tVCsVobJ+hKz6OS7kEMsedeGW3lwyFKuQZ3KROHTzaKOLXuLmIMo6x+ jp5+c5LNkgHmVVXFl9Al2l3QI8vlFRU81lOM0DCgvORrwbtrdSbbBW1RljBFeeHfZEeQ hFbL/Yg2EByuL8gvhhplm3c/xapmwsd9VPIrTB6JTUJgk6UmUER/+wf5xd7PrS+g05Om iVlg== X-Gm-Message-State: AOAM530IJEBxrCd6tp4jY2K7c4x3yy2oCFk+i1P6x5ScY057CI80KGVl ltm013BZl57yBIwY9TUGTtYpg28013BYYcREIe0JOA== X-Received: by 2002:a67:1087:: with SMTP id 129mr20527619vsq.42.1621865485296; Mon, 24 May 2021 07:11:25 -0700 (PDT) MIME-Version: 1.0 References: <20210521034432.2321-1-zbestahu@gmail.com> In-Reply-To: <20210521034432.2321-1-zbestahu@gmail.com> From: Ulf Hansson Date: Mon, 24 May 2021 16:10:47 +0200 Message-ID: Subject: Re: [PATCH] mmc: cqhci: introduce get_trans_desc_offset() To: Yue Hu Cc: Adrian Hunter , Harjani Ritesh , Asutosh Das , linux-mmc , Linux Kernel Mailing List , Yue Hu , zbestahu@163.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 21 May 2021 at 05:44, Yue Hu wrote: > > From: Yue Hu > > 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 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 >