Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp949720pxb; Wed, 3 Mar 2021 22:12:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+1H6vIAJyk+09Pej4dwVq3TmQ8z/eiLCX1Fo3ekPI6ohAQqV42L+/KnKtMS34o/IkBfzO X-Received: by 2002:a17:907:9611:: with SMTP id gb17mr2545227ejc.325.1614838354144; Wed, 03 Mar 2021 22:12:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614838354; cv=none; d=google.com; s=arc-20160816; b=cwf/bDtda3xc8oxpH0ByVSYsDqWuEu5R48dQ/5pm5LlJQ4J9/oqkMsSIF+JynoLgAt 3MtFt6vIsBRHDUxIm4WetsHyC66m+zstO4MukE3LqFawL2/3WsuieUnJYd7tQkZ2gOPh LgyXnYlkHgsvPsH4YH6dIv//SBQWTM87EkP0HBWnh2fqM+rPgmH4unevTZZ0Mpid3FXT iaJKR7Mp9gnY+uGWVssIuNTd5Qx+WGzk24iqBwmNCKYCEVqVbq8ce0gAPbdbQPqMhdJ4 uUn8lj5EMI9VlscDOVLEfdzSiIIND0FLu0afdAA6iKlUVGd0qpdbRe6cu1+tzGvvA9Ds b4qg== 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=Umhvl4bq+upwhpgsDahvWiFLVfJYEzzIi8Pp8HB1UCU=; b=Akk10gPCTeZ3gzQCc3dRimb5UWjdoNC5jmeloQQMj0pmnOPP3FFkAyPQN6b55O2fH9 QvZnzKIfirIFqrHAE9jVRkDSozWJiL44LDM3w4j298RGx1W1uS/h4uNj1iA/GAPHOIOE Jy5W3vXRgYQ0tLCn4vKNqId76SFG3wNZ7ARpZJRiUnXOEXpDn26MQvCsLhAroAX1CTkG kW2kOmNeqvEUVt11PwPZVv0CVE5S57g9r8U4J6DhG92+vuGqFwGpoI7/74yf2eAYn8iY uKxuLENQCjdegGhdZWH6MgA6wK/yn2LpqrS4lJFaUJqTzl2d9VfwmN9juYFRCBtT+stC n72A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OQG3lH5w; 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 kl16si17354366ejc.565.2021.03.03.22.12.11; Wed, 03 Mar 2021 22:12:34 -0800 (PST) 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=OQG3lH5w; 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 S1446431AbhCBKyQ (ORCPT + 99 others); Tue, 2 Mar 2021 05:54:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239276AbhCBKkN (ORCPT ); Tue, 2 Mar 2021 05:40:13 -0500 Received: from mail-ua1-x92b.google.com (mail-ua1-x92b.google.com [IPv6:2607:f8b0:4864:20::92b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAC70C0617AA for ; Tue, 2 Mar 2021 02:39:22 -0800 (PST) Received: by mail-ua1-x92b.google.com with SMTP id t15so6603910ual.6 for ; Tue, 02 Mar 2021 02:39:22 -0800 (PST) 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=Umhvl4bq+upwhpgsDahvWiFLVfJYEzzIi8Pp8HB1UCU=; b=OQG3lH5wODLrZdv+wguq1ZV0/ouPrqhe3yjBzS5zIDZ9Z3IP+ASIFxVf+INdGRUEKQ 2/twk8qhoUJem5qqPWeeh5b74/yj2selF5wiJ4HmR9mo8H0T50wrgDxAqWRrGVgfcvUV VngPYDvdzNKKI71OQE1LDYEt9UQyRTASDZTYp6vXooGlDnbSU4rNy9sHsEX4eORftUHY YnCyFFsI1E+85nKfV4oehVPQEgcBTOfUJzuXn+8QpCKNsJVsgjL+wAmq9XmN8LVmZQdq Ke/iqI6p0/62buAnjIu5ZAAFafN8r/gikx0YnzlmndlYxofqONVdOr86VCFm4G998eQi g2Rg== 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=Umhvl4bq+upwhpgsDahvWiFLVfJYEzzIi8Pp8HB1UCU=; b=M/+qyPClEXx9lcmqWoc3an9/aAvHTWJgZrl/IKR/QkU//0ySn6pLYhLP0OF71BzbNA 5y2kyM9lQZx3LfeXH4eCz/KXpkvEclGh2IscpeTX7cZLmRST62aJjv3a5OexzFjpL3jO nimCFSEnfSQ7yw7sQ8D4T887gC5bowXQ9yDgQ7bfKxcEFvlnjtRnzDVj1Fc/AtaQWPiY FVKLPZ40IyYrCUUt19dzDcsP79Fg4Lf5t3bI5Azs082W6vRKW9bmv/DQSc88FufBM2qH VNzLA50kNC6e0Zj3ihLcLXwvOUasufmYURNTbOW/mNDkGxHKD6410NNSu2mpNusmkWb2 C6wg== X-Gm-Message-State: AOAM531J55ieOMzoytc0wymEL3bADE4A8lpN1AhA80rjvkCqhQ2KelUn u536UozroxRYnHDJCWf6e2n2Jn80UAimB6f6YWNBLA== X-Received: by 2002:ab0:6045:: with SMTP id o5mr10027474ual.100.1614681562074; Tue, 02 Mar 2021 02:39:22 -0800 (PST) MIME-Version: 1.0 References: <20210215015116.1355-1-zbestahu@gmail.com> In-Reply-To: <20210215015116.1355-1-zbestahu@gmail.com> From: Ulf Hansson Date: Tue, 2 Mar 2021 11:38:44 +0100 Message-ID: Subject: Re: [PATCH] mmc: core: Reduce code duplication to mmc_spi_send_{csd|cid} To: Yue Hu Cc: "linux-mmc@vger.kernel.org" , Linux Kernel Mailing List , Yue Hu , zhangwen@yulong.com, zbestahu@163.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 15 Feb 2021 at 02:51, Yue Hu wrote: > > From: Yue Hu > > mmc_spi_send_{csd|cid} have similar function body. Let's remove the > duplicated part to simplify the code, just add opcode to distinguish > them in changed mmc_spi_send_cxd(). > > Signed-off-by: Yue Hu Applied for next, thanks! Kind regards Uffe > --- > drivers/mmc/core/mmc_ops.c | 39 +++++++++------------------------------ > 1 file changed, 9 insertions(+), 30 deletions(-) > > diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c > index 265d95e..f413474 100644 > --- a/drivers/mmc/core/mmc_ops.c > +++ b/drivers/mmc/core/mmc_ops.c > @@ -296,61 +296,40 @@ int mmc_set_relative_addr(struct mmc_card *card) > return 0; > } > > -static int mmc_spi_send_csd(struct mmc_host *host, u32 *csd) > +static int mmc_spi_send_cxd(struct mmc_host *host, u32 *cxd, u32 opcode) > { > int ret, i; > - __be32 *csd_tmp; > + __be32 *cxd_tmp; > > - csd_tmp = kzalloc(16, GFP_KERNEL); > - if (!csd_tmp) > + cxd_tmp = kzalloc(16, GFP_KERNEL); > + if (!cxd_tmp) > return -ENOMEM; > > - ret = mmc_send_cxd_data(NULL, host, MMC_SEND_CSD, csd_tmp, 16); > + ret = mmc_send_cxd_data(NULL, host, opcode, cxd_tmp, 16); > if (ret) > goto err; > > for (i = 0; i < 4; i++) > - csd[i] = be32_to_cpu(csd_tmp[i]); > + cxd[i] = be32_to_cpu(cxd_tmp[i]); > > err: > - kfree(csd_tmp); > + kfree(cxd_tmp); > return ret; > } > > int mmc_send_csd(struct mmc_card *card, u32 *csd) > { > if (mmc_host_is_spi(card->host)) > - return mmc_spi_send_csd(card->host, csd); > + return mmc_spi_send_cxd(card->host, csd, MMC_SEND_CSD); > > return mmc_send_cxd_native(card->host, card->rca << 16, csd, > MMC_SEND_CSD); > } > > -static int mmc_spi_send_cid(struct mmc_host *host, u32 *cid) > -{ > - int ret, i; > - __be32 *cid_tmp; > - > - cid_tmp = kzalloc(16, GFP_KERNEL); > - if (!cid_tmp) > - return -ENOMEM; > - > - ret = mmc_send_cxd_data(NULL, host, MMC_SEND_CID, cid_tmp, 16); > - if (ret) > - goto err; > - > - for (i = 0; i < 4; i++) > - cid[i] = be32_to_cpu(cid_tmp[i]); > - > -err: > - kfree(cid_tmp); > - return ret; > -} > - > int mmc_send_cid(struct mmc_host *host, u32 *cid) > { > if (mmc_host_is_spi(host)) > - return mmc_spi_send_cid(host, cid); > + return mmc_spi_send_cxd(host, cid, MMC_SEND_CID); > > return mmc_send_cxd_native(host, 0, cid, MMC_ALL_SEND_CID); > } > -- > 1.9.1 >