mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eugeniu Rosca <erosca@de.adit-jv.com>
To: Ulf Hansson <ulf.hansson@linaro.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	<linux-mmc@vger.kernel.org>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Mathieu Malaterre <malat@debian.org>, Pavel Machek <pavel@ucw.cz>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Eugeniu Rosca <erosca@de.adit-jv.com>,
	Eugeniu Rosca <roscaeugeniu@gmail.com>
Subject: [PATCH 2/3] mmc: host: Compress 'fixed-emmc-driver-type' handling
Date: Tue, 5 Nov 2019 06:50:14 +0100	[thread overview]
Message-ID: <20191105055015.23656-2-erosca@de.adit-jv.com> (raw)
In-Reply-To: <20191105055015.23656-1-erosca@de.adit-jv.com>

Prepare for reading two additional OF properties (inspired from
"fixed-emmc-driver-type"):
 - fixed-emmc-driver-type-hs200
 - fixed-emmc-driver-type-hs400

The parsing mechanism is common too all three, thus factored out.
The only functional change is a tiny update in the error message.

Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
---
 drivers/mmc/core/host.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 105b7a7c0251..54abfdfc69ba 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -161,6 +161,20 @@ static void mmc_retune_timer(struct timer_list *t)
 	mmc_retune_needed(host);
 }
 
+static void mmc_of_read_drv_type(struct mmc_host *host, char *prop, u32 *val)
+{
+	struct device *dev = host->parent;
+	u32 drv_type;
+
+	if (device_property_read_u32(dev, prop, &drv_type))
+		return;
+
+	if (host->caps & MMC_CAP_NONREMOVABLE)
+		*val = drv_type;
+	else
+		dev_err(dev, "can't use %s, media is removable\n", prop);
+}
+
 /**
  *	mmc_of_parse() - parse host's device-tree node
  *	@host: host whose node should be parsed.
@@ -173,7 +187,7 @@ static void mmc_retune_timer(struct timer_list *t)
 int mmc_of_parse(struct mmc_host *host)
 {
 	struct device *dev = host->parent;
-	u32 bus_width, drv_type, cd_debounce_delay_ms;
+	u32 bus_width, cd_debounce_delay_ms;
 	int ret;
 	bool cd_cap_invert, cd_gpio_invert = false;
 	bool ro_cap_invert, ro_gpio_invert = false;
@@ -321,13 +335,7 @@ int mmc_of_parse(struct mmc_host *host)
 		host->caps2 |= MMC_CAP2_NO_MMC;
 
 	/* Must be after "non-removable" check */
-	if (device_property_read_u32(dev, "fixed-emmc-driver-type", &drv_type) == 0) {
-		if (host->caps & MMC_CAP_NONREMOVABLE)
-			host->fixed_drv_type = drv_type;
-		else
-			dev_err(host->parent,
-				"can't use fixed driver type, media is removable\n");
-	}
+	mmc_of_read_drv_type(host, "fixed-emmc-driver-type", &host->fixed_drv_type);
 
 	host->dsr_req = !device_property_read_u32(dev, "dsr", &host->dsr);
 	if (host->dsr_req && (host->dsr & ~0xffff)) {
-- 
2.23.0


  reply	other threads:[~2019-11-05  5:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05  5:50 [PATCH 1/3] dt-bindings: mmc: Add 'fixed-emmc-driver-type-hs{200,400}' Eugeniu Rosca
2019-11-05  5:50 ` Eugeniu Rosca [this message]
2019-11-05  5:50 ` [PATCH 3/3] mmc: core: " Eugeniu Rosca
2019-11-05  6:22 ` [PATCH 1/3] dt-bindings: mmc: " Wolfram Sang
2019-11-05  8:32   ` Eugeniu Rosca
2019-11-07  0:39     ` Rob Herring
2019-11-12 21:19       ` Wolfram Sang
2019-11-12 23:11         ` Linus Walleij
2019-11-14 10:46         ` Ulf Hansson
2019-11-06 11:07 ` Linus Walleij
2019-11-11 22:25   ` Eugeniu Rosca
2019-11-12 23:08     ` Linus Walleij

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=20191105055015.23656-2-erosca@de.adit-jv.com \
    --to=erosca@de.adit-jv.com \
    --cc=adrian.hunter@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=malat@debian.org \
    --cc=pavel@ucw.cz \
    --cc=roscaeugeniu@gmail.com \
    --cc=ulf.hansson@linaro.org \
    --cc=wsa+renesas@sang-engineering.com \
    /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

all inboxes | Powered by JetHome®