drivers: mci: Add mci_get_device_by_name function
Get a 'struct mci' by search after the device name. Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
1f76dfce39
commit
572e8cdfa3
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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_ */
|
||||
|
|
Loading…
Reference in New Issue