Linux MultiMedia Card development
 help / color / mirror / Atom feed
* [RFC PATCH 00/11] mmc: rename mmc_can_* functions
@ 2025-04-01  9:58 Wolfram Sang
  2025-04-01  9:58 ` [RFC PATCH 01/11] mmc: rename mmc_can_discard() to mmc_card_can_discard() Wolfram Sang
                   ` (11 more replies)
  0 siblings, 12 replies; 15+ messages in thread
From: Wolfram Sang @ 2025-04-01  9:58 UTC (permalink / raw)
  To: linux-mmc; +Cc: Ulf Hansson

As mentioned in [1], here is a series which rename mmc_can_* functions
to names which include 'card' or 'host' in the name. I am only an
occasional MMC core hacker, and these namings would have made my life
quite easier in past times. So, here is my proposed change. Have a look
and let me know if you like it. Plain RFC for now. Notes:

* This series is based on [1] which needs changes. My idea would be to
  respin the series on rc1 right after it is out.
* I intentionally left mmc_can_retune() out because it seems more
  consistent with all the other mmc_*_retune() functions
* Builds fine locally, tested on a Renesas Salvator-X with R-Car M3-W.
  buildbots still need to check it, branch is here:
  git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/mmc/unbind-power-off

What do you think?


[1] https://lore.kernel.org/r/20250320140040.162416-1-ulf.hansson@linaro.org

Wolfram Sang (11):
  mmc: rename mmc_can_discard() to mmc_card_can_discard()
  mmc: rename mmc_can_erase() to mmc_card_can_erase()
  mmc: rename mmc_can_ext_csd() to mmc_card_can_ext_csd()
  mmc: rename mmc_can_poweroff_notify() to
    mmc_card_can_poweroff_notify()
  mmc: rename mmc_can_reset() to mmc_card_can_reset()
  mmc: rename mmc_can_sanitize() to mmc_card_can_sanitize()
  mmc: rename mmc_can_secure_erase_trim() to
    mmc_card_can_secure_erase_trim()
  mmc: rename mmc_can_sleep() to mmc_card_can_sleep()
  mmc: rename mmc_can_trim() to mmc_card_can_trim()
  mmc: rename mmc_can_gpio_cd() to mmc_host_can_gpio_cd()
  mmc: rename mmc_can_gpio_ro() to mmc_host_can_gpio_ro()

 drivers/mmc/core/block.c             |  6 ++--
 drivers/mmc/core/core.c              | 48 ++++++++++++----------------
 drivers/mmc/core/core.h              | 10 +++---
 drivers/mmc/core/mmc.c               | 30 ++++++++---------
 drivers/mmc/core/mmc_ops.c           |  6 ++--
 drivers/mmc/core/mmc_ops.h           |  2 +-
 drivers/mmc/core/mmc_test.c          | 12 +++----
 drivers/mmc/core/queue.c             |  6 ++--
 drivers/mmc/core/slot-gpio.c         |  8 ++---
 drivers/mmc/host/dw_mmc.c            |  6 ++--
 drivers/mmc/host/mtk-sd.c            |  2 +-
 drivers/mmc/host/renesas_sdhi_core.c |  2 +-
 drivers/mmc/host/sdhci-omap.c        |  2 +-
 drivers/mmc/host/sdhci.c             |  6 ++--
 drivers/mmc/host/sunplus-mmc.c       |  2 +-
 drivers/mmc/host/tmio_mmc_core.c     |  6 ++--
 include/linux/mmc/slot-gpio.h        |  4 +--
 17 files changed, 74 insertions(+), 84 deletions(-)

-- 
2.47.2


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

* [RFC PATCH 01/11] mmc: rename mmc_can_discard() to mmc_card_can_discard()
  2025-04-01  9:58 [RFC PATCH 00/11] mmc: rename mmc_can_* functions Wolfram Sang
@ 2025-04-01  9:58 ` Wolfram Sang
  2025-04-01  9:58 ` [RFC PATCH 02/11] mmc: rename mmc_can_erase() to mmc_card_can_erase() Wolfram Sang
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Wolfram Sang @ 2025-04-01  9:58 UTC (permalink / raw)
  To: linux-mmc; +Cc: Ulf Hansson

mmc_can_* functions sometimes relate to the card and sometimes to the host.
Make it obvious by renaming this function to include 'card'. Also, convert to
proper bool type while we are here.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/core/core.c | 8 +++-----
 drivers/mmc/core/core.h | 2 +-
 drivers/mmc/core/mmc.c  | 2 +-
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index ce08e0ea7fc1..8bc46ea370e8 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1854,17 +1854,15 @@ int mmc_can_trim(struct mmc_card *card)
 }
 EXPORT_SYMBOL(mmc_can_trim);
 
-int mmc_can_discard(struct mmc_card *card)
+bool mmc_card_can_discard(struct mmc_card *card)
 {
 	/*
 	 * As there's no way to detect the discard support bit at v4.5
 	 * use the s/w feature support filed.
 	 */
-	if (card->ext_csd.feature_support & MMC_DISCARD_FEATURE)
-		return 1;
-	return 0;
+	return (card->ext_csd.feature_support & MMC_DISCARD_FEATURE);
 }
-EXPORT_SYMBOL(mmc_can_discard);
+EXPORT_SYMBOL(mmc_card_can_discard);
 
 int mmc_can_sanitize(struct mmc_card *card)
 {
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index fc9c066e6468..e88b64379ab0 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -120,7 +120,7 @@ int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq);
 int mmc_erase(struct mmc_card *card, sector_t from, unsigned int nr, unsigned int arg);
 int mmc_can_erase(struct mmc_card *card);
 int mmc_can_trim(struct mmc_card *card);
-int mmc_can_discard(struct mmc_card *card);
+bool mmc_card_can_discard(struct mmc_card *card);
 int mmc_can_sanitize(struct mmc_card *card);
 int mmc_can_secure_erase_trim(struct mmc_card *card);
 int mmc_erase_group_aligned(struct mmc_card *card, sector_t from, unsigned int nr);
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index df5de69b981b..0bcad3ec8c83 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1804,7 +1804,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 	}
 
 	/* set erase_arg */
-	if (mmc_can_discard(card))
+	if (mmc_card_can_discard(card))
 		card->erase_arg = MMC_DISCARD_ARG;
 	else if (mmc_can_trim(card))
 		card->erase_arg = MMC_TRIM_ARG;
-- 
2.47.2


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

