From: Daniel Schultz <d.schultz@phytec.de>
To: barebox@lists.infradead.org
Subject: [PATCH v3 3/4] drivers: mci: Add mci_get_device_by_name function
Date: Wed, 2 Sep 2015 08:28:52 +0200 [thread overview]
Message-ID: <1441175333-26759-3-git-send-email-d.schultz@phytec.de> (raw)
In-Reply-To: <1441175333-26759-1-git-send-email-d.schultz@phytec.de>
Get a 'struct mci' by search after the device name.
Signed-off-by: Daniel Schultz <d.schultz@phytec.de>
---
Changes:
v3:
New with patch v3
drivers/mci/mci-core.c | 16 ++++++++++++++++
include/mci.h | 8 ++++++++
2 files changed, 24 insertions(+)
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index c22f932..d6865d1 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -53,6 +53,8 @@
__res & __mask; \
})
+LIST_HEAD(mci_list);
+
/**
* @file
* @brief Memory Card framework
@@ -1753,6 +1755,8 @@ int mci_register(struct mci_host *host)
mci->dev.id = DEVICE_ID_DYNAMIC;
}
+ list_add_tail(&mci->list, &mci_list);
+
mci->dev.platform_data = host;
mci->dev.parent = host->hw_dev;
mci->host = host;
@@ -1844,3 +1848,15 @@ void mci_of_parse(struct mci_host *host)
host->non_removable = of_property_read_bool(np, "non-removable");
}
+
+struct mci *mci_get_device_by_name(const char *name)
+{
+ struct mci *dev;
+
+ for_each_mci_device(dev) {
+ if (!strcmp(dev->cdevname, name))
+ return dev;
+ }
+
+ return NULL;
+}
diff --git a/include/mci.h b/include/mci.h
index 9e4d18b..3c7b407 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -466,6 +466,8 @@ struct mci {
struct mci_part *part_curr;
u8 ext_csd_part_config;
+
+ struct list_head list; /* The list of all mci devices */
};
int mci_register(struct mci_host*);
@@ -483,4 +485,10 @@ static inline int mmc_host_is_spi(struct mci_host *host)
return 0;
}
+/* Iterate over all mci devices
+ */
+#define for_each_mci_device(dev) list_for_each_entry(dev, &mci_list, list)
+
+struct mci *mci_get_device_by_name(const char *name);
+
#endif /* _MCI_H_ */
--
1.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2015-09-02 6:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-02 6:28 [PATCH v3 1/4] drivers: mci: Make two functions public Daniel Schultz
2015-09-02 6:28 ` [PATCH v3 2/4] include: mci: Add new ext. CSD field defines Daniel Schultz
2015-09-02 6:28 ` Daniel Schultz [this message]
2015-09-07 5:47 ` [PATCH v3 3/4] drivers: mci: Add mci_get_device_by_name function Sascha Hauer
2015-09-02 6:28 ` [PATCH v3 4/4] commands: Add MMC ext. CSD register tool Daniel Schultz
2015-09-07 7:00 ` 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=1441175333-26759-3-git-send-email-d.schultz@phytec.de \
--to=d.schultz@phytec.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