diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_ext2.c | 40 | ||||
-rw-r--r-- | common/cmd_fat.c | 37 | ||||
-rw-r--r-- | common/cmd_ide.c | 8 | ||||
-rw-r--r-- | common/cmd_reiser.c | 40 | ||||
-rw-r--r-- | common/cmd_scsi.c | 2 | ||||
-rw-r--r-- | common/cmd_usb.c | 1 | ||||
-rw-r--r-- | common/usb_storage.c | 3 |
7 files changed, 18 insertions, 113 deletions
diff --git a/common/cmd_ext2.c b/common/cmd_ext2.c index 5db42f2..94bd9b6 100644 --- a/common/cmd_ext2.c +++ b/common/cmd_ext2.c @@ -33,6 +33,7 @@ * Ext2fs support */ #include <common.h> +#include <part.h> #if (CONFIG_COMMANDS & CFG_CMD_EXT2) #include <config.h> @@ -57,41 +58,6 @@ #define PRINTF(fmt,args...) #endif -static block_dev_desc_t *get_dev (char* ifname, int dev) -{ -#if (CONFIG_COMMANDS & CFG_CMD_IDE) - if (strncmp(ifname,"ide",3)==0) { - extern block_dev_desc_t * ide_get_dev(int dev); - return((dev >= CFG_IDE_MAXDEVICE) ? NULL : ide_get_dev(dev)); - } -#endif -#if (CONFIG_COMMANDS & CFG_CMD_SCSI) - if (strncmp(ifname,"scsi",4)==0) { - extern block_dev_desc_t * scsi_get_dev(int dev); - return((dev >= CFG_SCSI_MAXDEVICE) ? NULL : scsi_get_dev(dev)); - } -#endif -#if ((CONFIG_COMMANDS & CFG_CMD_USB) && defined(CONFIG_USB_STORAGE)) - if (strncmp(ifname,"usb",3)==0) { - extern block_dev_desc_t * usb_stor_get_dev(int dev); - return((dev >= USB_MAX_STOR_DEV) ? NULL : usb_stor_get_dev(dev)); - } -#endif -#if defined(CONFIG_MMC) - if (strncmp(ifname,"mmc",3)==0) { - extern block_dev_desc_t * mmc_get_dev(int dev); - return((dev >= 1) ? NULL : mmc_get_dev(dev)); - } -#endif -#if defined(CONFIG_SYSTEMACE) - if (strcmp(ifname,"ace")==0) { - extern block_dev_desc_t * systemace_get_dev(int dev); - return((dev >= 1) ? NULL : systemace_get_dev(dev)); - } -#endif - return(NULL); -} - int do_ext2ls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { char *filename = "/"; @@ -106,7 +72,7 @@ int do_ext2ls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return(1); } dev = (int)simple_strtoul (argv[2], &ep, 16); - dev_desc=get_dev(argv[1],dev); + dev_desc = get_dev(argv[1],dev); if (dev_desc == NULL) { printf ("\n** Block device %s %d not supported\n", argv[1], dev); @@ -210,7 +176,7 @@ int do_ext2load (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } dev = (int)simple_strtoul (argv[2], &ep, 16); - dev_desc=get_dev(argv[1],dev); + dev_desc = get_dev(argv[1],dev); if (dev_desc==NULL) { printf ("\n** Block device %s %d not supported\n", argv[1], dev); return(1); diff --git a/common/cmd_fat.c b/common/cmd_fat.c index 6844c10..afaf299 100644 --- a/common/cmd_fat.c +++ b/common/cmd_fat.c @@ -29,6 +29,7 @@ #include <s_record.h> #include <net.h> #include <ata.h> +#include <part.h> #if (CONFIG_COMMANDS & CFG_CMD_FAT) @@ -37,42 +38,6 @@ #include <fat.h> -block_dev_desc_t *get_dev (char* ifname, int dev) -{ -#if (CONFIG_COMMANDS & CFG_CMD_IDE) - if (strncmp(ifname,"ide",3)==0) { - extern block_dev_desc_t * ide_get_dev(int dev); - return(ide_get_dev(dev)); - } -#endif -#if (CONFIG_COMMANDS & CFG_CMD_SCSI) - if (strncmp(ifname,"scsi",4)==0) { - extern block_dev_desc_t * scsi_get_dev(int dev); - return(scsi_get_dev(dev)); - } -#endif -#if ((CONFIG_COMMANDS & CFG_CMD_USB) && defined(CONFIG_USB_STORAGE)) - if (strncmp(ifname,"usb",3)==0) { - extern block_dev_desc_t * usb_stor_get_dev(int dev); - return(usb_stor_get_dev(dev)); - } -#endif -#if defined(CONFIG_MMC) - if (strncmp(ifname,"mmc",3)==0) { - extern block_dev_desc_t * mmc_get_dev(int dev); - return(mmc_get_dev(dev)); - } -#endif -#if defined(CONFIG_SYSTEMACE) - if (strcmp(ifname,"ace")==0) { - extern block_dev_desc_t * systemace_get_dev(int dev); - return(systemace_get_dev(dev)); - } -#endif - return NULL; -} - - int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { long size; diff --git a/common/cmd_ide.c b/common/cmd_ide.c index a415502..ebc080c 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -31,20 +31,26 @@ #include <command.h> #include <image.h> #include <asm/byteorder.h> + #if defined(CONFIG_IDE_8xx_DIRECT) || defined(CONFIG_IDE_PCMCIA) # include <pcmcia.h> #endif + #ifdef CONFIG_8xx # include <mpc8xx.h> #endif + #ifdef CONFIG_MPC5xxx #include <mpc5xxx.h> #endif + #include <ide.h> #include <ata.h> + #ifdef CONFIG_STATUS_LED # include <status_led.h> #endif + #ifndef __PPC__ #include <asm/io.h> #ifdef __MIPS__ @@ -697,7 +703,7 @@ void ide_init (void) block_dev_desc_t * ide_get_dev(int dev) { - return ((block_dev_desc_t *)&ide_dev_desc[dev]); + return (dev < CFG_IDE_MAXDEVICE) ? &ide_dev_desc[dev] : NULL; } diff --git a/common/cmd_reiser.c b/common/cmd_reiser.c index 508ffcb..09c86e6 100644 --- a/common/cmd_reiser.c +++ b/common/cmd_reiser.c @@ -35,6 +35,7 @@ #include <linux/ctype.h> #include <asm/byteorder.h> #include <reiserfs.h> +#include <part.h> #ifndef CONFIG_DOS_PARTITION #error DOS partition support must be selected @@ -48,41 +49,6 @@ #define PRINTF(fmt,args...) #endif -static block_dev_desc_t *get_dev (char* ifname, int dev) -{ -#if (CONFIG_COMMANDS & CFG_CMD_IDE) - if (strncmp(ifname,"ide",3)==0) { - extern block_dev_desc_t * ide_get_dev(int dev); - return((dev >= CFG_IDE_MAXDEVICE) ? NULL : ide_get_dev(dev)); - } -#endif -#if (CONFIG_COMMANDS & CFG_CMD_SCSI) - if (strncmp(ifname,"scsi",4)==0) { - extern block_dev_desc_t * scsi_get_dev(int dev); - return((dev >= CFG_SCSI_MAXDEVICE) ? NULL : scsi_get_dev(dev)); - } -#endif -#if ((CONFIG_COMMANDS & CFG_CMD_USB) && defined(CONFIG_USB_STORAGE)) - if (strncmp(ifname,"usb",3)==0) { - extern block_dev_desc_t * usb_stor_get_dev(int dev); - return((dev >= USB_MAX_STOR_DEV) ? NULL : usb_stor_get_dev(dev)); - } -#endif -#if defined(CONFIG_MMC) - if (strncmp(ifname,"mmc",3)==0) { - extern block_dev_desc_t * mmc_get_dev(int dev); - return((dev >= 1) ? NULL : mmc_get_dev(dev)); - } -#endif -#if defined(CONFIG_SYSTEMACE) - if (strcmp(ifname,"ace")==0) { - extern block_dev_desc_t * systemace_get_dev(int dev); - return((dev >= 1) ? NULL : systemace_get_dev(dev)); - } -#endif - return NULL; -} - int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { char *filename = "/"; @@ -97,7 +63,7 @@ int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 1; } dev = (int)simple_strtoul (argv[2], &ep, 16); - dev_desc=get_dev(argv[1],dev); + dev_desc = get_dev(argv[1],dev); if (dev_desc == NULL) { printf ("\n** Block device %s %d not supported\n", argv[1], dev); @@ -196,7 +162,7 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } dev = (int)simple_strtoul (argv[2], &ep, 16); - dev_desc=get_dev(argv[1],dev); + dev_desc = get_dev(argv[1],dev); if (dev_desc==NULL) { printf ("\n** Block device %s %d not supported\n", argv[1], dev); return 1; diff --git a/common/cmd_scsi.c b/common/cmd_scsi.c index cc08743..b17bebb 100644 --- a/common/cmd_scsi.c +++ b/common/cmd_scsi.c @@ -194,7 +194,7 @@ void scsi_init(void) block_dev_desc_t * scsi_get_dev(int dev) { - return((block_dev_desc_t *)&scsi_dev_desc[dev]); + return (dev < CFG_SCSI_MAX_DEVICE) ? &scsi_dev_desc[dev] : NULL; } diff --git a/common/cmd_usb.c b/common/cmd_usb.c index 28c05aa..904df71 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -28,6 +28,7 @@ #include <common.h> #include <command.h> #include <asm/byteorder.h> +#include <part.h> #if (CONFIG_COMMANDS & CFG_CMD_USB) diff --git a/common/usb_storage.c b/common/usb_storage.c index 06ea99b..b4b7914 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -56,6 +56,7 @@ #if (CONFIG_COMMANDS & CFG_CMD_USB) +#include <part.h> #include <usb.h> #ifdef CONFIG_USB_STORAGE @@ -174,7 +175,7 @@ void uhci_show_temp_int_td(void); block_dev_desc_t *usb_stor_get_dev(int index) { - return &usb_dev_desc[index]; + return (index < USB_MAX_STOR_DEV) ? &usb_dev_desc[index] : NULL; } |