[PATCH 10/16] efi_driver: efi_net: Add efi_net_unbind_drv method to efi_net driver
Heinrich Schuchardt
xypron.glpk at gmx.de
Tue Apr 15 14:49:32 CEST 2025
On 11.03.25 17:47, Adriano Cordova wrote:
> Signed-off-by: Adriano Cordova <adriano.cordova at canonical.com>
> ---
> lib/efi_driver/efi_net_device.c | 44 +++++++++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/lib/efi_driver/efi_net_device.c b/lib/efi_driver/efi_net_device.c
> index 3838cc47158..bc4edde19b0 100644
> --- a/lib/efi_driver/efi_net_device.c
> +++ b/lib/efi_driver/efi_net_device.c
> @@ -9,6 +9,7 @@
> #include <malloc.h>
> #include <net.h>
> #include <dm/device-internal.h>
> +#include <dm/lists.h>
> #include <dm/root.h>
> #include <dm/tag.h>
> #include <dm/uclass-internal.h>
> @@ -172,6 +173,48 @@ static efi_status_t efi_net_bind_drv(
> return EFI_SUCCESS;
> }
>
> +/**
> + * efi_net_unbind_drv() - TODO
TODO is not a valid description.
> + *
> + * @this: driver binding protocol
> + * @handle: handle
> + * Return: status code
> + */
> +static efi_status_t efi_net_unbind_drv(
> + struct efi_driver_binding_extended_protocol *this,
> + efi_handle_t handle)
> +{
> + EFI_PRINT("%s: handle %p\n", __func__, handle);
> +
> + struct driver *drv;
> + struct udevice *dev;
> + int r;
> +
> + if (!handle || !handle->dev)
> + return EFI_DEVICE_ERROR;
> +
> + drv = lists_driver_lookup_name("efi_netdev");
> + if (!drv) {
> + log_err("Cannot find driver 'efi_netdev'\n");
> + return EFI_DEVICE_ERROR;
> + }
Why do we have to check the driver? How could this unbind function be
invoked with the wrong driver?
Can we move unbind() up to the uclass?
Best regards
Heinrich
> +
> + if (drv == handle->dev->driver) {
> + dev = handle->dev;
> + r = efi_unlink_dev(handle);
> + if (r)
> + return EFI_DEVICE_ERROR;
> + r = device_remove(dev, DM_REMOVE_NORMAL);
> + if (r)
> + return EFI_DEVICE_ERROR;
> + r = device_unbind(dev);
> + if (r)
> + return EFI_DEVICE_ERROR;
> + }
> +
> + return EFI_SUCCESS;
> +}
> +
> /**
> * efi_net_init_drv() - initialize network device driver
> *
> @@ -236,6 +279,7 @@ static const struct efi_driver_ops driver_ops = {
> .protocol = &efi_net_guid,
> .init = efi_net_init_drv,
> .bind = efi_net_bind_drv,
> + .unbind = efi_net_unbind_drv,
> };
>
> /* Identify as EFI driver */
More information about the U-Boot
mailing list