[PATCH 1/1] efi_loader: provide agent_handle to efi_disk_add_dev()
Heinrich Schuchardt
heinrich.schuchardt at canonical.com
Sat Oct 8 09:11:54 CEST 2022
In efi_disk_add_dev() we have to open protocols with BY_DRIVER and
BY_CHILD_CONTROLLER. Provide the handle of the EFI block driver. The actual
usage of the value will follow in a later patch.
Change function descriptions to Sphinx style.
Remove a TODO: tag.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
lib/efi_loader/efi_disk.c | 50 +++++++++++++++++++++++----------------
1 file changed, 29 insertions(+), 21 deletions(-)
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index cef4e45124..0ce448f92d 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -13,6 +13,7 @@
#include <dm/device-internal.h>
#include <dm/tag.h>
#include <event.h>
+#include <efi_driver.h>
#include <efi_loader.h>
#include <fs.h>
#include <log.h>
@@ -382,6 +383,7 @@ static int efi_fs_exists(struct blk_desc *desc, int part)
* @part_info: partition info
* @part: partition
* @disk: pointer to receive the created handle
+ * @agent_handle: handle of the EFI block driver
* Return: disk object
*/
static efi_status_t efi_disk_add_dev(
@@ -391,7 +393,8 @@ static efi_status_t efi_disk_add_dev(
int dev_index,
struct disk_partition *part_info,
unsigned int part,
- struct efi_disk_obj **disk)
+ struct efi_disk_obj **disk,
+ efi_handle_t agent_handle)
{
struct efi_disk_obj *diskobj;
struct efi_object *handle;
@@ -525,17 +528,18 @@ error:
return ret;
}
-/*
- * Create a handle for a whole raw disk
+/**
+ * efi_disk_create_raw() - create a handle for a whole raw disk
*
- * @dev uclass device (UCLASS_BLK)
+ * @dev: udevice (UCLASS_BLK)
+ * @agent_handle: handle of the EFI block driver
*
* Create an efi_disk object which is associated with @dev.
* The type of @dev must be UCLASS_BLK.
*
- * @return 0 on success, -1 otherwise
+ * Return: 0 on success, -1 otherwise
*/
-static int efi_disk_create_raw(struct udevice *dev)
+static int efi_disk_create_raw(struct udevice *dev, efi_handle_t agent_handle)
{
struct efi_disk_obj *disk;
struct blk_desc *desc;
@@ -546,7 +550,7 @@ static int efi_disk_create_raw(struct udevice *dev)
diskid = desc->devnum;
ret = efi_disk_add_dev(NULL, NULL, desc,
- diskid, NULL, 0, &disk);
+ diskid, NULL, 0, &disk, agent_handle);
if (ret != EFI_SUCCESS) {
if (ret == EFI_NOT_READY)
log_notice("Disk %s not ready\n", dev->name);
@@ -565,17 +569,18 @@ static int efi_disk_create_raw(struct udevice *dev)
return 0;
}
-/*
- * Create a handle for a disk partition
+/**
+ * efi_disk_create_part() - create a handle for a disk partition
*
- * @dev uclass device (UCLASS_PARTITION)
+ * @dev: udevice (UCLASS_PARTITION)
+ * @agent_handle: handle of the EFI block driver
*
* Create an efi_disk object which is associated with @dev.
* The type of @dev must be UCLASS_PARTITION.
*
- * @return 0 on success, -1 otherwise
+ * Return: 0 on success, -1 otherwise
*/
-static int efi_disk_create_part(struct udevice *dev)
+static int efi_disk_create_part(struct udevice *dev, efi_handle_t agent_handle)
{
efi_handle_t parent;
struct blk_desc *desc;
@@ -604,7 +609,7 @@ static int efi_disk_create_part(struct udevice *dev)
dp_parent = (struct efi_device_path *)handler->protocol_interface;
ret = efi_disk_add_dev(parent, dp_parent, desc, diskid,
- info, part, &disk);
+ info, part, &disk, agent_handle);
if (ret != EFI_SUCCESS) {
log_err("Adding partition for %s failed\n", dev->name);
return -1;
@@ -619,17 +624,18 @@ static int efi_disk_create_part(struct udevice *dev)
return 0;
}
-/*
- * Create efi_disk objects for a block device
+/**
+ * efi_disk_probe() - create efi_disk objects for a block device
*
- * @dev uclass device (UCLASS_BLK)
+ * @ctx: event context - driver binding protocol
+ * @event: EV_PM_POST_PROBE event
*
* Create efi_disk objects for partitions as well as a raw disk
* which is associated with @dev.
* The type of @dev must be UCLASS_BLK.
* This function is expected to be called at EV_PM_POST_PROBE.
*
- * @return 0 on success, -1 otherwise
+ * Return: 0 on success, -1 otherwise
*/
int efi_disk_probe(void *ctx, struct event *event)
{
@@ -637,28 +643,30 @@ int efi_disk_probe(void *ctx, struct event *event)
enum uclass_id id;
struct blk_desc *desc;
struct udevice *child;
+ struct efi_driver_binding_extended_protocol *db_prot = ctx;
+ efi_handle_t agent_handle = db_prot->bp.driver_binding_handle;
int ret;
dev = event->data.dm.dev;
id = device_get_uclass_id(dev);
- /* TODO: We won't support partitions in a partition */
+ /* We won't support partitions in a partition */
if (id != UCLASS_BLK)
return 0;
/*
- * avoid creating duplicated objects now that efi_driver
+ * Avoid creating duplicated objects now that efi_driver
* has already created an efi_disk at this moment.
*/
desc = dev_get_uclass_plat(dev);
if (desc->uclass_id != UCLASS_EFI_LOADER) {
- ret = efi_disk_create_raw(dev);
+ ret = efi_disk_create_raw(dev, agent_handle);
if (ret)
return -1;
}
device_foreach_child(child, dev) {
- ret = efi_disk_create_part(child);
+ ret = efi_disk_create_part(child, agent_handle);
if (ret)
return -1;
}
--
2.37.2
More information about the U-Boot
mailing list