* [RFC PATCH 02/11] mmc: rename mmc_can_erase() to mmc_card_can_erase()
  2025-04-01  9:58 [RFC PATCH 00/11] mmc: rename mmc_can_* functions Wolfram Sang
  2025-04-01  9:58 ` [RFC PATCH 01/11] mmc: rename mmc_can_discard() to mmc_card_can_discard() Wolfram Sang
@ 2025-04-01  9:58 ` Wolfram Sang
  2025-04-01  9:58 ` [RFC PATCH 03/11] mmc: rename mmc_can_ext_csd() to mmc_card_can_ext_csd() Wolfram Sang
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Wolfram Sang @ 2025-04-01  9:58 UTC (permalink / raw)
  To: linux-mmc; +Cc: Ulf Hansson

mmc_can_* functions sometimes relate to the card and sometimes to the host.
Make it obvious by renaming this function to include 'card'. Also, convert to
proper bool type while we are here.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/core/block.c    |  2 +-
 drivers/mmc/core/core.c     | 10 ++++------
 drivers/mmc/core/core.h     |  2 +-
 drivers/mmc/core/mmc_test.c |  8 ++++----
 drivers/mmc/core/queue.c    |  2 +-
 5 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 4830628510e6..e9213de4a9fe 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -1220,7 +1220,7 @@ static void mmc_blk_issue_erase_rq(struct mmc_queue *mq, struct request *req,
 	int err = 0;
 	blk_status_t status = BLK_STS_OK;
 
-	if (!mmc_can_erase(card)) {
+	if (!mmc_card_can_erase(card)) {
 		status = BLK_STS_NOTSUPP;
 		goto fail;
 	}
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 8bc46ea370e8..e7449d03f311 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1837,13 +1837,11 @@ int mmc_erase(struct mmc_card *card, sector_t from, unsigned int nr,
 }
 EXPORT_SYMBOL(mmc_erase);
 
-int mmc_can_erase(struct mmc_card *card)
+bool mmc_card_can_erase(struct mmc_card *card)
 {
-	if (card->csd.cmdclass & CCC_ERASE && card->erase_size)
-		return 1;
-	return 0;
+	return (card->csd.cmdclass & CCC_ERASE && card->erase_size);
 }
-EXPORT_SYMBOL(mmc_can_erase);
+EXPORT_SYMBOL(mmc_card_can_erase);
 
 int mmc_can_trim(struct mmc_card *card)
 {
@@ -1866,7 +1864,7 @@ EXPORT_SYMBOL(mmc_card_can_discard);
 
 int mmc_can_sanitize(struct mmc_card *card)
 {
-	if (!mmc_can_trim(card) && !mmc_can_erase(card))
+	if (!mmc_can_trim(card) && !mmc_card_can_erase(card))
 		return 0;
 	if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_SANITIZE)
 		return 1;
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index e88b64379ab0..2e66d8321626 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -118,7 +118,7 @@ bool mmc_is_req_done(struct mmc_host *host, struct mmc_request *mrq);
 int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq);
 
 int mmc_erase(struct mmc_card *card, sector_t from, unsigned int nr, unsigned int arg);
-int mmc_can_erase(struct mmc_card *card);
+bool mmc_card_can_erase(struct mmc_card *card);
 int mmc_can_trim(struct mmc_card *card);
 bool mmc_card_can_discard(struct mmc_card *card);
 int mmc_can_sanitize(struct mmc_card *card);
diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c
index 4f4286b8e0f2..190ae178da84 100644
--- a/drivers/mmc/core/mmc_test.c
+++ b/drivers/mmc/core/mmc_test.c
@@ -1510,7 +1510,7 @@ static int mmc_test_area_erase(struct mmc_test_card *test)
 {
 	struct mmc_test_area *t = &test->area;
 
-	if (!mmc_can_erase(test->card))
+	if (!mmc_card_can_erase(test->card))
 		return 0;
 
 	return mmc_erase(test->card, t->dev_addr, t->max_sz >> 9,
@@ -1749,7 +1749,7 @@ static int mmc_test_profile_trim_perf(struct mmc_test_card *test)
 	if (!mmc_can_trim(test->card))
 		return RESULT_UNSUP_CARD;
 
-	if (!mmc_can_erase(test->card))
+	if (!mmc_card_can_erase(test->card))
 		return RESULT_UNSUP_HOST;
 
 	for (sz = 512; sz < t->max_sz; sz <<= 1) {
@@ -1866,7 +1866,7 @@ static int mmc_test_profile_seq_trim_perf(struct mmc_test_card *test)
 	if (!mmc_can_trim(test->card))
 		return RESULT_UNSUP_CARD;
 
-	if (!mmc_can_erase(test->card))
+	if (!mmc_card_can_erase(test->card))
 		return RESULT_UNSUP_HOST;
 
 	for (sz = 512; sz <= t->max_sz; sz <<= 1) {
@@ -2114,7 +2114,7 @@ static int mmc_test_rw_multiple(struct mmc_test_card *test,
 		return 0;
 
 	/* prepare test area */
-	if (mmc_can_erase(test->card) &&
+	if (mmc_card_can_erase(test->card) &&
 	    tdata->prepare & MMC_TEST_PREP_ERASE) {
 		ret = mmc_erase(test->card, dev_addr,
 				size / 512, test->card->erase_arg);
diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c
index 3ba62f825b84..099fee86d088 100644
--- a/drivers/mmc/core/queue.c
+++ b/drivers/mmc/core/queue.c
@@ -352,7 +352,7 @@ static struct gendisk *mmc_alloc_disk(struct mmc_queue *mq,
 	};
 	struct gendisk *disk;
 
-	if (mmc_can_erase(card))
+	if (mmc_card_can_erase(card))
 		mmc_queue_setup_discard(card, &lim);
 
 	lim.max_hw_sectors = min(host->max_blk_count, host->max_req_size / 512);
-- 
2.47.2


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

* [RFC PATCH 03/11] mmc: rename mmc_can_ext_csd() to mmc_card_can_ext_csd()
  2025-04-01  9:58 [RFC PATCH 00/11] mmc: rename mmc_can_* functions Wolfram Sang
  2025-04-01  9:58 ` [RFC PATCH 01/11] mmc: rename mmc_can_discard() to mmc_card_can_discard() Wolfram Sang
  2025-04-01  9:58 ` [RFC PATCH 02/11] mmc: rename mmc_can_erase() to mmc_card_can_erase() Wolfram Sang
@ 2025-04-01  9:58 ` Wolfram Sang
  2025-04-01  9:58 ` [RFC PATCH 04/11] mmc: rename mmc_can_poweroff_notify() to mmc_card_can_poweroff_notify() Wolfram Sang
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Wolfram Sang @ 2025-04-01  9:58 UTC (permalink / raw)
  To: linux-mmc; +Cc: Ulf Hansson

mmc_can_* functions sometimes relate to the card and sometimes to the host.
Make it obvious by renaming this function to include 'card'. Also, convert to
proper bool type while we are here.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/core/mmc.c     | 8 ++++----
 drivers/mmc/core/mmc_ops.c | 4 ++--
 drivers/mmc/core/mmc_ops.h | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 0bcad3ec8c83..2b63eb608489 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -680,7 +680,7 @@ static int mmc_read_ext_csd(struct mmc_card *card)
 	u8 *ext_csd;
 	int err;
 
-	if (!mmc_can_ext_csd(card))
+	if (!mmc_card_can_ext_csd(card))
 		return 0;
 
 	err = mmc_get_ext_csd(card, &ext_csd);
@@ -959,7 +959,7 @@ static int mmc_select_powerclass(struct mmc_card *card)
 	int err, ddr;
 
 	/* Power class selection is supported for versions >= 4.0 */
-	if (!mmc_can_ext_csd(card))
+	if (!mmc_card_can_ext_csd(card))
 		return 0;
 
 	bus_width = host->ios.bus_width;
@@ -1022,7 +1022,7 @@ static int mmc_select_bus_width(struct mmc_card *card)
 	unsigned idx, bus_width = 0;
 	int err = 0;
 
-	if (!mmc_can_ext_csd(card) ||
+	if (!mmc_card_can_ext_csd(card) ||
 	    !(host->caps & (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)))
 		return 0;
 
@@ -1543,7 +1543,7 @@ static int mmc_select_timing(struct mmc_card *card)
 {
 	int err = 0;
 
-	if (!mmc_can_ext_csd(card))
+	if (!mmc_card_can_ext_csd(card))
 		goto bus_speed;
 
 	if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400ES) {
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 5c8e62e8f331..638e87a861bc 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -383,7 +383,7 @@ int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd)
 	if (!card || !new_ext_csd)
 		return -EINVAL;
 
-	if (!mmc_can_ext_csd(card))
+	if (!mmc_card_can_ext_csd(card))
 		return -EOPNOTSUPP;
 
 	/*
@@ -944,7 +944,7 @@ static int mmc_interrupt_hpi(struct mmc_card *card)
 	return err;
 }
 
-int mmc_can_ext_csd(struct mmc_card *card)
+bool mmc_card_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 0df3ebd900d1..514c40ff4b4e 100644
--- a/drivers/mmc/core/mmc_ops.h
+++ b/drivers/mmc/core/mmc_ops.h
@@ -37,7 +37,7 @@ 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_can_ext_csd(struct mmc_card *card);
+bool mmc_card_can_ext_csd(struct mmc_card *card);
 int mmc_switch_status(struct mmc_card *card, bool crc_err_fatal);
 bool mmc_prepare_busy_cmd(struct mmc_host *host, struct mmc_command *cmd,
 			  unsigned int timeout_ms);
-- 
2.47.2


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

* [RFC PATCH 04/11] mmc: rename mmc_can_poweroff_notify() to mmc_card_can_poweroff_notify()
  2025-04-01  9:58 [RFC PATCH 00/11] mmc: rename mmc_can_* functions Wolfram Sang
                   ` (2 preceding siblings ...)
  2025-04-01  9:58 ` [RFC PATCH 03/11] mmc: rename mmc_can_ext_csd() to mmc_card_can_ext_csd() Wolfram Sang
@ 2025-04-01  9:58 ` Wolfram Sang
  2025-04-01  9:58 ` [RFC PATCH 05/11] mmc: rename mmc_can_reset() to mmc_card_can_reset() Wolfram Sang
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Wolfram Sang @ 2025-04-01  9:58 UTC (permalink / raw)
  To: linux-mmc; +Cc: Ulf Hansson

mmc_can_* functions sometimes relate to the card and sometimes to the host.
Make it obvious by renaming this function to include 'card'.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/core/mmc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 2b63eb608489..8911b2206c45 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -2013,7 +2013,7 @@ static int mmc_sleep(struct mmc_host *host)
 	return err;
 }
 
-static bool mmc_can_poweroff_notify(const struct mmc_card *card)
+static bool mmc_card_can_poweroff_notify(const struct mmc_card *card)
 {
 	return card &&
 		mmc_card_mmc(card) &&
@@ -2137,7 +2137,7 @@ static int _mmc_suspend(struct mmc_host *host, enum mmc_poweroff_type pm_type)
 		goto out;
 
 pr_info("%s: reason %d, may_notify %d\n", mmc_hostname(host), pm_type, mmc_may_poweroff_notify(host, pm_type));
-	if (mmc_can_poweroff_notify(host->card) &&
+	if (mmc_card_can_poweroff_notify(host->card) &&
 	    mmc_may_poweroff_notify(host, pm_type))
 		err = mmc_poweroff_notify(host->card, notify_type);
 	else if (mmc_can_sleep(host->card))
@@ -2217,7 +2217,7 @@ static int mmc_shutdown(struct mmc_host *host)
 	 * In a specific case for poweroff notify, we need to resume the card
 	 * before we can shutdown it properly.
 	 */
-	if (mmc_can_poweroff_notify(host->card) &&
+	if (mmc_card_can_poweroff_notify(host->card) &&
 	    !mmc_may_poweroff_notify(host, MMC_POWEROFF_SUSPEND))
 		err = _mmc_resume(host);
 
-- 
2.47.2


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

* [RFC PATCH 05/11] mmc: rename mmc_can_reset() to mmc_card_can_reset()
  2025-04-01  9:58 [RFC PATCH 00/11] mmc: rename mmc_can_* functions Wolfram Sang
                   ` (3 preceding siblings ...)
  2025-04-01  9:58 ` [RFC PATCH 04/11] mmc: rename mmc_can_poweroff_notify() to mmc_card_can_poweroff_notify() Wolfram Sang
@ 2025-04-01  9:58 ` Wolfram Sang
  2025-04-01  9:58 ` [RFC PATCH 06/11] mmc: rename mmc_can_sanitize() to mmc_card_can_sanitize() Wolfram Sang
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Wolfram Sang @ 2025-04-01  9:58 UTC (permalink / raw)
  To: linux-mmc; +Cc: Ulf Hansson

mmc_can_* functions sometimes relate to the card and sometimes to the host.
Make it obvious by renaming this function to include 'card'. Also, convert to
proper bool type while we are here. Conversion was simplified by
inverting the logic.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/core/mmc.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 8911b2206c45..8fde20ba3d95 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -2269,14 +2269,12 @@ static int mmc_runtime_resume(struct mmc_host *host)
 	return 0;
 }
 
-static int mmc_can_reset(struct mmc_card *card)
+static bool mmc_card_can_reset(struct mmc_card *card)
 {
 	u8 rst_n_function;
 
 	rst_n_function = card->ext_csd.rst_n_function;
-	if ((rst_n_function & EXT_CSD_RST_N_EN_MASK) != EXT_CSD_RST_N_ENABLED)
-		return 0;
-	return 1;
+	return ((rst_n_function & EXT_CSD_RST_N_EN_MASK) == EXT_CSD_RST_N_ENABLED);
 }
 
 static int _mmc_hw_reset(struct mmc_host *host)
@@ -2290,7 +2288,7 @@ static int _mmc_hw_reset(struct mmc_host *host)
 	_mmc_flush_cache(host);
 
 	if ((host->caps & MMC_CAP_HW_RESET) && host->ops->card_hw_reset &&
-	     mmc_can_reset(card)) {
+	     mmc_card_can_reset(card)) {
 		/* If the card accept RST_n signal, send it. */
 		mmc_set_clock(host, host->f_init);
 		host->ops->card_hw_reset(host);
-- 
2.47.2


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

* [RFC PATCH 06/11] mmc: rename mmc_can_sanitize() to mmc_card_can_sanitize()
  2025-04-01  9:58 [RFC PATCH 00/11] mmc: rename mmc_can_* functions Wolfram Sang
                   ` (4 preceding siblings ...)
  2025-04-01  9:58 ` [RFC PATCH 05/11] mmc: rename mmc_can_reset() to mmc_card_can_reset() Wolfram Sang
@ 2025-04-01  9:58 ` Wolfram Sang
  2025-04-01  9:58 ` [RFC PATCH 07/11] mmc: rename mmc_can_secure_erase_trim() to mmc_card_can_secure_erase_trim() Wolfram Sang
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Wolfram Sang @ 2025-04-01  9:58 UTC (permalink / raw)
  To: linux-mmc; +Cc: Ulf Hansson

mmc_can_* functions sometimes relate to the card and sometimes to the host.
Make it obvious by renaming this function to include 'card'. Also, convert to
proper bool type while we are here.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/core/core.c    | 8 ++++----
 drivers/mmc/core/core.h    | 2 +-
 drivers/mmc/core/mmc_ops.c | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index e7449d03f311..ff75336eb1ae 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1862,13 +1862,13 @@ bool mmc_card_can_discard(struct mmc_card *card)
 }
 EXPORT_SYMBOL(mmc_card_can_discard);
 
-int mmc_can_sanitize(struct mmc_card *card)
+bool mmc_card_can_sanitize(struct mmc_card *card)
 {
 	if (!mmc_can_trim(card) && !mmc_card_can_erase(card))
-		return 0;
+		return false;
 	if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_SANITIZE)
-		return 1;
-	return 0;
+		return true;
+	return false;
 }
 
 int mmc_can_secure_erase_trim(struct mmc_card *card)
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index 2e66d8321626..1f194665499d 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -121,7 +121,7 @@ int mmc_erase(struct mmc_card *card, sector_t from, unsigned int nr, unsigned in
 bool mmc_card_can_erase(struct mmc_card *card);
 int mmc_can_trim(struct mmc_card *card);
 bool mmc_card_can_discard(struct mmc_card *card);
-int mmc_can_sanitize(struct mmc_card *card);
+bool mmc_card_can_sanitize(struct mmc_card *card);
 int mmc_can_secure_erase_trim(struct mmc_card *card);
 int mmc_erase_group_aligned(struct mmc_card *card, sector_t from, unsigned int nr);
 unsigned int mmc_calc_max_discard(struct mmc_card *card);
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 638e87a861bc..66283825513c 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -1046,7 +1046,7 @@ int mmc_sanitize(struct mmc_card *card, unsigned int timeout_ms)
 	struct mmc_host *host = card->host;
 	int err;
 
-	if (!mmc_can_sanitize(card)) {
+	if (!mmc_card_can_sanitize(card)) {
 		pr_warn("%s: Sanitize not supported\n", mmc_hostname(host));
 		return -EOPNOTSUPP;
 	}
-- 
2.47.2


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

* [RFC PATCH 07/11] mmc: rename mmc_can_secure_erase_trim() to mmc_card_can_secure_erase_trim()
  2025-04-01  9:58 [RFC PATCH 00/11] mmc: rename mmc_can_* functions Wolfram Sang
                   ` (5 preceding siblings ...)
  2025-04-01  9:58 ` [RFC PATCH 06/11] mmc: rename mmc_can_sanitize() to mmc_card_can_sanitize() Wolfram Sang
@ 2025-04-01  9:58 ` Wolfram Sang
  2025-04-01  9:58 ` [RFC PATCH 08/11] mmc: rename mmc_can_sleep() to mmc_card_can_sleep() Wolfram Sang
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Wolfram Sang @ 2025-04-01  9:58 UTC (permalink / raw)
  To: linux-mmc; +Cc: Ulf Hansson

mmc_can_* functions sometimes relate to the card and sometimes to the host.
Make it obvious by renaming this function to include 'card'. Also, convert to
proper bool type while we are here.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/core/block.c |  2 +-
 drivers/mmc/core/core.c  | 10 ++++------
 drivers/mmc/core/core.h  |  2 +-
 drivers/mmc/core/queue.c |  2 +-
 4 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index e9213de4a9fe..02a11a757360 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -1276,7 +1276,7 @@ static void mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
 	int err = 0, type = MMC_BLK_SECDISCARD;
 	blk_status_t status = BLK_STS_OK;
 
-	if (!(mmc_can_secure_erase_trim(card))) {
+	if (!(mmc_card_can_secure_erase_trim(card))) {
 		status = BLK_STS_NOTSUPP;
 		goto out;
 	}
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index ff75336eb1ae..f451903891a1 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1871,14 +1871,12 @@ bool mmc_card_can_sanitize(struct mmc_card *card)
 	return false;
 }
 
-int mmc_can_secure_erase_trim(struct mmc_card *card)
+bool mmc_card_can_secure_erase_trim(struct mmc_card *card)
 {
-	if ((card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN) &&
-	    !(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN))
-		return 1;
-	return 0;
+	return ((card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN) &&
+		!(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN));
 }
-EXPORT_SYMBOL(mmc_can_secure_erase_trim);
+EXPORT_SYMBOL(mmc_card_can_secure_erase_trim);
 
 int mmc_erase_group_aligned(struct mmc_card *card, sector_t from,
 			    unsigned int nr)
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index 1f194665499d..3f7bd25e9557 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -122,7 +122,7 @@ bool mmc_card_can_erase(struct mmc_card *card);
 int mmc_can_trim(struct mmc_card *card);
 bool mmc_card_can_discard(struct mmc_card *card);
 bool mmc_card_can_sanitize(struct mmc_card *card);
-int mmc_can_secure_erase_trim(struct mmc_card *card);
+bool mmc_card_can_secure_erase_trim(struct mmc_card *card);
 int mmc_erase_group_aligned(struct mmc_card *card, sector_t from, unsigned int nr);
 unsigned int mmc_calc_max_discard(struct mmc_card *card);
 
diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c
index 099fee86d088..f65bf1717bbd 100644
--- a/drivers/mmc/core/queue.c
+++ b/drivers/mmc/core/queue.c
@@ -184,7 +184,7 @@ static void mmc_queue_setup_discard(struct mmc_card *card,
 		return;
 
 	lim->max_hw_discard_sectors = max_discard;
-	if (mmc_can_secure_erase_trim(card))
+	if (mmc_card_can_secure_erase_trim(card))
 		lim->max_secure_erase_sectors = max_discard;
 	if (mmc_can_trim(card) && card->erased_byte == 0)
 		lim->max_write_zeroes_sectors = max_discard;
-- 
2.47.2


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

* [RFC PATCH 08/11] mmc: rename mmc_can_sleep() to mmc_card_can_sleep()
  2025-04-01  9:58 [RFC PATCH 00/11] mmc: rename mmc_can_* functions Wolfram Sang
                   ` (6 preceding siblings ...)
  2025-04-01  9:58 ` [RFC PATCH 07/11] mmc: rename mmc_can_secure_erase_trim() to mmc_card_can_secure_erase_trim() Wolfram Sang
@ 2025-04-01  9:58 ` Wolfram Sang
  2025-04-01  9:58 ` [RFC PATCH 09/11] mmc: rename mmc_can_trim() to mmc_card_can_trim() Wolfram Sang
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Wolfram Sang @ 2025-04-01  9:58 UTC (permalink / raw)
  To: linux-mmc; +Cc: Ulf Hansson

mmc_can_* functions sometimes relate to the card and sometimes to the host.
Make it obvious by renaming this function to include 'card'. Also, convert to
proper bool type while we are here.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/core/mmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 8fde20ba3d95..80bb0a68b037 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1955,7 +1955,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 	return err;
 }
 
-static int mmc_can_sleep(struct mmc_card *card)
+static bool mmc_card_can_sleep(struct mmc_card *card)
 {
 	return card->ext_csd.rev >= 3;
 }
@@ -2140,7 +2140,7 @@ pr_info("%s: reason %d, may_notify %d\n", mmc_hostname(host), pm_type, mmc_may_p
 	if (mmc_card_can_poweroff_notify(host->card) &&
 	    mmc_may_poweroff_notify(host, pm_type))
 		err = mmc_poweroff_notify(host->card, notify_type);
-	else if (mmc_can_sleep(host->card))
+	else if (mmc_card_can_sleep(host->card))
 		err = mmc_sleep(host);
 	else if (!mmc_host_is_spi(host))
 		err = mmc_deselect_cards(host);
-- 
2.47.2


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

* [RFC PATCH 09/11] mmc: rename mmc_can_trim() to mmc_card_can_trim()
  2025-04-01  9:58 [RFC PATCH 00/11] mmc: rename mmc_can_* functions Wolfram Sang
                   ` (7 preceding siblings ...)
  2025-04-01  9:58 ` [RFC PATCH 08/11] mmc: rename mmc_can_sleep() to mmc_card_can_sleep() Wolfram Sang
@ 2025-04-01  9:58 ` Wolfram Sang
  2025-04-01  9:58 ` [RFC PATCH 10/11] mmc: rename mmc_can_gpio_cd() to mmc_host_can_gpio_cd() Wolfram Sang
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Wolfram Sang @ 2025-04-01  9:58 UTC (permalink / raw)
  To: linux-mmc; +Cc: Ulf Hansson

mmc_can_* functions sometimes relate to the card and sometimes to the host.
Make it obvious by renaming this function to include 'card'. Also, convert to
proper bool type while we are here.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/core/block.c    |  2 +-
 drivers/mmc/core/core.c     | 14 ++++++--------
 drivers/mmc/core/core.h     |  2 +-
 drivers/mmc/core/mmc.c      |  2 +-
 drivers/mmc/core/mmc_test.c |  4 ++--
 drivers/mmc/core/queue.c    |  2 +-
 6 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 02a11a757360..63320cc441c1 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -1284,7 +1284,7 @@ static void mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
 	from = blk_rq_pos(req);
 	nr = blk_rq_sectors(req);
 
-	if (mmc_can_trim(card) && !mmc_erase_group_aligned(card, from, nr))
+	if (mmc_card_can_trim(card) && !mmc_erase_group_aligned(card, from, nr))
 		arg = MMC_SECURE_TRIM1_ARG;
 	else
 		arg = MMC_SECURE_ERASE_ARG;
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index f451903891a1..a0e2dce70434 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1843,14 +1843,12 @@ bool mmc_card_can_erase(struct mmc_card *card)
 }
 EXPORT_SYMBOL(mmc_card_can_erase);
 
-int mmc_can_trim(struct mmc_card *card)
+bool mmc_card_can_trim(struct mmc_card *card)
 {
-	if ((card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN) &&
-	    (!(card->quirks & MMC_QUIRK_TRIM_BROKEN)))
-		return 1;
-	return 0;
+	return ((card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN) &&
+		(!(card->quirks & MMC_QUIRK_TRIM_BROKEN)));
 }
-EXPORT_SYMBOL(mmc_can_trim);
+EXPORT_SYMBOL(mmc_card_can_trim);
 
 bool mmc_card_can_discard(struct mmc_card *card)
 {
@@ -1864,7 +1862,7 @@ EXPORT_SYMBOL(mmc_card_can_discard);
 
 bool mmc_card_can_sanitize(struct mmc_card *card)
 {
-	if (!mmc_can_trim(card) && !mmc_card_can_erase(card))
+	if (!mmc_card_can_trim(card) && !mmc_card_can_erase(card))
 		return false;
 	if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_SANITIZE)
 		return true;
@@ -1981,7 +1979,7 @@ unsigned int mmc_calc_max_discard(struct mmc_card *card)
 		return card->pref_erase;
 
 	max_discard = mmc_do_calc_max_discard(card, MMC_ERASE_ARG);
-	if (mmc_can_trim(card)) {
+	if (mmc_card_can_trim(card)) {
 		max_trim = mmc_do_calc_max_discard(card, MMC_TRIM_ARG);
 		if (max_trim < max_discard || max_discard == 0)
 			max_discard = max_trim;
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index 3f7bd25e9557..622085cd766f 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -119,7 +119,7 @@ int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq);
 
 int mmc_erase(struct mmc_card *card, sector_t from, unsigned int nr, unsigned int arg);
 bool mmc_card_can_erase(struct mmc_card *card);
-int mmc_can_trim(struct mmc_card *card);
+bool mmc_card_can_trim(struct mmc_card *card);
 bool mmc_card_can_discard(struct mmc_card *card);
 bool mmc_card_can_sanitize(struct mmc_card *card);
 bool mmc_card_can_secure_erase_trim(struct mmc_card *card);
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 80bb0a68b037..6bd6fed59b9d 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1806,7 +1806,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 	/* set erase_arg */
 	if (mmc_card_can_discard(card))
 		card->erase_arg = MMC_DISCARD_ARG;
-	else if (mmc_can_trim(card))
+	else if (mmc_card_can_trim(card))
 		card->erase_arg = MMC_TRIM_ARG;
 	else
 		card->erase_arg = MMC_ERASE_ARG;
diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c
index 190ae178da84..be2d2895b4c4 100644
--- a/drivers/mmc/core/mmc_test.c
+++ b/drivers/mmc/core/mmc_test.c
@@ -1746,7 +1746,7 @@ static int mmc_test_profile_trim_perf(struct mmc_test_card *test)
 	struct timespec64 ts1, ts2;
 	int ret;
 
-	if (!mmc_can_trim(test->card))
+	if (!mmc_card_can_trim(test->card))
 		return RESULT_UNSUP_CARD;
 
 	if (!mmc_card_can_erase(test->card))
@@ -1863,7 +1863,7 @@ static int mmc_test_profile_seq_trim_perf(struct mmc_test_card *test)
 	struct timespec64 ts1, ts2;
 	int ret;
 
-	if (!mmc_can_trim(test->card))
+	if (!mmc_card_can_trim(test->card))
 		return RESULT_UNSUP_CARD;
 
 	if (!mmc_card_can_erase(test->card))
diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c
index f65bf1717bbd..284856c8f655 100644
--- a/drivers/mmc/core/queue.c
+++ b/drivers/mmc/core/queue.c
@@ -186,7 +186,7 @@ static void mmc_queue_setup_discard(struct mmc_card *card,
 	lim->max_hw_discard_sectors = max_discard;
 	if (mmc_card_can_secure_erase_trim(card))
 		lim->max_secure_erase_sectors = max_discard;
-	if (mmc_can_trim(card) && card->erased_byte == 0)
+	if (mmc_card_can_trim(card) && card->erased_byte == 0)
 		lim->max_write_zeroes_sectors = max_discard;
 
 	/* granularity must not be greater than max. discard */
-- 
2.47.2


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

* [RFC PATCH 10/11] mmc: rename mmc_can_gpio_cd() to mmc_host_can_gpio_cd()
  2025-04-01  9:58 [RFC PATCH 00/11] mmc: rename mmc_can_* functions Wolfram Sang
                   ` (8 preceding siblings ...)
  2025-04-01  9:58 ` [RFC PATCH 09/11] mmc: rename mmc_can_trim() to mmc_card_can_trim() Wolfram Sang
@ 2025-04-01  9:58 ` Wolfram Sang
  2025-04-01  9:58 ` [RFC PATCH 11/11] mmc: rename mmc_can_gpio_ro() to mmc_host_can_gpio_ro() Wolfram Sang
  2025-04-22 15:43 ` [RFC PATCH 00/11] mmc: rename mmc_can_* functions Ulf Hansson
  11 siblings, 0 replies; 15+ messages in thread
