diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2007-02-20 09:04:34 +0100 |
---|---|---|
committer | Stefan Roese <sr@denx.de> | 2007-02-20 09:04:34 +0100 |
commit | 735dd97b1b20e777d059c7b389fe9d70cd3f80c7 (patch) | |
tree | eb62a0abe8bdea88c563380c302a88fa64eff151 /disk | |
parent | 620d3c9a14affca29a5c4e575e9f355c2bd4aed2 (diff) | |
download | u-boot-735dd97b1b20e777d059c7b389fe9d70cd3f80c7.tar.gz u-boot-735dd97b1b20e777d059c7b389fe9d70cd3f80c7.tar.xz u-boot-735dd97b1b20e777d059c7b389fe9d70cd3f80c7.zip |
[PATCH 1_4] Merge common get_dev() routines for block devices
Each of the filesystem drivers duplicate the get_dev routine. This change
merges them into a single function in part.c
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'disk')
-rw-r--r-- | disk/part.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/disk/part.c b/disk/part.c index 2255e726cf..f1026c5ef2 100644 --- a/disk/part.c +++ b/disk/part.c @@ -24,6 +24,7 @@ #include <common.h> #include <command.h> #include <ide.h> +#include <part.h> #undef PART_DEBUG @@ -39,6 +40,54 @@ defined(CONFIG_MMC) || \ defined(CONFIG_SYSTEMACE) ) +struct block_drvr { + char *name; + block_dev_desc_t* (*get_dev)(int dev); +}; + +static const struct block_drvr block_drvr[] = { +#if (CONFIG_COMMANDS & CFG_CMD_IDE) + { .name = "ide", .get_dev = ide_get_dev, }, +#endif +#if (CONFIG_COMMANDS & CFG_CMD_SCSI) + { .name = "scsi", .get_dev = scsi_get_dev, }, +#endif +#if ((CONFIG_COMMANDS & CFG_CMD_USB) && defined(CONFIG_USB_STORAGE)) + { .name = "usb", .get_dev = usb_stor_get_dev, }, +#endif +#if defined(CONFIG_MMC) + { .name = "mmc", .get_dev = mmc_get_dev, }, +#endif +#if defined(CONFIG_SYSTEMACE) + { .name = "ace", .get_dev = systemace_get_dev, }, +#endif + { }, +}; + +block_dev_desc_t *get_dev(char* ifname, int dev) +{ + const struct block_drvr *drvr = block_drvr; + + while (drvr->name) { + if (strncmp(ifname, drvr->name, strlen(drvr->name)) == 0) + return drvr->get_dev(dev); + drvr++; + } + return NULL; +} +#else +block_dev_desc_t *get_dev(char* ifname, int dev) +{ + return NULL; +} +#endif + +#if ((CONFIG_COMMANDS & CFG_CMD_IDE) || \ + (CONFIG_COMMANDS & CFG_CMD_SCSI) || \ + (CONFIG_COMMANDS & CFG_CMD_USB) || \ + defined(CONFIG_MMC) || \ + defined(CONFIG_SYSTEMACE) ) + /* ------------------------------------------------------------------------- */ /* * reports device info to the user |