All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] mmc: core: Some trivial re-factoring and cleanups
@ 2017-06-08 13:27 Ulf Hansson
  2017-06-08 13:27 ` [PATCH 1/9] mmc: core: Don't export some eMMC specific functions from core.c Ulf Hansson
                   ` (9 more replies)
  0 siblings, 10 replies; 22+ messages in thread
From: Ulf Hansson @ 2017-06-08 13:27 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson; +Cc: Jaehoon Chung, Adrian Hunter, Linus Walleij

I have collected some cleanups along the road on the mmc core, now I thought it
was time to post them. None of these changes causes any functional changes, but
the goal is rather to just make the code more readable and avoid open coding.


Ulf Hansson (9):
  mmc: core: Don't export some eMMC specific functions from core.c
  mmc: core: Move mmc bkops functions from core.c to mmc_ops.c
  mmc: core: Move mmc_interrupt_hpi() from core.c to mmc_ops.c
  mmc: core: Move mmc_flush_cache() from core.c to mmc_ops.c
  mmc: core: Make mmc_can_reset() static
  mmc: core: Remove redundant code in mmc_send_cid()
  mmc: core: Re-factor code for sending CID
  mmc: core: Drop mmc_all_send_cid() and use mmc_send_cxd_native()
    instead
  mmc: core: Clarify code for sending CSD

 drivers/mmc/core/core.c    | 207 -------------------------------------
 drivers/mmc/core/mmc.c     |   8 +-
 drivers/mmc/core/mmc_ops.c | 250 +++++++++++++++++++++++++++++++++++++++------
 drivers/mmc/core/mmc_ops.h |   3 -
 drivers/mmc/core/sd.c      |   6 +-
 5 files changed, 221 insertions(+), 253 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 1/9] mmc: core: Don't export some eMMC specific functions from core.c
  2017-06-08 13:27 [PATCH 0/9] mmc: core: Some trivial re-factoring and cleanups Ulf Hansson
@ 2017-06-08 13:27 ` Ulf Hansson
  2017-06-09 13:22   ` Linus Walleij
  2017-06-08 13:27 ` [PATCH 2/9] mmc: core: Move mmc bkops functions from core.c to mmc_ops.c Ulf Hansson
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Ulf Hansson @ 2017-06-08 13:27 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson; +Cc: Jaehoon Chung, Adrian Hunter, Linus Walleij

The mmc_start|stop_bkops(), mmc_read_bkops_status() and mmc_interrupt_hpi()
functions are all used from within the mmc core module, thus there are no
need to use EXPORT_SYMBOL() for them, so let's remove it.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/core/core.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index ad8caf4..d48be0b 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -428,7 +428,6 @@ void mmc_start_bkops(struct mmc_card *card, bool from_exception)
 out:
 	mmc_release_host(card->host);
 }
-EXPORT_SYMBOL(mmc_start_bkops);
 
 /*
  * mmc_wait_data_done() - done callback for data request
@@ -811,7 +810,6 @@ int mmc_interrupt_hpi(struct mmc_card *card)
 	mmc_release_host(card->host);
 	return err;
 }
-EXPORT_SYMBOL(mmc_interrupt_hpi);
 
 /**
  *	mmc_wait_for_cmd - start a command and wait for completion
@@ -869,7 +867,6 @@ int mmc_stop_bkops(struct mmc_card *card)
 
 	return err;
 }
-EXPORT_SYMBOL(mmc_stop_bkops);
 
 int mmc_read_bkops_status(struct mmc_card *card)
 {
@@ -887,7 +884,6 @@ int mmc_read_bkops_status(struct mmc_card *card)
 	kfree(ext_csd);
 	return 0;
 }
-EXPORT_SYMBOL(mmc_read_bkops_status);
 
 /**
  *	mmc_set_data_timeout - set the timeout for a data command
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 2/9] mmc: core: Move mmc bkops functions from core.c to mmc_ops.c
  2017-06-08 13:27 [PATCH 0/9] mmc: core: Some trivial re-factoring and cleanups Ulf Hansson
  2017-06-08 13:27 ` [PATCH 1/9] mmc: core: Don't export some eMMC specific functions from core.c Ulf Hansson
