diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index c22f932c7..6d5a4bfc6 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 @@ -1787,6 +1789,8 @@ int mci_register(struct mci_host *host) if (IS_ENABLED(CONFIG_MCI_STARTUP)) mci_card_probe(mci); + list_add_tail(&mci->list, &mci_list); + return 0; err_unregister: @@ -1844,3 +1848,17 @@ 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 *mci; + + list_for_each_entry(mci, &mci_list, list) { + if (!mci->cdevname) + continue; + if (!strcmp(mci->cdevname, name)) + return mci; + } + + return NULL; +} diff --git a/include/mci.h b/include/mci.h index 9e4d18b06..41a757e6d 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,6 @@ static inline int mmc_host_is_spi(struct mci_host *host) return 0; } +struct mci *mci_get_device_by_name(const char *name); + #endif /* _MCI_H_ */