From: Wolfram Sang @ 2025-04-01  9:58 UTC (permalink / raw)
  To: linux-mmc; +Cc: Ulf Hansson

mmc_can_* functions sometimes relate to the card and sometimes to the host.
Make it obvious by renaming this function to include 'host'.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/core/slot-gpio.c     | 4 ++--
 drivers/mmc/host/dw_mmc.c        | 6 +++---
 drivers/mmc/host/mtk-sd.c        | 2 +-
 drivers/mmc/host/sdhci.c         | 4 ++--
 drivers/mmc/host/sunplus-mmc.c   | 2 +-
 drivers/mmc/host/tmio_mmc_core.c | 4 ++--
 include/linux/mmc/slot-gpio.h    | 2 +-
 7 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
index 5fd455816393..82a933d86889 100644
--- a/drivers/mmc/core/slot-gpio.c
+++ b/drivers/mmc/core/slot-gpio.c
@@ -228,13 +228,13 @@ int mmc_gpiod_set_cd_config(struct mmc_host *host, unsigned long config)
 }
 EXPORT_SYMBOL(mmc_gpiod_set_cd_config);
 
-bool mmc_can_gpio_cd(struct mmc_host *host)
+bool mmc_host_can_gpio_cd(struct mmc_host *host)
 {
 	struct mmc_gpio *ctx = host->slot.handler_priv;
 
 	return ctx->cd_gpio ? true : false;
 }