@ 2017-06-08 13:27 ` Ulf Hansson
  2017-06-09 13:23   ` Linus Walleij
  2017-06-08 13:27 ` [PATCH 3/9] mmc: core: Move mmc_interrupt_hpi() " Ulf Hansson
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Ulf Hansson @ 2017-06-08 13:27 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson; +Cc: Jaehoon Chung, Adrian Hunter, Linus Walleij

The mmc_start_bkops(), mmc_stop_bkops() and mmc_read_bkops_status()
functions are all specific to eMMCs. To make this clear, let's move them
from from core.c to mmc_ops.c.

While moving them, get rid of MMC_BKOPS_MAX_TIMEOUT (4 min) and use the
common default timeout MMC_OPS_TIMEOUT_MS (10 min) instead, as there is no
need to have specific default timeout for bkops.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/core/core.c    | 118 ---------------------------------------------
 drivers/mmc/core/mmc_ops.c | 113 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 113 insertions(+), 118 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index d48be0b..d7c934c 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -53,12 +53,6 @@
 /* If the device is not responding */
 #define MMC_CORE_TIMEOUT_MS	(10 * 60 * 1000) /* 10 minute timeout */
 
-/*
- * Background operations can take a long time, depending on the housekeeping
- * operations the card has to perform.
- */
-#define MMC_BKOPS_MAX_TIMEOUT	(4 * 60 * 1000) /* max time to wait in ms */
-
 /* The max erase timeout, used when host->max_busy_timeout isn't specified */
 #define MMC_ERASE_TIMEOUT_MS	(60 * 1000) /* 60 s */
 
@@ -362,73 +356,6 @@ static int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
 	return 0;
 }
 
-/**
- *	mmc_start_bkops - start BKOPS for supported cards
- *	@card: MMC card to start BKOPS
- *	@form_exception: A flag to indicate if this function was
- *			 called due to an exception raised by the card
- *
- *	Start background operations whenever requested.
- *	When the urgent BKOPS bit is set in a R1 command response
- *	then background operations should be started immediately.
-*/
-void mmc_start_bkops(struct mmc_card *card, bool from_exception)
-{
-	int err;
-	int timeout;
-	bool use_busy_signal;
-
-	if (!card->ext_csd.man_bkops_en || mmc_card_doing_bkops(card))
-		return;
-
-	err = mmc_read_bkops_status(card);
-	if (err) {
-		pr_err("%s: Failed to read bkops status: %d\n",
-		       mmc_hostname(card->host), err);
-		return;
-	}
-
-	if (!card->ext_csd.raw_bkops_status)
-		return;
-
-	if (card->ext_csd.raw_bkops_status < EXT_CSD_BKOPS_LEVEL_2 &&
-	    from_exception)
-		return;
-
-	mmc_claim_host(card->host);
-	if (card->ext_csd.raw_bkops_status >= EXT_CSD_BKOPS_LEVEL_2) {
-		timeout = MMC_BKOPS_MAX_TIMEOUT;
-		use_busy_signal = true;
-	} else {
-		timeout = 0;
-		use_busy_signal = false;
-	}
-
-	mmc_retune_hold(card->host);
-
-	err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
-			EXT_CSD_BKOPS_START, 1, timeout, 0,
-			use_busy_signal, true, false);
-	if (err) {
-		pr_warn("%s: Error %d starting bkops\n",
-			mmc_hostname(card->host), err);
-		mmc_retune_release(card->host);
-		goto out;
-	}
-
-	/*
-	 * For urgent bkops status (LEVEL_2 and more)
-	 * bkops executed synchronously, otherwise
-	 * the operation is in progress
-	 */
-	if (!use_busy_signal)
-		mmc_card_set_doing_bkops(card);
-	else
-		mmc_retune_release(card->host);
-out:
-	mmc_release_host(card->host);
-}
-
 /*
  * mmc_wait_data_done() - done callback for data request
  * @mrq: done data request
@@ -841,51 +768,6 @@ int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries
 EXPORT_SYMBOL(mmc_wait_for_cmd);
 
 /**
- *	mmc_stop_bkops - stop ongoing BKOPS
- *	@card: MMC card to check BKOPS
- *
- *	Send HPI command to stop ongoing background operations to
- *	allow rapid servicing of foreground operations, e.g. read/
- *	writes. Wait until the card comes out of the programming state
- *	to avoid errors in servicing read/write requests.
- */
-int mmc_stop_bkops(struct mmc_card *card)
-{
-	int err = 0;
-
-	err = mmc_interrupt_hpi(card);
-
-	/*
-	 * If err is EINVAL, we can't issue an HPI.
-	 * It should complete the BKOPS.
-	 */
-	if (!err || (err == -EINVAL)) {
-		mmc_card_clr_doing_bkops(card);
-		mmc_retune_release(card->host);
-		err = 0;
-	}
-
-	return err;
-}
-
-int mmc_read_bkops_status(struct mmc_card *card)
-{
-	int err;
-	u8 *ext_csd;
-
-	mmc_claim_host(card->host);
-	err = mmc_get_ext_csd(card, &ext_csd);
-	mmc_release_host(card->host);
-	if (err)
-		return err;
-
-	card->ext_csd.raw_bkops_status = ext_csd[EXT_CSD_BKOPS_STATUS];
-	card->ext_csd.raw_exception_status = ext_csd[EXT_CSD_EXP_EVENTS_STATUS];
-	kfree(ext_csd);
-	return 0;
-}
-
-/**
  *	mmc_set_data_timeout - set the timeout for a data command
  *	@data: data phase for command
  *	@card: the MMC card associated with the data transfer
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index ae1fc48..0648fae 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -19,6 +19,7 @@
 #include <linux/mmc/mmc.h>
 
 #include "core.h"
+#include "card.h"
 #include "host.h"
 #include "mmc_ops.h"
 
@@ -845,6 +846,118 @@ int mmc_can_ext_csd(struct mmc_card *card)
 	return (card && card->csd.mmca_vsn > CSD_SPEC_VER_3);
 }
 
+/**
+ *	mmc_stop_bkops - stop ongoing BKOPS
+ *	@card: MMC card to check BKOPS
+ *
+ *	Send HPI command to stop ongoing background operations to
+ *	allow rapid servicing of foreground operations, e.g. read/
+ *	writes. Wait until the card comes out of the programming state
+ *	to avoid errors in servicing read/write requests.
+ */
+int mmc_stop_bkops(struct mmc_card *card)
+{
+	int err = 0;
+
+	err = mmc_interrupt_hpi(card);
+
+	/*
+	 * If err is EINVAL, we can't issue an HPI.
+	 * It should complete the BKOPS.
+	 */
+	if (!err || (err == -EINVAL)) {
+		mmc_card_clr_doing_bkops(card);
+		mmc_retune_release(card->host);
+		err = 0;
+	}
+
+	return err;
+}
+
+int mmc_read_bkops_status(struct mmc_card *card)
+{
+	int err;
+	u8 *ext_csd;
+
+	mmc_claim_host(card->host);
+	err = mmc_get_ext_csd(card, &ext_csd);
+	mmc_release_host(card->host);
+	if (err)
+		return err;
+
+	card->ext_csd.raw_bkops_status = ext_csd[EXT_CSD_BKOPS_STATUS];
+	card->ext_csd.raw_exception_status = ext_csd[EXT_CSD_EXP_EVENTS_STATUS];
+	kfree(ext_csd);
+	return 0;
+}
+
+/**
+ *	mmc_start_bkops - start BKOPS for supported cards
+ *	@card: MMC card to start BKOPS
+ *	@form_exception: A flag to indicate if this function was
+ *			 called due to an exception raised by the card
+ *
+ *	Start background operations whenever requested.
+ *	When the urgent BKOPS bit is set in a R1 command response
+ *	then background operations should be started immediately.
+*/
+void mmc_start_bkops(struct mmc_card *card, bool from_exception)
+{
+	int err;
+	int timeout;
+	bool use_busy_signal;
+
+	if (!card->ext_csd.man_bkops_en || mmc_card_doing_bkops(card))
+		return;
+
+	err = mmc_read_bkops_status(card);
+	if (err) {
+		pr_err("%s: Failed to read bkops status: %d\n",
+		       mmc_hostname(card->host), err);
+		return;
+	}
+
+	if (!card->ext_csd.raw_bkops_status)
+		return;
+
+	if (card->ext_csd.raw_bkops_status < EXT_CSD_BKOPS_LEVEL_2 &&
+	    from_exception)
+		return;
+
+	mmc_claim_host(card->host);
+	if (card->ext_csd.raw_bkops_status >= EXT_CSD_BKOPS_LEVEL_2) {
+		timeout = MMC_OPS_TIMEOUT_MS;
+		use_busy_signal = true;
+	} else {
+		timeout = 0;
+		use_busy_signal = false;
+	}
+
+	mmc_retune_hold(card->host);
+
+	err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+			EXT_CSD_BKOPS_START, 1, timeout, 0,
+			use_busy_signal, true, false);
+	if (err) {
+		pr_warn("%s: Error %d starting bkops\n",
+			mmc_hostname(card->host), err);
+		mmc_retune_release(card->host);
+		goto out;
+	}
+
+	/*
+	 * For urgent bkops status (LEVEL_2 and more)
+	 * bkops executed synchronously, otherwise
+	 * the operation is in progress
+	 */
+	if (!use_busy_signal)
+		mmc_card_set_doing_bkops(card);
+	else
+		mmc_retune_release(card->host);
+out:
+	mmc_release_host(card->host);
+}
+
 static int mmc_cmdq_switch(struct mmc_card *card, bool enable)
 {
 	u8 val = enable ? EXT_CSD_CMDQ_MODE_ENABLED : 0;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 3/9] mmc: core: Move mmc_interrupt_hpi() from core.c to mmc_ops.c
  2017-06-08 13:27 [PATCH 0/9] mmc: core: Some trivial re-factoring and cleanups Ulf Hansson
  2017-06-08 13:27 ` [PATCH 1/9] mmc: core: Don't export some eMMC specific functions from core.c Ulf Hansson
  2017-06-08 13:27 ` [PATCH 2/9] mmc: core: Move mmc bkops functions from core.c to mmc_ops.c Ulf Hansson
@ 2017-06-08 13:27 ` Ulf Hansson
  2017-06-09 13:24   ` Linus Walleij
  2017-06-08 13:27 ` [PATCH 4/9] mmc: core: Move mmc_flush_cache() " Ulf Hansson
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Ulf Hansson @ 2017-06-08 13:27 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson; +Cc: Jaehoon Chung, Adrian Hunter, Linus Walleij

