Get a 'struct mci' by search after the device name. Signed-off-by: Daniel Schultz <d.schultz@xxxxxxxxx> --- 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@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox