Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b82fd339 authored by Veerabhadrarao Badiganti's avatar Veerabhadrarao Badiganti
Browse files

mmc: sdhci-mmc-ice: Factor out ice_cfg_start from sdhci_msm_ice_cfg



Factor out the logic of getting ice config parameters from
sdhci_msm_ice_cfg().

With ICE2.0, same sdhci_msm_ice_cfg function is being called from cmdq
and noncq. But with ICE3.0 support, cmdq needs a separate host op.
Since this logic of getting ice config is common for noncq and cmdq,
by having it in separate function, same can be reused
in cmdq host op as-well.

Change-Id: If2cf26667acd54cb7ee7bd6283d8f24fcbf60791
Signed-off-by: default avatarVeerabhadrarao Badiganti <vbadigan@codeaurora.org>
parent 86c7a7fb
Loading
Loading
Loading
Loading
+42 −29
Original line number Diff line number Diff line
@@ -211,6 +211,38 @@ void sdhci_msm_ice_cfg_reset(struct sdhci_host *host, u32 slot)
		host->ioaddr + CORE_VENDOR_SPEC_ICE_CTRL_INFO_3_n + 16 * slot);
}

static
int sdhci_msm_ice_get_cfg(struct sdhci_msm_host *msm_host, struct request *req,
			unsigned int *bypass, short *key_index)
{
	int err = 0;
	struct ice_data_setting ice_set;

	memset(&ice_set, 0, sizeof(struct ice_data_setting));
	if (msm_host->ice.vops->config_start) {
		err = msm_host->ice.vops->config_start(
						msm_host->ice.pdev,
						req, &ice_set, false);
		if (err) {
			pr_err("%s: ice config failed %d\n",
					mmc_hostname(msm_host->mmc), err);
			return err;
		}
	}
	/* if writing data command */
	if (rq_data_dir(req) == WRITE)
		*bypass = ice_set.encr_bypass ?
				SDHCI_MSM_ICE_ENABLE_BYPASS :
				SDHCI_MSM_ICE_DISABLE_BYPASS;
	/* if reading data command */
	else if (rq_data_dir(req) == READ)
		*bypass = ice_set.decr_bypass ?
				SDHCI_MSM_ICE_ENABLE_BYPASS :
				SDHCI_MSM_ICE_DISABLE_BYPASS;
	*key_index = ice_set.crypto_data.key_index;
	return err;
}

static
void sdhci_msm_ice_update_cfg(struct sdhci_host *host, u64 lba,
			u32 slot, unsigned int bypass, short key_index)
@@ -250,7 +282,7 @@ int sdhci_msm_ice_cfg(struct sdhci_host *host, struct mmc_request *mrq,
	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
	struct sdhci_msm_host *msm_host = pltfm_host->priv;
	int err = 0;
	struct ice_data_setting ice_set;
	short key_index = 0;
	sector_t lba = 0;
	unsigned int bypass = SDHCI_MSM_ICE_ENABLE_BYPASS;
	struct request *req;
@@ -261,41 +293,22 @@ int sdhci_msm_ice_cfg(struct sdhci_host *host, struct mmc_request *mrq,
		return -EINVAL;
	}

	BUG_ON(!mrq);
	memset(&ice_set, 0, sizeof(struct ice_data_setting));
	WARN_ON(!mrq);
	if (!mrq)
		return -EINVAL;
	req = mrq->req;
	if (req) {
		lba = req->__sector;
		if (msm_host->ice.vops->config_start) {
			err = msm_host->ice.vops->config_start(
							msm_host->ice.pdev,
							req, &ice_set, false);
			if (err) {
				pr_err("%s: ice config failed %d\n",
						mmc_hostname(host->mmc), err);
		err = sdhci_msm_ice_get_cfg(msm_host, req, &bypass, &key_index);
		if (err)
			return err;
			}
		}
		/* if writing data command */
		if (rq_data_dir(req) == WRITE)
			bypass = ice_set.encr_bypass ?
					SDHCI_MSM_ICE_ENABLE_BYPASS :
					SDHCI_MSM_ICE_DISABLE_BYPASS;
		/* if reading data command */
		else if (rq_data_dir(req) == READ)
			bypass = ice_set.decr_bypass ?
					SDHCI_MSM_ICE_ENABLE_BYPASS :
					SDHCI_MSM_ICE_DISABLE_BYPASS;
		pr_debug("%s: %s: slot %d encr_bypass %d bypass %d decr_bypass %d key_index %d\n",
		pr_debug("%s: %s: slot %d bypass %d key_index %d\n",
				mmc_hostname(host->mmc),
				(rq_data_dir(req) == WRITE) ? "WRITE" : "READ",
				slot, ice_set.encr_bypass, bypass,
				ice_set.decr_bypass,
				ice_set.crypto_data.key_index);
				slot, bypass, key_index);
	}

	sdhci_msm_ice_update_cfg(host, lba, slot, bypass,
				ice_set.crypto_data.key_index);
	sdhci_msm_ice_update_cfg(host, lba, slot, bypass, key_index);
	return 0;
}