The mmc_interrupt_hpi() is a eMMC specific function, let's move it to
mmc_ops.c to make that clear. The move also enables us to make
mmc_send_hpi_cmd() static, so let's do that change as well.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/core/core.c    | 64 --------------------------------------------
 drivers/mmc/core/mmc_ops.c | 66 +++++++++++++++++++++++++++++++++++++++++++++-
 drivers/mmc/core/mmc_ops.h |  1 -
 3 files changed, 65 insertions(+), 66 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index d7c934c..de31f30 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -675,70 +675,6 @@ void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
 EXPORT_SYMBOL(mmc_wait_for_req);
 
 /**
- *	mmc_interrupt_hpi - Issue for High priority Interrupt
- *	@card: the MMC card associated with the HPI transfer
- *
- *	Issued High Priority Interrupt, and check for card status
- *	until out-of prg-state.
- */
-int mmc_interrupt_hpi(struct mmc_card *card)
-{
-	int err;
-	u32 status;
-	unsigned long prg_wait;
-
-	if (!card->ext_csd.hpi_en) {
-		pr_info("%s: HPI enable bit unset\n", mmc_hostname(card->host));
-		return 1;
-	}
-
-	mmc_claim_host(card->host);
-	err = mmc_send_status(card, &status);
-	if (err) {
-		pr_err("%s: Get card status fail\n", mmc_hostname(card->host));
-		goto out;
-	}
-
-	switch (R1_CURRENT_STATE(status)) {
-	case R1_STATE_IDLE:
-	case R1_STATE_READY:
-	case R1_STATE_STBY:
-	case R1_STATE_TRAN:
-		/*
-		 * In idle and transfer states, HPI is not needed and the caller
-		 * can issue the next intended command immediately
-		 */
-		goto out;
-	case R1_STATE_PRG:
-		break;
-	default:
-		/* In all other states, it's illegal to issue HPI */
-		pr_debug("%s: HPI cannot be sent. Card state=%d\n",
-			mmc_hostname(card->host), R1_CURRENT_STATE(status));
-		err = -EINVAL;
-		goto out;
-	}
-
-	err = mmc_send_hpi_cmd(card, &status);
-	if (err)
-		goto out;
-
-	prg_wait = jiffies + msecs_to_jiffies(card->ext_csd.out_of_int_time);
-	do {
-		err = mmc_send_status(card, &status);
-
-		if (!err && R1_CURRENT_STATE(status) == R1_STATE_TRAN)
-			break;
-		if (time_after(jiffies, prg_wait))
-			err = -ETIMEDOUT;
-	} while (!err);
-
-out:
-	mmc_release_host(card->host);
-	return err;
-}
-
-/**
  *	mmc_wait_for_cmd - start a command and wait for completion
  *	@host: MMC host to start command
  *	@cmd: MMC command to start
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 0648fae..53e4da48 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -807,7 +807,7 @@ int mmc_bus_test(struct mmc_card *card, u8 bus_width)
 	return mmc_send_bus_test(card, card->host, MMC_BUS_TEST_R, width);
 }
 
-int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status)
+static int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status)
 {
 	struct mmc_command cmd = {};
 	unsigned int opcode;
@@ -841,6 +841,70 @@ int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status)
 	return 0;
 }
 
+/**
+ *	mmc_interrupt_hpi - Issue for High priority Interrupt
+ *	@card: the MMC card associated with the HPI transfer
+ *
+ *	Issued High Priority Interrupt, and check for card status
+ *	until out-of prg-state.
+ */
+int mmc_interrupt_hpi(struct mmc_card *card)
+{
+	int err;
+	u32 status;
+	unsigned long prg_wait;
+
+	if (!card->ext_csd.hpi_en) {
+		pr_info("%s: HPI enable bit unset\n", mmc_hostname(card->host));
+		return 1;
+	}
+
+	mmc_claim_host(card->host);
+	err = mmc_send_status(card, &status);
+	if (err) {
+		pr_err("%s: Get card status fail\n", mmc_hostname(card->host));
+		goto out;
+	}
+
+	switch (R1_CURRENT_STATE(status)) {
+	case R1_STATE_IDLE:
+	case R1_STATE_READY:
+	case R1_STATE_STBY:
+	case R1_STATE_TRAN:
+		/*
+		 * In idle and transfer states, HPI is not needed and the caller
+		 * can issue the next intended command immediately
+		 */
+		goto out;
+	case R1_STATE_PRG:
+		break;
+	default:
+		/* In all other states, it's illegal to issue HPI */
+		pr_debug("%s: HPI cannot be sent. Card state=%d\n",
+			mmc_hostname(card->host), R1_CURRENT_STATE(status));
+		err = -EINVAL;
+		goto out;
+	}
+
+	err = mmc_send_hpi_cmd(card, &status);
+	if (err)
+		goto out;
+
+	prg_wait = jiffies + msecs_to_jiffies(card->ext_csd.out_of_int_time);
+	do {
+		err = mmc_send_status(card, &status);
+
+		if (!err && R1_CURRENT_STATE(status) == R1_STATE_TRAN)
+			break;
+		if (time_after(jiffies, prg_wait))
+			err = -ETIMEDOUT;
+	} while (!err);
+
+out:
+	mmc_release_host(card->host);
+	return err;
+}
+
 int mmc_can_ext_csd(struct mmc_card *card)
 {
 	return (card && card->csd.mmca_vsn > CSD_SPEC_VER_3);
diff --git a/drivers/mmc/core/mmc_ops.h b/drivers/mmc/core/mmc_ops.h
index b8d0552..063500c 100644
--- a/drivers/mmc/core/mmc_ops.h
+++ b/drivers/mmc/core/mmc_ops.h
@@ -31,7 +31,6 @@ int mmc_send_cid(struct mmc_host *host, u32 *cid);
 int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp);
 int mmc_spi_set_crc(struct mmc_host *host, int use_crc);
 int mmc_bus_test(struct mmc_card *card, u8 bus_width);
