public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: John Keeping <john@metanate.com>
To: linux-mmc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Jaehoon Chung <jh80.chung@samsung.com>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	John Keeping <john@metanate.com>
Subject: [PATCH 1/2] mmc: dw_mmc: extract ctrl_id lookup to a function
Date: Tue, 16 Nov 2021 19:02:43 +0000	[thread overview]
Message-ID: <20211116190244.1417591-2-john@metanate.com> (raw)
In-Reply-To: <20211116190244.1417591-1-john@metanate.com>

An upcoming commit will change the logic to use the standard "mmc" stem
for looking up the alias, while keeping the nonstandard "mshc" stem for
backwards compatibility.  In preparation for this, extract a common
function to replace the two places that currently replicate this lookup.

There is no functional change intended here.

Signed-off-by: John Keeping <john@metanate.com>
---
 drivers/mmc/host/dw_mmc-k3.c |  4 +---
 drivers/mmc/host/dw_mmc.c    | 24 ++++++++++++++++++------
 drivers/mmc/host/dw_mmc.h    |  2 ++
 3 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc-k3.c b/drivers/mmc/host/dw_mmc-k3.c
index 0311a37dd4ab..0d82e6f54cca 100644
--- a/drivers/mmc/host/dw_mmc-k3.c
+++ b/drivers/mmc/host/dw_mmc-k3.c
@@ -127,9 +127,7 @@ static int dw_mci_hi6220_parse_dt(struct dw_mci *host)
 	if (IS_ERR(priv->reg))
 		priv->reg = NULL;
 
-	priv->ctrl_id = of_alias_get_id(host->dev->of_node, "mshc");
-	if (priv->ctrl_id < 0)
-		priv->ctrl_id = 0;
+	priv->ctrl_id = dw_mci_of_alias_get_id(host);
 
 	if (priv->ctrl_id >= TIMING_MODE)
 		return -EINVAL;
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 1bedef827138..37af1245304b 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -105,6 +105,21 @@ struct idmac_desc {
 /* Each descriptor can transfer up to 4KB of data in chained mode */
 #define DW_MCI_DESC_DATA_LENGTH	0x1000
 
+int dw_mci_of_alias_get_id(struct dw_mci *host)
+{
+	int ctrl_id;
+
+	if (WARN_ON(!host->dev->of_node))
+		return 0;
+
+	ctrl_id = of_alias_get_id(host->dev->of_node, "mshc");
+
+	if (ctrl_id < 0)
+		ctrl_id = 0;
+
+	return ctrl_id;
+}
+
 #if defined(CONFIG_DEBUG_FS)
 static int dw_mci_req_show(struct seq_file *s, void *v)
 {
@@ -2855,13 +2870,10 @@ static int dw_mci_init_slot_caps(struct dw_mci_slot *slot)
 	if (host->pdata->pm_caps)
 		mmc->pm_caps = host->pdata->pm_caps;
 
-	if (host->dev->of_node) {
-		ctrl_id = of_alias_get_id(host->dev->of_node, "mshc");
-		if (ctrl_id < 0)
-			ctrl_id = 0;
-	} else {
+	if (host->dev->of_node)
+		ctrl_id = dw_mci_of_alias_get_id(host);
+	else
 		ctrl_id = to_platform_device(host->dev)->id;
-	}
 
 	if (drv_data && drv_data->caps) {
 		if (ctrl_id >= drv_data->num_caps) {
diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
index ce05d81477d9..9e643d7fe90b 100644
--- a/drivers/mmc/host/dw_mmc.h
+++ b/drivers/mmc/host/dw_mmc.h
@@ -508,6 +508,8 @@ extern int dw_mci_runtime_suspend(struct device *device);
 extern int dw_mci_runtime_resume(struct device *device);
 #endif
 
+extern int dw_mci_of_alias_get_id(struct dw_mci *host);
+
 /**
  * struct dw_mci_slot - MMC slot state
  * @mmc: The mmc_host representing this slot.
-- 
2.34.0


  reply	other threads:[~2021-11-16 19:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-16 19:02 [PATCH 0/2] mmc: dw_mmc: use standard "mmc" alias stem John Keeping
2021-11-16 19:02 ` John Keeping [this message]
2021-11-16 19:02 ` [PATCH 2/2] " John Keeping
2021-11-23 19:34   ` Ulf Hansson
2021-11-24  9:54     ` Jaehoon Chung
2021-11-24 12:29       ` John Keeping
2021-11-24 15:13         ` Ulf Hansson
2021-11-24 12:52       ` Christian Löhle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211116190244.1417591-2-john@metanate.com \
    --to=john@metanate.com \
    --cc=jh80.chung@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox