[edk2-devel] [PATCH 2/5] ArmVirt/PlatformBootManagerLib: factor out IsVirtio()

Gerd Hoffmann posted 5 patches 1 year, 5 months ago
There is a newer version of this series
[edk2-devel] [PATCH 2/5] ArmVirt/PlatformBootManagerLib: factor out IsVirtio()
Posted by Gerd Hoffmann 1 year, 5 months ago
IsVirtioRng() becomes just a thin wrapper for IsVirtio().
This allows to add similar thin wrappers for other virtio
devices in the future.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 .../PlatformBootManagerLib/PlatformBm.c       | 26 +++++++++++++++----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
index 10c815378cd5..5eb6f0f9c14a 100644
--- a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
+++ b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
@@ -269,15 +269,16 @@ IsPciDisplay (
 }
 
 /**
-  This FILTER_FUNCTION checks if a handle corresponds to a Virtio RNG device at
-  the VIRTIO_DEVICE_PROTOCOL level.
+  This function checks if a handle corresponds to the Virtio Device ID given
+  at the VIRTIO_DEVICE_PROTOCOL level.
 **/
 STATIC
 BOOLEAN
 EFIAPI
-IsVirtioRng (
+IsVirtio (
   IN EFI_HANDLE    Handle,
-  IN CONST CHAR16  *ReportText
+  IN CONST CHAR16  *ReportText,
+  IN UINT16        VirtIoDeviceId
   )
 {
   EFI_STATUS              Status;
@@ -293,7 +294,22 @@ IsVirtioRng (
   }
 
   return (BOOLEAN)(VirtIo->SubSystemDeviceId ==
-                   VIRTIO_SUBSYSTEM_ENTROPY_SOURCE);
+                   VirtIoDeviceId);
+}
+
+/**
+  This FILTER_FUNCTION checks if a handle corresponds to a Virtio RNG device at
+  the VIRTIO_DEVICE_PROTOCOL level.
+**/
+STATIC
+BOOLEAN
+EFIAPI
+IsVirtioRng (
+  IN EFI_HANDLE    Handle,
+  IN CONST CHAR16  *ReportText
+  )
+{
+  return IsVirtio (Handle, ReportText, VIRTIO_SUBSYSTEM_ENTROPY_SOURCE);
 }
 
 /**
-- 
2.40.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104801): https://edk2.groups.io/g/devel/message/104801
Mute This Topic: https://groups.io/mt/98850080/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH 2/5] ArmVirt/PlatformBootManagerLib: factor out IsVirtio()
Posted by Ard Biesheuvel 1 year, 5 months ago
On Fri, 12 May 2023 at 16:23, Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> IsVirtioRng() becomes just a thin wrapper for IsVirtio().
> This allows to add similar thin wrappers for other virtio
> devices in the future.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Reviewed-by: Ard Biesheuvel <ardb@kernel.org>

> ---
>  .../PlatformBootManagerLib/PlatformBm.c       | 26 +++++++++++++++----
>  1 file changed, 21 insertions(+), 5 deletions(-)
>
> diff --git a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
> index 10c815378cd5..5eb6f0f9c14a 100644
> --- a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
> +++ b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
> @@ -269,15 +269,16 @@ IsPciDisplay (
>  }
>
>  /**
> -  This FILTER_FUNCTION checks if a handle corresponds to a Virtio RNG device at
> -  the VIRTIO_DEVICE_PROTOCOL level.
> +  This function checks if a handle corresponds to the Virtio Device ID given
> +  at the VIRTIO_DEVICE_PROTOCOL level.
>  **/
>  STATIC
>  BOOLEAN
>  EFIAPI
> -IsVirtioRng (
> +IsVirtio (
>    IN EFI_HANDLE    Handle,
> -  IN CONST CHAR16  *ReportText
> +  IN CONST CHAR16  *ReportText,
> +  IN UINT16        VirtIoDeviceId
>    )
>  {
>    EFI_STATUS              Status;
> @@ -293,7 +294,22 @@ IsVirtioRng (
>    }
>
>    return (BOOLEAN)(VirtIo->SubSystemDeviceId ==
> -                   VIRTIO_SUBSYSTEM_ENTROPY_SOURCE);
> +                   VirtIoDeviceId);
> +}
> +
> +/**
> +  This FILTER_FUNCTION checks if a handle corresponds to a Virtio RNG device at
> +  the VIRTIO_DEVICE_PROTOCOL level.
> +**/
> +STATIC
> +BOOLEAN
> +EFIAPI
> +IsVirtioRng (
> +  IN EFI_HANDLE    Handle,
> +  IN CONST CHAR16  *ReportText
> +  )
> +{
> +  return IsVirtio (Handle, ReportText, VIRTIO_SUBSYSTEM_ENTROPY_SOURCE);
>  }
>
>  /**
> --
> 2.40.1
>



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105533): https://edk2.groups.io/g/devel/message/105533
Mute This Topic: https://groups.io/mt/98850080/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-