-int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status);
 int mmc_interrupt_hpi(struct mmc_card *card);
 int mmc_can_ext_csd(struct mmc_card *card);
 int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 4/9] mmc: core: Move mmc_flush_cache() from core.c to mmc_ops.c
  2017-06-08 13:27 [PATCH 0/9] mmc: core: Some trivial re-factoring and cleanups Ulf Hansson
                   ` (2 preceding siblings ...)
  2017-06-08 13:27 ` [PATCH 3/9] mmc: core: Move mmc_interrupt_hpi() " Ulf Hansson
@ 2017-06-08 13:27 ` Ulf Hansson
  2017-06-09 13:25   ` Linus Walleij
  2017-06-08 13:27 ` [PATCH 5/9] mmc: core: Make mmc_can_reset() static Ulf Hansson
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Ulf Hansson @ 2017-06-08 13:27 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson; +Cc: Jaehoon Chung, Adrian Hunter, Linus Walleij

The mmc_flush_cache() is a eMMC specific function, let's move it to
mmc_ops.c to make that clear.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/core/core.c    | 21 ---------------------
 drivers/mmc/core/mmc_ops.c | 21 +++++++++++++++++++++
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index de31f30..d40697f 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2729,27 +2729,6 @@ int mmc_power_restore_host(struct mmc_host *host)
 }
 EXPORT_SYMBOL(mmc_power_restore_host);
 
-/*
- * Flush the cache to the non-volatile storage.
- */
-int mmc_flush_cache(struct mmc_card *card)
-{
-	int err = 0;
-
-	if (mmc_card_mmc(card) &&
-			(card->ext_csd.cache_size > 0) &&
-			(card->ext_csd.cache_ctrl & 1)) {
-		err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
-				EXT_CSD_FLUSH_CACHE, 1, 0);
-		if (err)
-			pr_err("%s: cache flush error %d\n",
-					mmc_hostname(card->host), err);
-	}
-
-	return err;
-}
-EXPORT_SYMBOL(mmc_flush_cache);
-
 #ifdef CONFIG_PM_SLEEP
 /* Do the card removal on suspend if card is assumed removeable
  * Do that in pm notifier while userspace isn't yet frozen, so we will be able
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 53e4da48..f79d680 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -1022,6 +1022,27 @@ void mmc_start_bkops(struct mmc_card *card, bool from_exception)
 	mmc_release_host(card->host);
 }
 
+/*
+ * Flush the cache to the non-volatile storage.
+ */
+int mmc_flush_cache(struct mmc_card *card)
+{
+	int err = 0;
+
+	if (mmc_card_mmc(card) &&
+			(card->ext_csd.cache_size > 0) &&
+			(card->ext_csd.cache_ctrl & 1)) {
+		err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+				EXT_CSD_FLUSH_CACHE, 1, 0);
+		if (err)
+			pr_err("%s: cache flush error %d\n",
+					mmc_hostname(card->host), err);
+	}
+
+	return err;
+}
+EXPORT_SYMBOL(mmc_flush_cache);
+
 static int mmc_cmdq_switch(struct mmc_card *card, bool enable)
 {
 	u8 val = enable ? EXT_CSD_CMDQ_MODE_ENABLED : 0;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 5/9] mmc: core: Make mmc_can_reset() static
  2017-06-08 13:27 [PATCH 0/9] mmc: core: Some trivial re-factoring and cleanups Ulf Hansson
                   ` (3 preceding siblings ...)
  2017-06-08 13:27 ` [PATCH 4/9] mmc: core: Move mmc_flush_cache() " Ulf Hansson
@ 2017-06-08 13:27 ` Ulf Hansson
  2017-06-09 13:27   ` Linus Walleij
  2017-06-08 13:27 ` [PATCH 6/9] mmc: core: Remove redundant code in mmc_send_cid() Ulf Hansson
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Ulf Hansson @ 2017-06-08 13:27 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson; +Cc: Jaehoon Chung, Adrian Hunter, Linus Walleij

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/core/mmc.c     | 3 +--
 drivers/mmc/core/mmc_ops.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index e3b6bea..ff6cdc3 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -2097,7 +2097,7 @@ static int mmc_runtime_resume(struct mmc_host *host)
 	return 0;
 }
 
-int mmc_can_reset(struct mmc_card *card)
+static int mmc_can_reset(struct mmc_card *card)
 {
 	u8 rst_n_function;
 
@@ -2106,7 +2106,6 @@ int mmc_can_reset(struct mmc_card *card)
 		return 0;
 	return 1;
 }
-EXPORT_SYMBOL(mmc_can_reset);
 
 static int mmc_reset(struct mmc_host *host)
 {
diff --git a/drivers/mmc/core/mmc_ops.h b/drivers/mmc/core/mmc_ops.h
index 063500c..9d6b15b 100644
--- a/drivers/mmc/core/mmc_ops.h
+++ b/drivers/mmc/core/mmc_ops.h
@@ -44,7 +44,6 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
 int mmc_stop_bkops(struct mmc_card *card);
 int mmc_read_bkops_status(struct mmc_card *card);
 void mmc_start_bkops(struct mmc_card *card, bool from_exception);
-int mmc_can_reset(struct mmc_card *card);
 int mmc_flush_cache(struct mmc_card *card);
 int mmc_cmdq_enable(struct mmc_card *card);
 int mmc_cmdq_disable(struct mmc_card *card);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 6/9] mmc: core: Remove redundant code in mmc_send_cid()
  2017-06-08 13:27 [PATCH 0/9] mmc: core: Some trivial re-factoring and cleanups Ulf Hansson
                   ` (4 preceding siblings ...)
  2017-06-08 13:27 ` [PATCH 5/9] mmc: core: Make mmc_can_reset() static Ulf Hansson
@ 2017-06-08 13:27 ` Ulf Hansson
  2017-06-09 13:29   ` Linus Walleij
  2017-06-08 13:27 ` [PATCH 7/9] mmc: core: Re-factor code for sending CID Ulf Hansson
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Ulf Hansson @ 2017-06-08 13:27 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson; +Cc: Jaehoon Chung, Adrian Hunter, Linus Walleij

The mmc_send_cid() is never called using non SPI mode. Thus, let's remove
the redundant code dealing with this.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/core/mmc_ops.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index f79d680..9994840 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -339,13 +339,6 @@ int mmc_send_cid(struct mmc_host *host, u32 *cid)
 	int ret, i;
 	__be32 *cid_tmp;
 
-	if (!mmc_host_is_spi(host)) {
-		if (!host->card)
-			return -EINVAL;
-		return mmc_send_cxd_native(host, host->card->rca << 16,
-				cid, MMC_SEND_CID);
-	}
-
 	cid_tmp = kzalloc(16, GFP_KERNEL);
 	if (!cid_tmp)
 		return -ENOMEM;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 7/9] mmc: core: Re-factor code for sending CID
  2017-06-08 13:27 [PATCH 0/9] mmc: core: Some trivial re-factoring and cleanups Ulf Hansson
                   ` (5 preceding siblings ...)
  2017-06-08 13:27 ` [PATCH 6/9] mmc: core: Remove redundant code in mmc_send_cid() Ulf Hansson
@ 2017-06-08 13:27 ` Ulf Hansson
  2017-06-09 13:32   ` Linus Walleij
  2017-06-08 13:27 ` [PATCH 8/9] mmc: core: Drop mmc_all_send_cid() and use mmc_send_cxd_native() instead Ulf Hansson
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Ulf Hansson @ 2017-06-08 13:27 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson; +Cc: Jaehoon Chung, Adrian Hunter, Linus Walleij

Instead of having the caller to check for SPI mode, let's leave that to
internals of mmc_send_cid(). In this way the code gets cleaner and it
becomes clear what is specific to SPI and non-SPI mode.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/core/mmc.c     |  5 +----
 drivers/mmc/core/mmc_ops.c | 12 ++++++++++--
 drivers/mmc/core/mmc_ops.h |  1 -
 drivers/mmc/core/sd.c      |  6 +-----
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index ff6cdc3..e504b66 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1556,10 +1556,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 	/*
 	 * Fetch CID from card.
 	 */
-	if (mmc_host_is_spi(host))
-		err = mmc_send_cid(host, cid);
-	else
-		err = mmc_all_send_cid(host, cid);
+	err = mmc_send_cid(host, cid);
 	if (err)
 		goto err;
 
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 9994840..50571a6 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -207,7 +207,7 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
 	return err;
 }
 
-int mmc_all_send_cid(struct mmc_host *host, u32 *cid)
+static int mmc_all_send_cid(struct mmc_host *host, u32 *cid)
 {
 	int err;
 	struct mmc_command cmd = {};
@@ -334,7 +334,7 @@ int mmc_send_csd(struct mmc_card *card, u32 *csd)
 	return ret;
 }
 
-int mmc_send_cid(struct mmc_host *host, u32 *cid)
+static int mmc_spi_send_cid(struct mmc_host *host, u32 *cid)
 {
 	int ret, i;
 	__be32 *cid_tmp;
@@ -355,6 +355,14 @@ int mmc_send_cid(struct mmc_host *host, u32 *cid)
 	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_all_send_cid(host, cid);
+}
+
 int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd)
 {
 	int err;
diff --git a/drivers/mmc/core/mmc_ops.h b/drivers/mmc/core/mmc_ops.h
index 9d6b15b..d3d5d68 100644
--- a/drivers/mmc/core/mmc_ops.h
+++ b/drivers/mmc/core/mmc_ops.h
@@ -22,7 +22,6 @@ int mmc_deselect_cards(struct mmc_host *host);
 int mmc_set_dsr(struct mmc_host *host);
 int mmc_go_idle(struct mmc_host *host);
 int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr);
