From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/5] mmc: sdhci-esdhc-imx: introduce function for parsing platform_data
Date: Fri, 23 May 2014 14:33:01 +0200 [thread overview]
Message-ID: <1400848384-3226-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1400848384-3226-1-git-send-email-s.hauer@pengutronix.de>
As a first step to separate the platform_data code from the
devicetree code add a function to parse the boarddata. Also
change the argument of the dt probe function from
struct esdhc_platform_data * to struct pltfm_imx_data *imx_data
which makes it possible to get struct esdhc_platform_data out
of the devicetree probing path.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mmc/host/sdhci-esdhc-imx.c | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index d530820..f6f7a45 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -901,8 +901,9 @@ static const struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
#ifdef CONFIG_OF
static int
sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
- struct esdhc_platform_data *boarddata)
+ struct pltfm_imx_data *imx_data)
{
+ struct esdhc_platform_data *boarddata = &imx_data->boarddata;
struct device_node *np = pdev->dev.of_node;
if (!np)
@@ -942,12 +943,28 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
#else
static inline int
sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
- struct esdhc_platform_data *boarddata)
+ struct pltfm_imx_data *imx_data)
{
return -ENODEV;
}
#endif
+static int
+sdhci_esdhc_imx_probe_boarddata(struct platform_device *pdev,
+ struct pltfm_imx_data *imx_data)
+{
+ struct esdhc_platform_data *pdata = pdev->dev.platform_data;
+
+ if (!pdata) {
+ dev_err(&pdev->dev, "no boarddata\n");
+ return -EINVAL;
+ }
+
+ imx_data->boarddata = *pdata;
+
+ return 0;
+}
+
static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
{
const struct of_device_id *of_id =
@@ -1037,14 +1054,10 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
host->ioaddr + ESDHC_TUNING_CTRL);
boarddata = &imx_data->boarddata;
- if (sdhci_esdhc_imx_probe_dt(pdev, boarddata) < 0) {
- if (!host->mmc->parent->platform_data) {
- dev_err(mmc_dev(host->mmc), "no board data!\n");
- err = -EINVAL;
+ if (sdhci_esdhc_imx_probe_dt(pdev, imx_data) < 0) {
+ err = sdhci_esdhc_imx_probe_boarddata(pdev, imx_data);
+ if (err)
goto disable_clk;
- }
- imx_data->boarddata = *((struct esdhc_platform_data *)
- host->mmc->parent->platform_data);
}
imx_data->f_max = clk_get_rate(imx_data->clk_per);
--
2.0.0.rc0
next prev parent reply other threads:[~2014-05-23 12:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-23 12:32 [PATCH] MMC: use mmc_of_parse in sdhci-esdhc-imx Sascha Hauer
2014-05-23 12:33 ` [PATCH 1/5] mmc: sdhci-esdhc-imx: add f_max field to private data Sascha Hauer
2014-06-01 7:45 ` Shawn Guo
2014-06-02 6:40 ` Sascha Hauer
2014-05-23 12:33 ` Sascha Hauer [this message]
2014-05-23 12:33 ` [PATCH 3/5] mmc: sdhci-esdhc-imx: straighten SDHCI_QUIRK_BROKEN_CARD_DETECTION flag Sascha Hauer
2014-05-23 12:33 ` [PATCH 4/5] mmc: sdhci-esdhc-imx: use mmc_of_parse Sascha Hauer
2014-05-23 12:33 ` [PATCH 5/5] ARM: dts: imx51-babbage: Fix esdhc setup Sascha Hauer
2014-06-01 15:22 ` Shawn Guo
2014-06-05 10:39 ` Sascha Hauer
2014-06-09 3:38 ` Shawn Guo
2014-06-09 3:41 ` Shawn Guo
2014-06-10 8:01 ` Lothar Waßmann
2014-06-21 7:56 ` Shawn Guo
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=1400848384-3226-3-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).