-EXPORT_SYMBOL(mmc_can_gpio_cd);
+EXPORT_SYMBOL(mmc_host_can_gpio_cd);
 
 /**
  * mmc_gpiod_request_ro - request a gpio descriptor for write protection
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index bb596d169420..8b4d1a3cd178 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -3622,7 +3622,7 @@ int dw_mci_runtime_suspend(struct device *dev)
 	clk_disable_unprepare(host->ciu_clk);
 
 	if (host->slot &&
-	    (mmc_can_gpio_cd(host->slot->mmc) ||
+	    (mmc_host_can_gpio_cd(host->slot->mmc) ||
 	     !mmc_card_is_removable(host->slot->mmc)))
 		clk_disable_unprepare(host->biu_clk);
 
@@ -3636,7 +3636,7 @@ int dw_mci_runtime_resume(struct device *dev)
 	struct dw_mci *host = dev_get_drvdata(dev);
 
 	if (host->slot &&
-	    (mmc_can_gpio_cd(host->slot->mmc) ||
+	    (mmc_host_can_gpio_cd(host->slot->mmc) ||
 	     !mmc_card_is_removable(host->slot->mmc))) {
 		ret = clk_prepare_enable(host->biu_clk);
 		if (ret)
@@ -3690,7 +3690,7 @@ int dw_mci_runtime_resume(struct device *dev)
 
 err:
 	if (host->slot &&
-	    (mmc_can_gpio_cd(host->slot->mmc) ||
+	    (mmc_host_can_gpio_cd(host->slot->mmc) ||
 	     !mmc_card_is_removable(host->slot->mmc)))
 		clk_disable_unprepare(host->biu_clk);
 
diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
index 345ea91629e0..66da4d7dc550 100644
--- a/drivers/mmc/host/mtk-sd.c
+++ b/drivers/mmc/host/mtk-sd.c
@@ -2977,7 +2977,7 @@ static int msdc_drv_probe(struct platform_device *pdev)
 		mmc->f_min = DIV_ROUND_UP(host->src_clk_freq, 4 * 4095);
 
 	if (!(mmc->caps & MMC_CAP_NONREMOVABLE) &&
-	    !mmc_can_gpio_cd(mmc) &&
+	    !mmc_host_can_gpio_cd(mmc) &&
 	    host->dev_comp->use_internal_cd) {
 		/*
 		 * Is removable but no GPIO declared, so
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 5f91b44891f9..4bffec30c508 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -158,7 +158,7 @@ static void sdhci_set_card_detection(struct sdhci_host *host, bool enable)
 	u32 present;
 
 	if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) ||
-	    !mmc_card_is_removable(host->mmc) || mmc_can_gpio_cd(host->mmc))
+	    !mmc_card_is_removable(host->mmc) || mmc_host_can_gpio_cd(host->mmc))
 		return;
 
 	if (enable) {
@@ -3744,7 +3744,7 @@ static bool sdhci_cd_irq_can_wakeup(struct sdhci_host *host)
 {
 	return mmc_card_is_removable(host->mmc) &&
 	       !(host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) &&
-	       !mmc_can_gpio_cd(host->mmc);
+	       !mmc_host_can_gpio_cd(host->mmc);
 }
 
 /*
diff --git a/drivers/mmc/host/sunplus-mmc.c b/drivers/mmc/host/sunplus-mmc.c
index 1cddea615a27..63279760239c 100644
--- a/drivers/mmc/host/sunplus-mmc.c
+++ b/drivers/mmc/host/sunplus-mmc.c
@@ -791,7 +791,7 @@ static int spmmc_get_cd(struct mmc_host *mmc)
 {
 	int ret = 0;
 
-	if (mmc_can_gpio_cd(mmc))
+	if (mmc_host_can_gpio_cd(mmc))
 		ret = mmc_gpio_get_cd(mmc);
 
 	if (ret < 0)
diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index 04c1c54df791..569b66d3d47a 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -1179,11 +1179,11 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
 	if (mmc_can_gpio_ro(mmc))
 		_host->ops.get_ro = mmc_gpio_get_ro;
 
-	if (mmc_can_gpio_cd(mmc))
+	if (mmc_host_can_gpio_cd(mmc))
 		_host->ops.get_cd = mmc_gpio_get_cd;
 
 	/* must be set before tmio_mmc_reset() */