-int mmc_all_send_cid(struct mmc_host *host, u32 *cid);
 int mmc_set_relative_addr(struct mmc_card *card);
 int mmc_send_csd(struct mmc_card *card, u32 *csd);
 int __mmc_send_status(struct mmc_card *card, u32 *status, unsigned int retries);
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 1d7542d..a1b0aa1 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -788,11 +788,7 @@ int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr)
 		}
 	}
 
-	if (mmc_host_is_spi(host))
-		err = mmc_send_cid(host, cid);
-	else
-		err = mmc_all_send_cid(host, cid);
-
+	err = mmc_send_cid(host, cid);
 	return err;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 8/9] mmc: core: Drop mmc_all_send_cid() and use mmc_send_cxd_native() instead
  2017-06-08 13:27 [PATCH 0/9] mmc: core: Some trivial re-factoring and cleanups Ulf Hansson
                   ` (6 preceding siblings ...)
  2017-06-08 13:27 ` [PATCH 7/9] mmc: core: Re-factor code for sending CID Ulf Hansson
@ 2017-06-08 13:27 ` Ulf Hansson
  2017-06-09 13:32   ` Linus Walleij
  2017-06-08 13:27 ` [PATCH 9/9] mmc: core: Clarify code for sending CSD Ulf Hansson
  2017-06-16  0:49 ` [PATCH 0/9] mmc: core: Some trivial re-factoring and cleanups Shawn Lin
  9 siblings, 1 reply; 22+ messages in thread
From: Ulf Hansson @ 2017-06-08 13:27 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson; +Cc: Jaehoon Chung, Adrian Hunter, Linus Walleij

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/core/mmc_ops.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 50571a6..b60b4da 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -207,24 +207,6 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
 	return err;
 }
 
-static int mmc_all_send_cid(struct mmc_host *host, u32 *cid)
-{
-	int err;
-	struct mmc_command cmd = {};
-
-	cmd.opcode = MMC_ALL_SEND_CID;
-	cmd.arg = 0;
-	cmd.flags = MMC_RSP_R2 | MMC_CMD_BCR;
-
-	err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
-	if (err)
-		return err;
-
-	memcpy(cid, cmd.resp, sizeof(u32) * 4);
-
-	return 0;
-}
-
 int mmc_set_relative_addr(struct mmc_card *card)
 {
 	struct mmc_command cmd = {};
@@ -360,7 +342,7 @@ 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_all_send_cid(host, cid);
+	return mmc_send_cxd_native(host, 0, cid, MMC_ALL_SEND_CID);
 }
 
 int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 9/9] mmc: core: Clarify code for sending CSD
  2017-06-08 13:27 [PATCH 0/9] mmc: core: Some trivial re-factoring and cleanups Ulf Hansson
                   ` (7 preceding siblings ...)
  2017-06-08 13:27 ` [PATCH 8/9] mmc: core: Drop mmc_all_send_cid() and use mmc_send_cxd_native() instead Ulf Hansson
@ 2017-06-08 13:27 ` Ulf Hansson
  2017-06-09 13:33   ` Linus Walleij
  2017-06-16  0:49 ` [PATCH 0/9] mmc: core: Some trivial re-factoring and cleanups Shawn Lin
  9 siblings, 1 reply; 22+ messages in thread
From: Ulf Hansson @ 2017-06-08 13:27 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson; +Cc: Jaehoon Chung, Adrian Hunter, Linus Walleij

To make the code more consistent and to increase readability, add an
mmc_spi_send_csd() function, which gets called from mmc_send_csd() in case
of SPI mode.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/core/mmc_ops.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index b60b4da..5f051ea 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -291,15 +291,11 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
 	return 0;
 }
 
-int mmc_send_csd(struct mmc_card *card, u32 *csd)
+static int mmc_spi_send_csd(struct mmc_card *card, u32 *csd)
 {
 	int ret, i;
 	__be32 *csd_tmp;
 
-	if (!mmc_host_is_spi(card->host))
-		return mmc_send_cxd_native(card->host, card->rca << 16,
-				csd, MMC_SEND_CSD);
-
 	csd_tmp = kzalloc(16, GFP_KERNEL);
 	if (!csd_tmp)
 		return -ENOMEM;
@@ -316,6 +312,15 @@ int mmc_send_csd(struct mmc_card *card, u32 *csd)
 	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, 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;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH 1/9] mmc: core: Don't export some eMMC specific functions from core.c
  2017-06-08 13:27 ` [PATCH 1/9] mmc: core: Don't export some eMMC specific functions from core.c Ulf Hansson
@ 2017-06-09 13:22   ` Linus Walleij
  2017-06-09 13:32     ` Ulf Hansson
  0 siblings, 1 reply; 22+ messages in thread
From: Linus Walleij @ 2017-06-09 13:22 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, Jaehoon Chung, Adrian Hunter

On Thu, Jun 8, 2017 at 3:27 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:

> The mmc_start|stop_bkops(), mmc_read_bkops_status() and mmc_interrupt_hpi()
> functions are all used from within the mmc core module, thus there are no
> need to use EXPORT_SYMBOL() for them, so let's remove it.
>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

> @@ -428,7 +428,6 @@ void mmc_start_bkops(struct mmc_card *card, bool from_exception)
>  out:
>         mmc_release_host(card->host);
>  }
> -EXPORT_SYMBOL(mmc_start_bkops);

For this one, you can also mark it static, and remove the prototype in
mmc_ops.h.

It is only called from inside the same file!

>  int mmc_read_bkops_status(struct mmc_card *card)
>  {
> @@ -887,7 +884,6 @@ int mmc_read_bkops_status(struct mmc_card *card)
>         kfree(ext_csd);
>         return 0;
>  }
> -EXPORT_SYMBOL(mmc_read_bkops_status);

