efi_loader: efi_disk: use efi_add_protocol
Use efi_add_protocol to install protocols. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
committed by
Alexander Graf
parent
bf19064bdc
commit
4b9f7aaf7c
@@ -213,33 +213,40 @@ static void efi_disk_add_dev(const char *name,
|
|||||||
unsigned int part)
|
unsigned int part)
|
||||||
{
|
{
|
||||||
struct efi_disk_obj *diskobj;
|
struct efi_disk_obj *diskobj;
|
||||||
|
efi_status_t ret;
|
||||||
|
|
||||||
/* Don't add empty devices */
|
/* Don't add empty devices */
|
||||||
if (!desc->lba)
|
if (!desc->lba)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
diskobj = calloc(1, sizeof(*diskobj));
|
diskobj = calloc(1, sizeof(*diskobj));
|
||||||
if (!diskobj) {
|
if (!diskobj)
|
||||||
printf("ERROR: Out of memory\n");
|
goto out_of_memory;
|
||||||
return;
|
|
||||||
}
|
/* Hook up to the device list */
|
||||||
|
list_add_tail(&diskobj->parent.link, &efi_obj_list);
|
||||||
|
|
||||||
/* Fill in object data */
|
/* Fill in object data */
|
||||||
diskobj->dp = efi_dp_from_part(desc, part);
|
diskobj->dp = efi_dp_from_part(desc, part);
|
||||||
diskobj->part = part;
|
diskobj->part = part;
|
||||||
diskobj->parent.protocols[0].guid = &efi_block_io_guid;
|
diskobj->parent.handle = diskobj;
|
||||||
diskobj->parent.protocols[0].protocol_interface = &diskobj->ops;
|
ret = efi_add_protocol(diskobj->parent.handle, &efi_block_io_guid,
|
||||||
diskobj->parent.protocols[1].guid = &efi_guid_device_path;
|
&diskobj->ops);
|
||||||
diskobj->parent.protocols[1].protocol_interface = diskobj->dp;
|
if (ret != EFI_SUCCESS)
|
||||||
|
goto out_of_memory;
|
||||||
|
ret = efi_add_protocol(diskobj->parent.handle, &efi_guid_device_path,
|
||||||
|
diskobj->dp);
|
||||||
|
if (ret != EFI_SUCCESS)
|
||||||
|
goto out_of_memory;
|
||||||
if (part >= 1) {
|
if (part >= 1) {
|
||||||
diskobj->volume = efi_simple_file_system(desc, part,
|
diskobj->volume = efi_simple_file_system(desc, part,
|
||||||
diskobj->dp);
|
diskobj->dp);
|
||||||
diskobj->parent.protocols[2].guid =
|
ret = efi_add_protocol(diskobj->parent.handle,
|
||||||
&efi_simple_file_system_protocol_guid;
|
&efi_simple_file_system_protocol_guid,
|
||||||
diskobj->parent.protocols[2].protocol_interface =
|
&diskobj->volume);
|
||||||
diskobj->volume;
|
if (ret != EFI_SUCCESS)
|
||||||
|
goto out_of_memory;
|
||||||
}
|
}
|
||||||
diskobj->parent.handle = diskobj;
|
|
||||||
diskobj->ops = block_io_disk_template;
|
diskobj->ops = block_io_disk_template;
|
||||||
diskobj->ifname = if_typename;
|
diskobj->ifname = if_typename;
|
||||||
diskobj->dev_index = dev_index;
|
diskobj->dev_index = dev_index;
|
||||||
@@ -253,9 +260,9 @@ static void efi_disk_add_dev(const char *name,
|
|||||||
diskobj->media.io_align = desc->blksz;
|
diskobj->media.io_align = desc->blksz;
|
||||||
diskobj->media.last_block = desc->lba - offset;
|
diskobj->media.last_block = desc->lba - offset;
|
||||||
diskobj->ops.media = &diskobj->media;
|
diskobj->ops.media = &diskobj->media;
|
||||||
|
return;
|
||||||
/* Hook up to the device list */
|
out_of_memory:
|
||||||
list_add_tail(&diskobj->parent.link, &efi_obj_list);
|
printf("ERROR: Out of memory\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int efi_disk_create_eltorito(struct blk_desc *desc,
|
static int efi_disk_create_eltorito(struct blk_desc *desc,
|
||||||
|
|||||||
Reference in New Issue
Block a user