mirror of
https://xff.cz/git/u-boot/
synced 2025-09-03 17:52:07 +02:00
dm: part: Drop the block_drvr table
This is not needed since we can use the functions provided by the legacy block device support. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
67
disk/part.c
67
disk/part.c
@@ -21,34 +21,6 @@
|
|||||||
#define PRINTF(fmt,args...)
|
#define PRINTF(fmt,args...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const struct block_drvr block_drvr[] = {
|
|
||||||
#if defined(CONFIG_CMD_IDE)
|
|
||||||
{ .name = "ide", },
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_CMD_SATA)
|
|
||||||
{.name = "sata", },
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_SCSI)
|
|
||||||
{ .name = "scsi", },
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_CMD_USB) && defined(CONFIG_USB_STORAGE)
|
|
||||||
{ .name = "usb", },
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_MMC)
|
|
||||||
{
|
|
||||||
.name = "mmc",
|
|
||||||
.select_hwpart = mmc_select_hwpart,
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_SYSTEMACE)
|
|
||||||
{ .name = "ace", },
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_SANDBOX)
|
|
||||||
{ .name = "host", },
|
|
||||||
#endif
|
|
||||||
{ },
|
|
||||||
};
|
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
#ifdef HAVE_BLOCK_DEVICE
|
#ifdef HAVE_BLOCK_DEVICE
|
||||||
@@ -70,34 +42,23 @@ static struct part_driver *part_driver_lookup_type(int part_type)
|
|||||||
|
|
||||||
static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
|
static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
|
||||||
{
|
{
|
||||||
const struct block_drvr *drvr = block_drvr;
|
struct blk_desc *dev_desc;
|
||||||
char *name;
|
int ret;
|
||||||
|
|
||||||
if (!ifname)
|
dev_desc = blk_get_devnum_by_typename(ifname, dev);
|
||||||
|
if (!dev_desc) {
|
||||||
|
debug("%s: No device for iface '%s', dev %d\n", __func__,
|
||||||
|
ifname, dev);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
name = drvr->name;
|
|
||||||
#ifdef CONFIG_NEEDS_MANUAL_RELOC
|
|
||||||
name += gd->reloc_off;
|
|
||||||
#endif
|
|
||||||
while (drvr->name) {
|
|
||||||
name = drvr->name;
|
|
||||||
#ifdef CONFIG_NEEDS_MANUAL_RELOC
|
|
||||||
name += gd->reloc_off;
|
|
||||||
#endif
|
|
||||||
if (strncmp(ifname, name, strlen(name)) == 0) {
|
|
||||||
struct blk_desc *dev_desc;
|
|
||||||
|
|
||||||
dev_desc = blk_get_devnum_by_typename(name, dev);
|
|
||||||
if (!dev_desc)
|
|
||||||
return NULL;
|
|
||||||
if (blk_dselect_hwpart(dev_desc, hwpart))
|
|
||||||
return NULL;
|
|
||||||
return dev_desc;
|
|
||||||
}
|
|
||||||
drvr++;
|
|
||||||
}
|
}
|
||||||
return NULL;
|
ret = blk_dselect_hwpart(dev_desc, hwpart);
|
||||||
|
if (ret) {
|
||||||
|
debug("%s: Failed to select h/w partition: err-%d\n", __func__,
|
||||||
|
ret);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dev_desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct blk_desc *blk_get_dev(const char *ifname, int dev)
|
struct blk_desc *blk_get_dev(const char *ifname, int dev)
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
#include <blk.h>
|
||||||
#include <efi_loader.h>
|
#include <efi_loader.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <part.h>
|
#include <part.h>
|
||||||
@@ -142,7 +143,7 @@ static const struct efi_block_io block_io_disk_template = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void efi_disk_add_dev(char *name,
|
static void efi_disk_add_dev(char *name,
|
||||||
const struct block_drvr *cur_drvr,
|
const struct blk_driver *cur_drvr,
|
||||||
const struct blk_desc *desc,
|
const struct blk_desc *desc,
|
||||||
int dev_index,
|
int dev_index,
|
||||||
lbaint_t offset)
|
lbaint_t offset)
|
||||||
@@ -160,7 +161,7 @@ static void efi_disk_add_dev(char *name,
|
|||||||
diskobj->parent.protocols[1].open = efi_disk_open_dp;
|
diskobj->parent.protocols[1].open = efi_disk_open_dp;
|
||||||
diskobj->parent.handle = diskobj;
|
diskobj->parent.handle = diskobj;
|
||||||
diskobj->ops = block_io_disk_template;
|
diskobj->ops = block_io_disk_template;
|
||||||
diskobj->ifname = cur_drvr->name;
|
diskobj->ifname = cur_drvr->if_typename;
|
||||||
diskobj->dev_index = dev_index;
|
diskobj->dev_index = dev_index;
|
||||||
diskobj->offset = offset;
|
diskobj->offset = offset;
|
||||||
|
|
||||||
@@ -189,7 +190,7 @@ static void efi_disk_add_dev(char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int efi_disk_create_eltorito(struct blk_desc *desc,
|
static int efi_disk_create_eltorito(struct blk_desc *desc,
|
||||||
const struct block_drvr *cur_drvr,
|
const struct blk_driver *cur_drvr,
|
||||||
int diskid)
|
int diskid)
|
||||||
{
|
{
|
||||||
int disks = 0;
|
int disks = 0;
|
||||||
@@ -202,8 +203,8 @@ static int efi_disk_create_eltorito(struct blk_desc *desc,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
while (!part_get_info(desc, part, &info)) {
|
while (!part_get_info(desc, part, &info)) {
|
||||||
snprintf(devname, sizeof(devname), "%s%d:%d", cur_drvr->name,
|
snprintf(devname, sizeof(devname), "%s%d:%d",
|
||||||
diskid, part);
|
cur_drvr->if_typename, diskid, part);
|
||||||
efi_disk_add_dev(devname, cur_drvr, desc, diskid, info.start);
|
efi_disk_add_dev(devname, cur_drvr, desc, diskid, info.start);
|
||||||
part++;
|
part++;
|
||||||
disks++;
|
disks++;
|
||||||
@@ -222,25 +223,29 @@ static int efi_disk_create_eltorito(struct blk_desc *desc,
|
|||||||
*/
|
*/
|
||||||
int efi_disk_register(void)
|
int efi_disk_register(void)
|
||||||
{
|
{
|
||||||
const struct block_drvr *cur_drvr;
|
const struct blk_driver *cur_drvr;
|
||||||
int i;
|
int i, if_type;
|
||||||
int disks = 0;
|
int disks = 0;
|
||||||
|
|
||||||
/* Search for all available disk devices */
|
/* Search for all available disk devices */
|
||||||
for (cur_drvr = block_drvr; cur_drvr->name; cur_drvr++) {
|
for (if_type = 0; if_type < IF_TYPE_COUNT; if_type++) {
|
||||||
printf("Scanning disks on %s...\n", cur_drvr->name);
|
cur_drvr = blk_driver_lookup_type(if_type);
|
||||||
|
if (!cur_drvr)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
printf("Scanning disks on %s...\n", cur_drvr->if_typename);
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
struct blk_desc *desc;
|
struct blk_desc *desc;
|
||||||
char devname[32] = { 0 }; /* dp->str is u16[32] long */
|
char devname[32] = { 0 }; /* dp->str is u16[32] long */
|
||||||
|
|
||||||
desc = blk_get_dev(cur_drvr->name, i);
|
desc = blk_get_devnum_by_type(if_type, i);
|
||||||
if (!desc)
|
if (!desc)
|
||||||
continue;
|
continue;
|
||||||
if (desc->type == DEV_TYPE_UNKNOWN)
|
if (desc->type == DEV_TYPE_UNKNOWN)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
snprintf(devname, sizeof(devname), "%s%d",
|
snprintf(devname, sizeof(devname), "%s%d",
|
||||||
cur_drvr->name, i);
|
cur_drvr->if_typename, i);
|
||||||
efi_disk_add_dev(devname, cur_drvr, desc, i, 0);
|
efi_disk_add_dev(devname, cur_drvr, desc, i, 0);
|
||||||
disks++;
|
disks++;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user