mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/3] mci: implement detect driver callback
Date: Thu, 30 May 2013 14:40:30 +0200	[thread overview]
Message-ID: <1369917631-31436-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1369917631-31436-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/mci-core.c | 21 +++++++++++++++++++++
 include/mci.h          |  6 ++++--
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 416168f..50068a7 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1596,6 +1596,24 @@ static int mci_init(void)
 
 device_initcall(mci_init);
 
+int mci_detect_card(struct mci_host *host)
+{
+	int rc;
+
+	rc = mci_check_if_already_initialized(host->mci);
+	if (rc != 0)
+		return 0;
+
+	return mci_card_probe(host->mci);
+}
+
+static int mci_detect(struct device_d *dev)
+{
+	struct mci *mci = container_of(dev, struct mci, dev);
+
+	return mci_detect_card(mci->host);
+}
+
 /**
  * Create a new mci device (for convenience)
  * @param host mci_host for this MCI device
@@ -1619,6 +1637,9 @@ int mci_register(struct mci_host *host)
 
 	mci->dev.platform_data = host;
 	mci->dev.parent = host->hw_dev;
+	mci->host = host;
+	host->mci = mci;
+	mci->dev.detect = mci_detect;
 
 	ret = register_device(&mci->dev);
 	if (ret)
diff --git a/include/mci.h b/include/mci.h
index 1eb967d..eb8a195 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -285,9 +285,12 @@ struct mci_ios {
 #define MMC_1_8V_SDR_MODE	4
 };
 
+struct mci;
+
 /** host information */
 struct mci_host {
 	struct device_d *hw_dev;	/**< the host MCI hardware device */
+	struct mci *mci;
 	char *devname;			/**< the devicename for the card, defaults to disk%d */
 	unsigned voltages;
 	unsigned host_caps;	/**< Host's interface capabilities, refer MMC_VDD_* */
@@ -308,8 +311,6 @@ struct mci_host {
 	int (*card_write_protected)(struct mci_host *);
 };
 
-struct mci;
-
 #define MMC_NUM_BOOT_PARTITION	2
 #define MMC_NUM_GP_PARTITION	4
 #define MMC_NUM_PHY_PARTITION	6
@@ -362,5 +363,6 @@ struct mci {
 };
 
 int mci_register(struct mci_host*);
+int mci_detect_card(struct mci_host *);
 
 #endif /* _MCI_H_ */
-- 
1.8.2.rc2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2013-05-30 12:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-30 12:40 [PATCH] 'detect' command to detect devices Sascha Hauer
2013-05-30 12:40 ` [PATCH 1/3] devices: add detect mechanism Sascha Hauer
2013-05-30 12:40 ` Sascha Hauer [this message]
2013-05-30 12:40 ` [PATCH 3/3] mci fsl-esdhc: implement detect driver callback Sascha Hauer

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=1369917631-31436-3-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@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