Same for this, but you may have to move the function above
the call site so it compiles.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 2/9] mmc: core: Move mmc bkops functions from core.c to mmc_ops.c
  2017-06-08 13:27 ` [PATCH 2/9] mmc: core: Move mmc bkops functions from core.c to mmc_ops.c Ulf Hansson
@ 2017-06-09 13:23   ` Linus Walleij
  2017-06-09 13:34     ` Ulf Hansson
  0 siblings, 1 reply; 22+ messages in thread
From: Linus Walleij @ 2017-06-09 13:23 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, Jaehoon Chung, Adrian Hunter

On Thu, Jun 8, 2017 at 3:27 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:

> The mmc_start_bkops(), mmc_stop_bkops() and mmc_read_bkops_status()
> functions are all specific to eMMCs. To make this clear, let's move them
> from from core.c to mmc_ops.c.
>
> While moving them, get rid of MMC_BKOPS_MAX_TIMEOUT (4 min) and use the
> common default timeout MMC_OPS_TIMEOUT_MS (10 min) instead, as there is no
> need to have specific default timeout for bkops.
>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Oh then my previous suggestion to mark those static are not
very good.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 3/9] mmc: core: Move mmc_interrupt_hpi() from core.c to mmc_ops.c
  2017-06-08 13:27 ` [PATCH 3/9] mmc: core: Move mmc_interrupt_hpi() " Ulf Hansson
@ 2017-06-09 13:24   ` Linus Walleij
  0 siblings, 0 replies; 22+ messages in thread
From: Linus Walleij @ 2017-06-09 13:24 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, Jaehoon Chung, Adrian Hunter

On Thu, Jun 8, 2017 at 3:27 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:

> The mmc_interrupt_hpi() is a eMMC specific function, let's move it to
> mmc_ops.c to make that clear. The move also enables us to make
> mmc_send_hpi_cmd() static, so let's do that change as well.
>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 4/9] mmc: core: Move mmc_flush_cache() from core.c to mmc_ops.c
  2017-06-08 13:27 ` [PATCH 4/9] mmc: core: Move mmc_flush_cache() " Ulf Hansson
@ 2017-06-09 13:25   ` Linus Walleij
  0 siblings, 0 replies; 22+ messages in thread
From: Linus Walleij @ 2017-06-09 13:25 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, Jaehoon Chung, Adrian Hunter

On Thu, Jun 8, 2017 at 3:27 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:

> The mmc_flush_cache() is a eMMC specific function, let's move it to
> mmc_ops.c to make that clear.
>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 5/9] mmc: core: Make mmc_can_reset() static
  2017-06-08 13:27 ` [PATCH 5/9] mmc: core: Make mmc_can_reset() static Ulf Hansson
@ 2017-06-09 13:27   ` Linus Walleij
  0 siblings, 0 replies; 22+ messages in thread
From: Linus Walleij @ 2017-06-09 13:27 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, Jaehoon Chung, Adrian Hunter

On Thu, Jun 8, 2017 at 3:27 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:

> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 6/9] mmc: core: Remove redundant code in mmc_send_cid()
  2017-06-08 13:27 ` [PATCH 6/9] mmc: core: Remove redundant code in mmc_send_cid() Ulf Hansson
@ 2017-06-09 13:29   ` Linus Walleij
  0 siblings, 0 replies; 22+ messages in thread
From: Linus Walleij @ 2017-06-09 13:29 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, Jaehoon Chung, Adrian Hunter

On Thu, Jun 8, 2017 at 3:27 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:

> The mmc_send_cid() is never called using non SPI mode. Thus, let's remove
> the redundant code dealing with this.
>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 7/9] mmc: core: Re-factor code for sending CID
  2017-06-08 13:27 ` [PATCH 7/9] mmc: core: Re-factor code for sending CID Ulf Hansson
@ 2017-06-09 13:32   ` Linus Walleij
  0 siblings, 0 replies; 22+ messages in thread
From: Linus Walleij @ 2017-06-09 13:32 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, Jaehoon Chung, Adrian Hunter

On Thu, Jun 8, 2017 at 3:27 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:

> Instead of having the caller to check for SPI mode, let's leave that to
> internals of mmc_send_cid(). In this way the code gets cleaner and it
> becomes clear what is specific to SPI and non-SPI mode.
>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 1/9] mmc: core: Don't export some eMMC specific functions from core.c
  2017-06-09 13:22   ` Linus Walleij
@ 2017-06-09 13:32     ` Ulf Hansson
  0 siblings, 0 replies; 22+ messages in thread
From: Ulf Hansson @ 2017-06-09 13:32 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-mmc, Jaehoon Chung, Adrian Hunter

On 9 June 2017 at 15:22, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Thu, Jun 8, 2017 at 3:27 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
>> The mmc_start|stop_bkops(), mmc_read_bkops_status() and mmc_interrupt_hpi()
>> functions are all used from within the mmc core module, thus there are no
>> need to use EXPORT_SYMBOL() for them, so let's remove it.
>>
>> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>
>> @@ -428,7 +428,6 @@ void mmc_start_bkops(struct mmc_card *card, bool from_exception)
>>  out:
>>         mmc_release_host(card->host);
>>  }
>> -EXPORT_SYMBOL(mmc_start_bkops);
>
> For this one, you can also mark it static, and remove the prototype in
> mmc_ops.h.
>
> It is only called from inside the same file!

Nope, used from core.c

>
>>  int mmc_read_bkops_status(struct mmc_card *card)
>>  {
>> @@ -887,7 +884,6 @@ int mmc_read_bkops_status(struct mmc_card *card)
>>         kfree(ext_csd);
>>         return 0;
>>  }
>> -EXPORT_SYMBOL(mmc_read_bkops_status);
>
> Same for this, but you may have to move the function above
> the call site so it compiles.

Done in patch2.

>
> Yours,
> Linus Walleij

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 8/9] mmc: core: Drop mmc_all_send_cid() and use mmc_send_cxd_native() instead
  2017-06-08 13:27 ` [PATCH 8/9] mmc: core: Drop mmc_all_send_cid() and use mmc_send_cxd_native() instead Ulf Hansson
