From patchwork Tue May 4 16:12:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 430884 Delivered-To: patches@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp3936517jao; Tue, 4 May 2021 09:12:47 -0700 (PDT) X-Received: by 2002:a2e:b60c:: with SMTP id r12mr3103694ljn.460.1620144767484; Tue, 04 May 2021 09:12:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620144767; cv=none; d=google.com; s=arc-20160816; b=lkd4gwhule+Jx2GNdL9TVBkJDIHDIwcWEai9zQtL8iBp2eqNCZ7i82ESZeGdztj1ce V/QX5ur1GcuNardlwCSgYAQd/T39d3+dkAQhwZxx0Xh8rZsuXiMBMyKJ1zTtQLdshqRu j/IOnR98H5rf5ul0xRD0iGz6RaAFNlmEBIh8a30dR7GBeODPIy4g/HrJCyHCST42SpLE z37Bd90lu8hR2Ye4hAiTjcFe5H2uIFOiSwnzagyZCp6XTQeOkBtrGOzEY3Rv/j71t873 QDB2ArTu5DZouBYWktRWzL6Wjs6dS7A6cR7l/OaZDEaSUtgLN9vhijIP12yth0Ltnyhv zpcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=RnseO+HlWfm8PnP329KlCqz9KF+klL6BviqqSWTWuio=; b=hiibhL/1D7a74oykCt2RsdVZs6EPrlLP+yVP02e9O+votMlwm4XYPfoO22PDvYPAXK H4aFFNqBmKE7/1K3L9hY9Z6XqWJf58wrah6+171jxiw2eOhrB3vPv93NEr52CNtADrHu T2AhiQyKtZI2wrq2B9DKgdUb8WvIClYDBG5acqpEZMZkMbEMZ7W7kcZ4LKoIQm1yE+E+ ngnYwa45Tp75BtrSgH/Dtce0geW51BGa76z7tVSLCOcA4goIjoJswMya5es6ksBnk1c0 g6iMD8EfWD+sJ6SSdKex/Cx1v/bawvRvjTAPJFeLfFEl4nrho9wBnonMGe5Umce8FRy6 q20Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lgIb6O2Y; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id h6sor3932943lfd.24.2021.05.04.09.12.47 for (Google Transport Security); Tue, 04 May 2021 09:12:47 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lgIb6O2Y; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RnseO+HlWfm8PnP329KlCqz9KF+klL6BviqqSWTWuio=; b=lgIb6O2YX+Ez0RMKw2US7fma0pchqhR4ksTVapAcxtj4ryBpTR93IrbfTqcGMVMAPL rxvWkxeBiHUzjrxc52/H0TDvuEw7y3w9XqDH59uP0LDM0HAEKWVvDGpvznJ1Tp0YjcKE lDHoyyuqx+7iGXZv3dfcz6jCik43KPq46pPmTKQvyOwQUxjm+ECvEDM5G6F7fRyNt5+z IEmxzZi8sEODp1XIe5hTgspTD+ANs14cC7FGdv4E5JURrrQwm3uRAEhM7hDtwl51KInE J9+zp26pXYSmhtdunLd728m1ItkWJLG4+ytaYzejqFlLqiJVzhr8EK6vyhM5/nc7mMEM VRTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RnseO+HlWfm8PnP329KlCqz9KF+klL6BviqqSWTWuio=; b=ADlYhuXpnJFVZFOKeEJFXswOFo+2POOyDFdBtgoZM/SuYu0P8kOqDFlqRMeJ9UFjr8 O1LK7nSUlnbJ1p8WnCCrqjAOo4nuiBEQJ8hh45Umdj23lbTjDlHJrhlJ52wbxhpsJUuI brU+5b9s9e2uLX/sdgNBuy8uXRepOQJnpyx4+t6kM0wO1jE/tij3hiVEaUBPHOYOmPji irVsJWbdNxq6OrX/vc9f8SqcfU4BvNIXujRSP4nxU/X4mlqQ28d4nvjAm8sPwmimku5R CZ44dedz9mCYijG7OHEiZmJSGaq7cXibMlbJvZZGdV9pVwFKi2DxgDIECnoZbLa4bqFT +j5A== X-Gm-Message-State: AOAM531m24FP6U4cyqSSUqouT3E+3P8SKoRWG3i+Z7UWbGaIIHrWJF1j 94iie2cgPNlZw+e3fISKQ7pnU7zJ X-Google-Smtp-Source: ABdhPJztL23XdscbpvYGwlpduSQ+/7dS5kub7ci6q1CTV7oAB7WUi7fOy7SpxGt3MMA8cz6xqA4yOw== X-Received: by 2002:ac2:5289:: with SMTP id q9mr3001194lfm.141.1620144766986; Tue, 04 May 2021 09:12:46 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-98-128-180-197.NA.cust.bahnhof.se. [98.128.180.197]) by smtp.gmail.com with ESMTPSA id s20sm164193ljs.116.2021.05.04.09.12.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 May 2021 09:12:45 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter Cc: Linus Walleij , Wolfram Sang , Shawn Lin , Avri Altman , Masami Hiramatsu , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/11] mmc: core: Drop open coding in mmc_sd_switch() Date: Tue, 4 May 2021 18:12:18 +0200 Message-Id: <20210504161222.101536-8-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210504161222.101536-1-ulf.hansson@linaro.org> References: <20210504161222.101536-1-ulf.hansson@linaro.org> MIME-Version: 1.0 The SD_SWITCH (CMD6) is an ADTC type of command with an R1 response, which can be sent by using the mmc_send_adtc_data(). Let's do that and drop the open coding in mmc_sd_switch(). Signed-off-by: Ulf Hansson --- drivers/mmc/core/sd_ops.c | 38 +++++++------------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) -- 2.25.1 Reviewed-by: Linus Walleij Reviewed-by: Shawn Lin diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index d61ff811218c..ef8d1dce5af1 100644 --- a/drivers/mmc/core/sd_ops.c +++ b/drivers/mmc/core/sd_ops.c @@ -17,6 +17,7 @@ #include "core.h" #include "sd_ops.h" +#include "mmc_ops.h" int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card) { @@ -309,43 +310,18 @@ int mmc_app_send_scr(struct mmc_card *card) int mmc_sd_switch(struct mmc_card *card, int mode, int group, u8 value, u8 *resp) { - struct mmc_request mrq = {}; - struct mmc_command cmd = {}; - struct mmc_data data = {}; - struct scatterlist sg; + u32 cmd_args; /* NOTE: caller guarantees resp is heap-allocated */ mode = !!mode; value &= 0xF; + cmd_args = mode << 31 | 0x00FFFFFF; + cmd_args &= ~(0xF << (group * 4)); + cmd_args |= value << (group * 4); - mrq.cmd = &cmd; - mrq.data = &data; - - cmd.opcode = SD_SWITCH; - cmd.arg = mode << 31 | 0x00FFFFFF; - cmd.arg &= ~(0xF << (group * 4)); - cmd.arg |= value << (group * 4); - cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC; - - data.blksz = 64; - data.blocks = 1; - data.flags = MMC_DATA_READ; - data.sg = &sg; - data.sg_len = 1; - - sg_init_one(&sg, resp, 64); - - mmc_set_data_timeout(&data, card); - - mmc_wait_for_req(card->host, &mrq); - - if (cmd.error) - return cmd.error; - if (data.error) - return data.error; - - return 0; + return mmc_send_adtc_data(card, card->host, SD_SWITCH, cmd_args, resp, + 64); } int mmc_app_sd_status(struct mmc_card *card, void *ssr)