[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>
This commit is contained in:
committed by
Stefan Roese
parent
620d3c9a14
commit
735dd97b1b
49
disk/part.c
49
disk/part.c
@@ -24,6 +24,7 @@
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <ide.h>
|
||||
#include <part.h>
|
||||
|
||||
#undef PART_DEBUG
|
||||
|
||||
@@ -33,6 +34,54 @@
|
||||
#define PRINTF(fmt,args...)
|
||||
#endif
|
||||
|
||||
#if ((CONFIG_COMMANDS & CFG_CMD_IDE) || \
|
||||
(CONFIG_COMMANDS & CFG_CMD_SCSI) || \
|
||||
(CONFIG_COMMANDS & CFG_CMD_USB) || \
|
||||
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) || \
|
||||
|
||||
Reference in New Issue
Block a user