@ 2017-06-09 13:32   ` Linus Walleij
  0 siblings, 0 replies; 22+ messages in thread
From: Linus Walleij @ 2017-06-09 13:32 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, Jaehoon Chung, Adrian Hunter

On Thu, Jun 8, 2017 at 3:27 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:

> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 9/9] mmc: core: Clarify code for sending CSD
  2017-06-08 13:27 ` [PATCH 9/9] mmc: core: Clarify code for sending CSD Ulf Hansson
@ 2017-06-09 13:33   ` Linus Walleij
  0 siblings, 0 replies; 22+ messages in thread
From: Linus Walleij @ 2017-06-09 13:33 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, Jaehoon Chung, Adrian Hunter

On Thu, Jun 8, 2017 at 3:27 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:

> To make the code more consistent and to increase readability, add an
> mmc_spi_send_csd() function, which gets called from mmc_send_csd() in case
> of SPI mode.
>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 2/9] mmc: core: Move mmc bkops functions from core.c to mmc_ops.c
  2017-06-09 13:23   ` Linus Walleij
@ 2017-06-09 13:34     ` Ulf Hansson
  0 siblings, 0 replies; 22+ messages in thread
From: Ulf Hansson @ 2017-06-09 13:34 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-mmc, Jaehoon Chung, Adrian Hunter

On 9 June 2017 at 15:23, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Thu, Jun 8, 2017 at 3:27 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
>> The mmc_start_bkops(), mmc_stop_bkops() and mmc_read_bkops_status()
>> functions are all specific to eMMCs. To make this clear, let's move them
>> from from core.c to mmc_ops.c.
>>
>> While moving them, get rid of MMC_BKOPS_MAX_TIMEOUT (4 min) and use the
>> common default timeout MMC_OPS_TIMEOUT_MS (10 min) instead, as there is no
>> need to have specific default timeout for bkops.
>>
>> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>
> Oh then my previous suggestion to mark those static are not
> very good.

Actually there is v2 of this change, taking into consideration your
suggestions of making functions static.

>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
>
> Yours,
> Linus Walleij

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 0/9] mmc: core: Some trivial re-factoring and cleanups
  2017-06-08 13:27 [PATCH 0/9] mmc: core: Some trivial re-factoring and cleanups Ulf Hansson
                   ` (8 preceding siblings ...)
  2017-06-08 13:27 ` [PATCH 9/9] mmc: core: Clarify code for sending CSD Ulf Hansson
@ 2017-06-16  0:49 ` Shawn Lin
  9 siblings, 0 replies; 22+ messages in thread
From: Shawn Lin @ 2017-06-16  0:49 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, shawn.lin, Jaehoon Chung, Adrian Hunter, Linus Walleij

Hi Ulf,

On 2017/6/8 21:27, Ulf Hansson wrote:
> I have collected some cleanups along the road on the mmc core, now I thought it
> was time to post them. None of these changes causes any functional changes, but
> the goal is rather to just make the code more readable and avoid open coding.
> 
> 
> Ulf Hansson (9):
>    mmc: core: Don't export some eMMC specific functions from core.c
>    mmc: core: Move mmc bkops functions from core.c to mmc_ops.c
>    mmc: core: Move mmc_interrupt_hpi() from core.c to mmc_ops.c
>    mmc: core: Move mmc_flush_cache() from core.c to mmc_ops.c
>    mmc: core: Make mmc_can_reset() static
>    mmc: core: Remove redundant code in mmc_send_cid()
>    mmc: core: Re-factor code for sending CID
>    mmc: core: Drop mmc_all_send_cid() and use mmc_send_cxd_native()
>      instead
>    mmc: core: Clarify code for sending CSD

Looks good to me, so

Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>

> 
>   drivers/mmc/core/core.c    | 207 -------------------------------------
>   drivers/mmc/core/mmc.c     |   8 +-
>   drivers/mmc/core/mmc_ops.c | 250 +++++++++++++++++++++++++++++++++++++++------
>   drivers/mmc/core/mmc_ops.h |   3 -
>   drivers/mmc/core/sd.c      |   6 +-
>   5 files changed, 221 insertions(+), 253 deletions(-)
> 


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2017-06-16  0:49 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-08 13:27 [PATCH 0/9] mmc: core: Some trivial re-factoring and cleanups Ulf Hansson
2017-06-08 13:27 ` [PATCH 1/9] mmc: core: Don't export some eMMC specific functions from core.c Ulf Hansson
2017-06-09 13:22   ` Linus Walleij
2017-06-09 13:32     ` Ulf Hansson
2017-06-08 13:27 ` [PATCH 2/9] mmc: core: Move mmc bkops functions from core.c to mmc_ops.c Ulf Hansson
2017-06-09 13:23   ` Linus Walleij
2017-06-09 13:34     ` Ulf Hansson
2017-06-08 13:27 ` [PATCH 3/9] mmc: core: Move mmc_interrupt_hpi() " Ulf Hansson
2017-06-09 13:24   ` Linus Walleij
2017-06-08 13:27 ` [PATCH 4/9] mmc: core: Move mmc_flush_cache() " Ulf Hansson
2017-06-09 13:25   ` Linus Walleij
2017-06-08 13:27 ` [PATCH 5/9] mmc: core: Make mmc_can_reset() static Ulf Hansson
2017-06-09 13:27   ` Linus Walleij
2017-06-08 13:27 ` [PATCH 6/9] mmc: core: Remove redundant code in mmc_send_cid() Ulf Hansson
2017-06-09 13:29   ` Linus Walleij
2017-06-08 13:27 ` [PATCH 7/9] mmc: core: Re-factor code for sending CID Ulf Hansson
2017-06-09 13:32   ` Linus Walleij
2017-06-08 13:27 ` [PATCH 8/9] mmc: core: Drop mmc_all_send_cid() and use mmc_send_cxd_native() instead Ulf Hansson
2017-06-09 13:32   ` Linus Walleij
2017-06-08 13:27 ` [PATCH 9/9] mmc: core: Clarify code for sending CSD Ulf Hansson
2017-06-09 13:33   ` Linus Walleij
2017-06-16  0:49 ` [PATCH 0/9] mmc: core: Some trivial re-factoring and cleanups Shawn Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.