[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAPDyKFrNBPUdU772EFhcodbu6Mnhv+KmfV6E1oNau1xOooNf8A@mail.gmail.com>
Date: Tue, 2 Mar 2021 11:38:44 +0100
From: Ulf Hansson <ulf.hansson@...aro.org>
To: Yue Hu <zbestahu@...il.com>
Cc: "linux-mmc@...r.kernel.org" <linux-mmc@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Yue Hu <huyue2@...ong.com>, zhangwen@...ong.com,
zbestahu@....com
Subject: Re: [PATCH] mmc: core: Reduce code duplication to mmc_spi_send_{csd|cid}
On Mon, 15 Feb 2021 at 02:51, Yue Hu <zbestahu@...il.com> wrote:
>
> From: Yue Hu <huyue2@...ong.com>
>
> 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 <huyue2@...ong.com>
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
>
Powered by blists - more mailing lists