diff mbox series

[3/3] s390x/sclp: Simplify get_sclp_device()

Message ID 20240502131533.377719-4-clg@redhat.com (mailing list archive)
State New, archived
Headers show
Series s390x: Simplify SCLPDevice usage | expand

Commit Message

Cédric Le Goater May 2, 2024, 1:15 p.m. UTC
get_sclp_device() scans the whole machine to find a TYPE_SCLP object.
Now that the SCLPDevice instance is available under the machine state,
use it to simplify the lookup. While at it, remove the inline to let
the compiler decide on how to optimize.

Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
 hw/s390x/sclp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Thomas Huth May 2, 2024, 5:11 p.m. UTC | #1
On 02/05/2024 15.15, Cédric Le Goater wrote:
> get_sclp_device() scans the whole machine to find a TYPE_SCLP object.
> Now that the SCLPDevice instance is available under the machine state,
> use it to simplify the lookup. While at it, remove the inline to let
> the compiler decide on how to optimize.
> 
> Signed-off-by: Cédric Le Goater <clg@redhat.com>
> ---
>   hw/s390x/sclp.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
> index d236dbaf0bdd15c3fc07749a98a5813e05cfb9a1..e725dcd5fdfd159f20307e930a38bed3326c9e0e 100644
> --- a/hw/s390x/sclp.c
> +++ b/hw/s390x/sclp.c
> @@ -21,13 +21,14 @@
>   #include "hw/s390x/s390-pci-bus.h"
>   #include "hw/s390x/ipl.h"
>   #include "hw/s390x/cpu-topology.h"
> +#include "hw/s390x/s390-virtio-ccw.h"
>   
> -static inline SCLPDevice *get_sclp_device(void)
> +static SCLPDevice *get_sclp_device(void)
>   {
>       static SCLPDevice *sclp;
>   
>       if (!sclp) {
> -        sclp = SCLP(object_resolve_path_type("", TYPE_SCLP, NULL));
> +        sclp = S390_CCW_MACHINE(qdev_get_machine())->sclp;
>       }
>       return sclp;
>   }

Reviewed-by: Thomas Huth <thuth@redhat.com>
diff mbox series

Patch

diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index d236dbaf0bdd15c3fc07749a98a5813e05cfb9a1..e725dcd5fdfd159f20307e930a38bed3326c9e0e 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -21,13 +21,14 @@ 
 #include "hw/s390x/s390-pci-bus.h"
 #include "hw/s390x/ipl.h"
 #include "hw/s390x/cpu-topology.h"
+#include "hw/s390x/s390-virtio-ccw.h"
 
-static inline SCLPDevice *get_sclp_device(void)
+static SCLPDevice *get_sclp_device(void)
 {
     static SCLPDevice *sclp;
 
     if (!sclp) {
-        sclp = SCLP(object_resolve_path_type("", TYPE_SCLP, NULL));
+        sclp = S390_CCW_MACHINE(qdev_get_machine())->sclp;
     }
     return sclp;
 }