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

Commit 3e6c67db authored by Ritesh Harjani's avatar Ritesh Harjani Committed by Veerabhadrarao Badiganti
Browse files

mmc: mmc_ops: Factor out mmc_switch_status from __mmc_switch



Factor out mmc_switch_status from __mmc_switch.
And also add mmc_switch_status api to be used to check mmc_switch
cmd status.

Change-Id: Ic5691ccb7bebe6c5d62df7b4ad7c4b0f7e6de61a
Signed-off-by: default avatarRitesh Harjani <riteshh@codeaurora.org>
Signed-off-by: default avatarVeerabhadrarao Badiganti <vbadigan@codeaurora.org>
parent 1446cd5f
Loading
Loading
Loading
Loading
+29 −11
Original line number Diff line number Diff line
@@ -57,6 +57,33 @@ int mmc_send_status(struct mmc_card *card, u32 *status)
	return __mmc_send_status(card, status, false);
}

static int mmc_switch_status_error(struct mmc_host *host, u32 status)
{
	if (mmc_host_is_spi(host)) {
		if (status & R1_SPI_ILLEGAL_COMMAND)
			return -EBADMSG;
	} else {
		if (status & 0xFDFFA000)
			pr_warn("%s: unexpected status %#x after switch\n",
				mmc_hostname(host), status);
		if (status & R1_SWITCH_ERROR)
			return -EBADMSG;
	}
	return 0;
}

int mmc_switch_status(struct mmc_card *card, bool ignore_crc)
{
	u32 status;
	int err;

	err = __mmc_send_status(card, &status, ignore_crc);
	if (err)
		return err;

	return mmc_switch_status_error(card->host, status);
}

static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card)
{
	int err;
@@ -564,18 +591,9 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
		}
	} while (R1_CURRENT_STATE(status) == R1_STATE_PRG);

	if (mmc_host_is_spi(host)) {
		if (status & R1_SPI_ILLEGAL_COMMAND)
			return -EBADMSG;
	} else {
		if (status & 0xFDFFA000)
			pr_warn("%s: unexpected status %#x after switch\n",
				mmc_hostname(host), status);
		if (status & R1_SWITCH_ERROR)
			return -EBADMSG;
	}
	err = mmc_switch_status_error(host, status);

	return 0;
	return err;
}
EXPORT_SYMBOL_GPL(__mmc_switch);

+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ int mmc_bus_test(struct mmc_card *card, u8 bus_width);
int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status);
int mmc_can_ext_csd(struct mmc_card *card);
int mmc_discard_queue(struct mmc_host *host, u32 tasks);
int mmc_switch_status(struct mmc_card *card, bool ignore_crc);

#endif