From: "Cédric Le Goater" <clg@redhat.com>
To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org
Cc: "Halil Pasic" <pasic@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"David Hildenbrand" <david@redhat.com>,
"Ilya Leoshkevich" <iii@linux.ibm.com>,
"Thomas Huth" <thuth@redhat.com>,
"Eric Farman" <farman@linux.ibm.com>,
"Cédric Le Goater" <clg@redhat.com>
Subject: [PATCH 2/3] s390x/event-facility: Simplify sclp_get_event_facility_bus()
Date: Thu, 2 May 2024 15:15:32 +0200 [thread overview]
Message-ID: <20240502131533.377719-3-clg@redhat.com> (raw)
In-Reply-To: <20240502131533.377719-1-clg@redhat.com>
sclp_get_event_facility_bus() scans the whole machine to find a
TYPE_SCLP_EVENTS_BUS object. The SCLPDevice instance is now available
under the machine state, use it to simplify the lookup and adjust the
creation of the consoles.
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
include/hw/s390x/event-facility.h | 2 +-
hw/s390x/event-facility.c | 13 ++-----------
hw/s390x/s390-virtio-ccw.c | 12 +++++++-----
3 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/include/hw/s390x/event-facility.h b/include/hw/s390x/event-facility.h
index 3ffd575d8ff09863e17f96d1bdb56a2ca6c2aa56..ff874e792d32ffa4089bb4cb40ab9eb34c889b0c 100644
--- a/include/hw/s390x/event-facility.h
+++ b/include/hw/s390x/event-facility.h
@@ -203,6 +203,6 @@ struct SCLPEventFacilityClass {
bool (*event_pending)(SCLPEventFacility *ef);
};
-BusState *sclp_get_event_facility_bus(void);
+BusState *sclp_get_event_facility_bus(SCLPEventFacility *ef);
#endif
diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index f9829de9532b65466a65443cecd9609198c5c026..06c1da0ecedcb307c77672097323954c6e7ccaf2 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -523,16 +523,7 @@ static void register_types(void)
type_init(register_types)
-BusState *sclp_get_event_facility_bus(void)
+BusState *sclp_get_event_facility_bus(SCLPEventFacility *ef)
{
- Object *busobj;
- SCLPEventsBus *sbus;
-
- busobj = object_resolve_path_type("", TYPE_SCLP_EVENTS_BUS, NULL);
- sbus = OBJECT_CHECK(SCLPEventsBus, busobj, TYPE_SCLP_EVENTS_BUS);
- if (!sbus) {
- return NULL;
- }
-
- return &sbus->qbus;
+ return BUS(&ef->sbus);
}
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 159f67d05c1e534800427ce46afcdaa526fd5902..2afaf45ce606b2bf7e67dc890339f6c5dd917eca 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -237,13 +237,15 @@ static void s390_create_virtio_net(BusState *bus, const char *name)
}
}
-static void s390_create_sclpconsole(const char *type, Chardev *chardev)
+static void s390_create_sclpconsole(SCLPDevice *sclp,
+ const char *type, Chardev *chardev)
{
- BusState *ev_fac_bus = sclp_get_event_facility_bus();
+ SCLPEventFacility *ef = sclp->event_facility;
+ BusState *ev_fac_bus = sclp_get_event_facility_bus(ef);
DeviceState *dev;
dev = qdev_new(type);
- object_property_add_child(OBJECT(ev_fac_bus->parent), type, OBJECT(dev));
+ object_property_add_child(OBJECT(ef), type, OBJECT(dev));
qdev_prop_set_chr(dev, "chardev", chardev);
qdev_realize_and_unref(dev, ev_fac_bus, &error_fatal);
}
@@ -308,10 +310,10 @@ static void ccw_init(MachineState *machine)
/* init consoles */
if (serial_hd(0)) {
- s390_create_sclpconsole("sclpconsole", serial_hd(0));
+ s390_create_sclpconsole(ms->sclp, "sclpconsole", serial_hd(0));
}
if (serial_hd(1)) {
- s390_create_sclpconsole("sclplmconsole", serial_hd(1));
+ s390_create_sclpconsole(ms->sclp, "sclplmconsole", serial_hd(1));
}
/* init the TOD clock */
--
2.44.0
next prev parent reply other threads:[~2024-05-02 13:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-02 13:15 [PATCH 0/3] s390x: Simplify SCLPDevice usage Cédric Le Goater
2024-05-02 13:15 ` [PATCH 1/3] s390x: Introduce a SCLPDevice pointer under the machine Cédric Le Goater
2024-05-02 17:04 ` Thomas Huth
2024-05-02 13:15 ` Cédric Le Goater [this message]
2024-05-02 17:11 ` [PATCH 2/3] s390x/event-facility: Simplify sclp_get_event_facility_bus() Thomas Huth
2024-05-02 13:15 ` [PATCH 3/3] s390x/sclp: Simplify get_sclp_device() Cédric Le Goater
2024-05-02 17:11 ` Thomas Huth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240502131533.377719-3-clg@redhat.com \
--to=clg@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=david@redhat.com \
--cc=farman@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).