-	_host->native_hotplug = !(mmc_can_gpio_cd(mmc) ||
+	_host->native_hotplug = !(mmc_host_can_gpio_cd(mmc) ||
 				  mmc->caps & MMC_CAP_NEEDS_POLL ||
 				  !mmc_card_is_removable(mmc));
 
diff --git a/include/linux/mmc/slot-gpio.h b/include/linux/mmc/slot-gpio.h
index 1ed7b0d1e4f9..4f6a46c636ec 100644
--- a/include/linux/mmc/slot-gpio.h
+++ b/include/linux/mmc/slot-gpio.h
@@ -24,7 +24,7 @@ int mmc_gpiod_request_ro(struct mmc_host *host, const char *con_id,
 int mmc_gpiod_set_cd_config(struct mmc_host *host, unsigned long config);
 int mmc_gpio_set_cd_wake(struct mmc_host *host, bool on);
 void mmc_gpiod_request_cd_irq(struct mmc_host *host);
-bool mmc_can_gpio_cd(struct mmc_host *host);
+bool mmc_host_can_gpio_cd(struct mmc_host *host);
 bool mmc_can_gpio_ro(struct mmc_host *host);
 
 #endif
-- 
2.47.2


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

* [RFC PATCH 11/11] mmc: rename mmc_can_gpio_ro() to mmc_host_can_gpio_ro()
  2025-04-01  9:58 [RFC PATCH 00/11] mmc: rename mmc_can_* functions Wolfram Sang
                   ` (9 preceding siblings ...)
  2025-04-01  9:58 ` [RFC PATCH 10/11] mmc: rename mmc_can_gpio_cd() to mmc_host_can_gpio_cd() Wolfram Sang
@ 2025-04-01  9:58 ` Wolfram Sang
  2025-04-22 15:43 ` [RFC PATCH 00/11] mmc: rename mmc_can_* functions Ulf Hansson
  11 siblings, 0 replies; 15+ messages in thread
From: Wolfram Sang @ 2025-04-01  9:58 UTC (permalink / raw)
  To: linux-mmc; +Cc: Ulf Hansson

mmc_can_* functions sometimes relate to the card and sometimes to the host.
Make it obvious by renaming this function to include 'host'.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/core/slot-gpio.c         | 4 ++--
 drivers/mmc/host/renesas_sdhi_core.c | 2 +-
 drivers/mmc/host/sdhci-omap.c        | 2 +-
 drivers/mmc/host/sdhci.c             | 2 +-
 drivers/mmc/host/tmio_mmc_core.c     | 2 +-
 include/linux/mmc/slot-gpio.h        | 2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
index 82a933d86889..c5bc6268803e 100644
--- a/drivers/mmc/core/slot-gpio.c
+++ b/drivers/mmc/core/slot-gpio.c
@@ -275,10 +275,10 @@ int mmc_gpiod_request_ro(struct mmc_host *host, const char *con_id,
 }
 EXPORT_SYMBOL(mmc_gpiod_request_ro);
 
-bool mmc_can_gpio_ro(struct mmc_host *host)
+bool mmc_host_can_gpio_ro(struct mmc_host *host)
 {
 	struct mmc_gpio *ctx = host->slot.handler_priv;
 
 	return ctx->ro_gpio ? true : false;
 }
-EXPORT_SYMBOL(mmc_can_gpio_ro);
+EXPORT_SYMBOL(mmc_host_can_gpio_ro);
diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index 4642fdb8bf65..c66dd85d33c5 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -1112,7 +1112,7 @@ int renesas_sdhi_probe(struct platform_device *pdev,
 		host->mmc->caps2 &= ~(MMC_CAP2_HS400 | MMC_CAP2_HS400_ES);
 
 	/* For some SoC, we disable internal WP. GPIO may override this */
-	if (mmc_can_gpio_ro(host->mmc))
+	if (mmc_host_can_gpio_ro(host->mmc))
 		mmc_data->capabilities2 &= ~MMC_CAP2_NO_WRITE_PROTECT;
 
 	/* SDR speeds are only available on Gen2+ */
diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
index 26a9a8b5682a..8897839ab2aa 100644
--- a/drivers/mmc/host/sdhci-omap.c
+++ b/drivers/mmc/host/sdhci-omap.c
@@ -1270,7 +1270,7 @@ static int sdhci_omap_probe(struct platform_device *pdev)
 			mmc->f_max = 48000000;
 	}
 
-	if (!mmc_can_gpio_ro(mmc))
+	if (!mmc_host_can_gpio_ro(mmc))
 		mmc->caps2 |= MMC_CAP2_NO_WRITE_PROTECT;
 
 	pltfm_host->clk = devm_clk_get(dev, "fck");
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 4bffec30c508..821cc916ad98 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2571,7 +2571,7 @@ int sdhci_get_ro(struct mmc_host *mmc)
 		is_readonly = 0;
 	} else if (host->ops->get_ro) {
 		is_readonly = host->ops->get_ro(host);
-	} else if (mmc_can_gpio_ro(mmc)) {
+	} else if (mmc_host_can_gpio_ro(mmc)) {
 		is_readonly = mmc_gpio_get_ro(mmc);
 		/* Do not invert twice */
 		allow_invert = !(mmc->caps2 & MMC_CAP2_RO_ACTIVE_HIGH);
diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index 569b66d3d47a..b71241f55df5 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -1176,7 +1176,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
 				  dma_max_mapping_size(&pdev->dev));
 	mmc->max_seg_size = mmc->max_req_size;
 
-	if (mmc_can_gpio_ro(mmc))
+	if (mmc_host_can_gpio_ro(mmc))
 		_host->ops.get_ro = mmc_gpio_get_ro;
 
 	if (mmc_host_can_gpio_cd(mmc))
diff --git a/include/linux/mmc/slot-gpio.h b/include/linux/mmc/slot-gpio.h
index 4f6a46c636ec..23ac5696fa38 100644
--- a/include/linux/mmc/slot-gpio.h
+++ b/include/linux/mmc/slot-gpio.h
@@ -25,6 +25,6 @@ int mmc_gpiod_set_cd_config(struct mmc_host *host, unsigned long config);
 int mmc_gpio_set_cd_wake(struct mmc_host *host, bool on);
 void mmc_gpiod_request_cd_irq(struct mmc_host *host);
 bool mmc_host_can_gpio_cd(struct mmc_host *host);
-bool mmc_can_gpio_ro(struct mmc_host *host);
+bool mmc_host_can_gpio_ro(struct mmc_host *host);
 
 #endif
-- 
2.47.2


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

* Re: [RFC PATCH 00/11] mmc: rename mmc_can_* functions
  2025-04-01  9:58 [RFC PATCH 00/11] mmc: rename mmc_can_* functions Wolfram Sang
                   ` (10 preceding siblings ...)
  2025-04-01  9:58 ` [RFC PATCH 11/11] mmc: rename mmc_can_gpio_ro() to mmc_host_can_gpio_ro() Wolfram Sang
@ 2025-04-22 15:43 ` Ulf Hansson
  2025-04-22 15:59   ` Wolfram Sang
  2025-04-23 20:29   ` Wolfram Sang
  11 siblings, 2 replies; 15+ messages in thread
From: Ulf Hansson @ 2025-04-22 15:43 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-mmc

On Tue, 1 Apr 2025 at 11:58, Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
>
> As mentioned in [1], here is a series which rename mmc_can_* functions
> to names which include 'card' or 'host' in the name. I am only an
> occasional MMC core hacker, and these namings would have made my life
> quite easier in past times. So, here is my proposed change. Have a look
> and let me know if you like it. Plain RFC for now. Notes:
>
> * This series is based on [1] which needs changes. My idea would be to
>   respin the series on rc1 right after it is out.
> * I intentionally left mmc_can_retune() out because it seems more
>   consistent with all the other mmc_*_retune() functions
> * Builds fine locally, tested on a Renesas Salvator-X with R-Car M3-W.
>   buildbots still need to check it, branch is here:
>   git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/mmc/unbind-power-off
>
> What do you think?
>
>
> [1] https://lore.kernel.org/r/20250320140040.162416-1-ulf.hansson@linaro.org
>
> Wolfram Sang (11):
>   mmc: rename mmc_can_discard() to mmc_card_can_discard()
>   mmc: rename mmc_can_erase() to mmc_card_can_erase()
>   mmc: rename mmc_can_ext_csd() to mmc_card_can_ext_csd()
>   mmc: rename mmc_can_poweroff_notify() to
>     mmc_card_can_poweroff_notify()
>   mmc: rename mmc_can_reset() to mmc_card_can_reset()
>   mmc: rename mmc_can_sanitize() to mmc_card_can_sanitize()
>   mmc: rename mmc_can_secure_erase_trim() to
>     mmc_card_can_secure_erase_trim()
>   mmc: rename mmc_can_sleep() to mmc_card_can_sleep()
>   mmc: rename mmc_can_trim() to mmc_card_can_trim()
>   mmc: rename mmc_can_gpio_cd() to mmc_host_can_gpio_cd()
>   mmc: rename mmc_can_gpio_ro() to mmc_host_can_gpio_ro()
>
>  drivers/mmc/core/block.c             |  6 ++--
>  drivers/mmc/core/core.c              | 48 ++++++++++++----------------
>  drivers/mmc/core/core.h              | 10 +++---
>  drivers/mmc/core/mmc.c               | 30 ++++++++---------
>  drivers/mmc/core/mmc_ops.c           |  6 ++--
>  drivers/mmc/core/mmc_ops.h           |  2 +-
>  drivers/mmc/core/mmc_test.c          | 12 +++----
>  drivers/mmc/core/queue.c             |  6 ++--
>  drivers/mmc/core/slot-gpio.c         |  8 ++---
>  drivers/mmc/host/dw_mmc.c            |  6 ++--
>  drivers/mmc/host/mtk-sd.c            |  2 +-
>  drivers/mmc/host/renesas_sdhi_core.c |  2 +-
>  drivers/mmc/host/sdhci-omap.c        |  2 +-
>  drivers/mmc/host/sdhci.c             |  6 ++--
>  drivers/mmc/host/sunplus-mmc.c       |  2 +-
>  drivers/mmc/host/tmio_mmc_core.c     |  6 ++--
>  include/linux/mmc/slot-gpio.h        |  4 +--
>  17 files changed, 74 insertions(+), 84 deletions(-)
>

Note that there are still some inconsistent naming of the functions
that correspond to the host's capabilities, beyond this series. For
example those we have in drivers/mmc/core/host.h. Would you mind
sending another series to rename those too?

That said, $subject series applied for next, thanks!

Kind regards
Uffe

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

* Re: [RFC PATCH 00/11] mmc: rename mmc_can_* functions
  2025-04-22 15:43 ` [RFC PATCH 00/11] mmc: rename mmc_can_* functions Ulf Hansson
@ 2025-04-22 15:59   ` Wolfram Sang
  2025-04-23 20:29   ` Wolfram Sang
  1 sibling, 0 replies; 15+ messages in thread
From: Wolfram Sang @ 2025-04-22 15:59 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc

[-- Attachment #1: Type: text/plain, Size: 577 bytes --]


> Note that there are still some inconsistent naming of the functions
> that correspond to the host's capabilities, beyond this series. For
> example those we have in drivers/mmc/core/host.h. Would you mind
> sending another series to rename those too?

Do you mean the mmc_retune* functions? I had this in the cover-letter
because I was unsure how to deal with it:

> > * I intentionally left mmc_can_retune() out because it seems more
> >   consistent with all the other mmc_*_retune() functions

But your comment now tells me I should convert them all to *_host_*,
right?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [RFC PATCH 00/11] mmc: rename mmc_can_* functions
  2025-04-22 15:43 ` [RFC PATCH 00/11] mmc: rename mmc_can_* functions Ulf Hansson
  2025-04-22 15:59   ` Wolfram Sang
@ 2025-04-23 20:29   ` Wolfram Sang
  1 sibling, 0 replies; 15+ messages in thread
From: Wolfram Sang @ 2025-04-23 20:29 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc

[-- Attachment #1: Type: text/plain, Size: 386 bytes --]


> example those we have in drivers/mmc/core/host.h. Would you mind
> sending another series to rename those too?

I pushed something out which builds fine locally but needs more coverage
from buildbots. If you want to peek, here is the branch:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/mmc/rename-funcs

I'll send patches once buildbots are happy.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2025-04-23 20:29 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-01  9:58 [RFC PATCH 00/11] mmc: rename mmc_can_* functions Wolfram Sang
2025-04-01  9:58 ` [RFC PATCH 01/11] mmc: rename mmc_can_discard() to mmc_card_can_discard() Wolfram Sang
2025-04-01  9:58 ` [RFC PATCH 02/11] mmc: rename mmc_can_erase() to mmc_card_can_erase() Wolfram Sang
2025-04-01  9:58 ` [RFC PATCH 03/11] mmc: rename mmc_can_ext_csd() to mmc_card_can_ext_csd() Wolfram Sang
2025-04-01  9:58 ` [RFC PATCH 04/11] mmc: rename mmc_can_poweroff_notify() to mmc_card_can_poweroff_notify() Wolfram Sang
2025-04-01  9:58 ` [RFC PATCH 05/11] mmc: rename mmc_can_reset() to mmc_card_can_reset() Wolfram Sang
2025-04-01  9:58 ` [RFC PATCH 06/11] mmc: rename mmc_can_sanitize() to mmc_card_can_sanitize() Wolfram Sang
2025-04-01  9:58 ` [RFC PATCH 07/11] mmc: rename mmc_can_secure_erase_trim() to mmc_card_can_secure_erase_trim() Wolfram Sang
2025-04-01  9:58 ` [RFC PATCH 08/11] mmc: rename mmc_can_sleep() to mmc_card_can_sleep() Wolfram Sang
2025-04-01  9:58 ` [RFC PATCH 09/11] mmc: rename mmc_can_trim() to mmc_card_can_trim() Wolfram Sang
2025-04-01  9:58 ` [RFC PATCH 10/11] mmc: rename mmc_can_gpio_cd() to mmc_host_can_gpio_cd() Wolfram Sang
2025-04-01  9:58 ` [RFC PATCH 11/11] mmc: rename mmc_can_gpio_ro() to mmc_host_can_gpio_ro() Wolfram Sang
2025-04-22 15:43 ` [RFC PATCH 00/11] mmc: rename mmc_can_* functions Ulf Hansson
2025-04-22 15:59   ` Wolfram Sang
2025-04-23 20:29   ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox