From nobody Sun Feb 8 06:21:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1556222596; cv=none; d=zoho.com; s=zohoarc; b=c9+9qlESkc5z2++4LbG5d20WjcvT3I9Nzc8CBkfDuWUzeXX8CM6M1eBH/xM1pK5DOBZoryVvghjtOa4EX80B/CdENcIBNBkDs9NP7wnItuI9CTn56JAJuEVqsa+NnHRnUsz499pFSaM/2J0YLa4I8TgM+1w/8jMyYYYGCYLqX1k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556222596; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=EEAlygXGrj6KT1sqgKFoDwSQc9ijusET68b/9nyVpS4=; b=QcMY05fErTw+NdTVWUMraEIzoXAuHIcMajotvcgsbepUumafjvgls+kOo/riKNDEPE5lCcYbV21RVl0DJGfuEeA1N80gdiI0dwaX/k54J2xsjdED1SHYoak1iSS3YUzqtKaiwyFwMG5NyaZ9T6ZpaNSbf+h7nyrFPCeLC2iPU9s= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1556222596650729.8860368513915; Thu, 25 Apr 2019 13:03:16 -0700 (PDT) Received: from localhost ([127.0.0.1]:34456 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJkaL-00071g-NN for importer@patchew.org; Thu, 25 Apr 2019 16:03:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJkYU-0005l6-2V for qemu-devel@nongnu.org; Thu, 25 Apr 2019 16:01:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJkYP-0007Es-5R for qemu-devel@nongnu.org; Thu, 25 Apr 2019 16:01:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43694) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hJkYM-0005pa-Pl for qemu-devel@nongnu.org; Thu, 25 Apr 2019 16:01:09 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D90F830832C2; Thu, 25 Apr 2019 20:00:55 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22E555D705; Thu, 25 Apr 2019 20:00:54 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Thu, 25 Apr 2019 17:00:48 -0300 Message-Id: <20190425200051.19906-2-ehabkost@redhat.com> In-Reply-To: <20190425200051.19906-1-ehabkost@redhat.com> References: <20190425200051.19906-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 25 Apr 2019 20:00:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/4] machine: Move gpio code to hw/core/gpio.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Markus Armbruster , Like Xu , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Only softmmu code uses gpio, so move gpio code from qdev.c to gpio.c and compile it only on softmmu mode. Signed-off-by: Eduardo Habkost Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/gpio.c | 206 ++++++++++++++++++++++++++++++++++++++++++ hw/core/qdev.c | 184 ------------------------------------- hw/core/Makefile.objs | 1 + 3 files changed, 207 insertions(+), 184 deletions(-) create mode 100644 hw/core/gpio.c diff --git a/hw/core/gpio.c b/hw/core/gpio.c new file mode 100644 index 0000000000..2724b4d7e7 --- /dev/null +++ b/hw/core/gpio.c @@ -0,0 +1,206 @@ +/* + * qdev GPIO helpers + * + * Copyright (c) 2009 CodeSourcery + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#include "qemu/osdep.h" +#include "hw/qdev.h" +#include "qapi/error.h" + +static NamedGPIOList *qdev_get_named_gpio_list(DeviceState *dev, + const char *name) +{ + NamedGPIOList *ngl; + + QLIST_FOREACH(ngl, &dev->gpios, node) { + /* NULL is a valid and matchable name, otherwise do a normal + * strcmp match. + */ + if ((!ngl->name && !name) || + (name && ngl->name && strcmp(name, ngl->name) =3D=3D 0)) { + return ngl; + } + } + + ngl =3D g_malloc0(sizeof(*ngl)); + ngl->name =3D g_strdup(name); + QLIST_INSERT_HEAD(&dev->gpios, ngl, node); + return ngl; +} + +void qdev_init_gpio_in_named_with_opaque(DeviceState *dev, + qemu_irq_handler handler, + void *opaque, + const char *name, int n) +{ + int i; + NamedGPIOList *gpio_list =3D qdev_get_named_gpio_list(dev, name); + + assert(gpio_list->num_out =3D=3D 0 || !name); + gpio_list->in =3D qemu_extend_irqs(gpio_list->in, gpio_list->num_in, h= andler, + opaque, n); + + if (!name) { + name =3D "unnamed-gpio-in"; + } + for (i =3D gpio_list->num_in; i < gpio_list->num_in + n; i++) { + gchar *propname =3D g_strdup_printf("%s[%u]", name, i); + + object_property_add_child(OBJECT(dev), propname, + OBJECT(gpio_list->in[i]), &error_abort); + g_free(propname); + } + + gpio_list->num_in +=3D n; +} + +void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n) +{ + qdev_init_gpio_in_named(dev, handler, NULL, n); +} + +void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq *pins, + const char *name, int n) +{ + int i; + NamedGPIOList *gpio_list =3D qdev_get_named_gpio_list(dev, name); + + assert(gpio_list->num_in =3D=3D 0 || !name); + + if (!name) { + name =3D "unnamed-gpio-out"; + } + memset(pins, 0, sizeof(*pins) * n); + for (i =3D 0; i < n; ++i) { + gchar *propname =3D g_strdup_printf("%s[%u]", name, + gpio_list->num_out + i); + + object_property_add_link(OBJECT(dev), propname, TYPE_IRQ, + (Object **)&pins[i], + object_property_allow_set_link, + OBJ_PROP_LINK_STRONG, + &error_abort); + g_free(propname); + } + gpio_list->num_out +=3D n; +} + +void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n) +{ + qdev_init_gpio_out_named(dev, pins, NULL, n); +} + +qemu_irq qdev_get_gpio_in_named(DeviceState *dev, const char *name, int n) +{ + NamedGPIOList *gpio_list =3D qdev_get_named_gpio_list(dev, name); + + assert(n >=3D 0 && n < gpio_list->num_in); + return gpio_list->in[n]; +} + +qemu_irq qdev_get_gpio_in(DeviceState *dev, int n) +{ + return qdev_get_gpio_in_named(dev, NULL, n); +} + +void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n, + qemu_irq pin) +{ + char *propname =3D g_strdup_printf("%s[%d]", + name ? name : "unnamed-gpio-out", n); + if (pin) { + /* We need a name for object_property_set_link to work. If the + * object has a parent, object_property_add_child will come back + * with an error without doing anything. If it has none, it will + * never fail. So we can just call it with a NULL Error pointer. + */ + object_property_add_child(container_get(qdev_get_machine(), + "/unattached"), + "non-qdev-gpio[*]", OBJECT(pin), NULL); + } + object_property_set_link(OBJECT(dev), OBJECT(pin), propname, &error_ab= ort); + g_free(propname); +} + +qemu_irq qdev_get_gpio_out_connector(DeviceState *dev, const char *name, i= nt n) +{ + char *propname =3D g_strdup_printf("%s[%d]", + name ? name : "unnamed-gpio-out", n); + + qemu_irq ret =3D (qemu_irq)object_property_get_link(OBJECT(dev), propn= ame, + NULL); + + return ret; +} + +/* disconnect a GPIO output, returning the disconnected input (if any) */ + +static qemu_irq qdev_disconnect_gpio_out_named(DeviceState *dev, + const char *name, int n) +{ + char *propname =3D g_strdup_printf("%s[%d]", + name ? name : "unnamed-gpio-out", n); + + qemu_irq ret =3D (qemu_irq)object_property_get_link(OBJECT(dev), propn= ame, + NULL); + if (ret) { + object_property_set_link(OBJECT(dev), NULL, propname, NULL); + } + g_free(propname); + return ret; +} + +qemu_irq qdev_intercept_gpio_out(DeviceState *dev, qemu_irq icpt, + const char *name, int n) +{ + qemu_irq disconnected =3D qdev_disconnect_gpio_out_named(dev, name, n); + qdev_connect_gpio_out_named(dev, name, n, icpt); + return disconnected; +} + +void qdev_connect_gpio_out(DeviceState * dev, int n, qemu_irq pin) +{ + qdev_connect_gpio_out_named(dev, NULL, n, pin); +} + +void qdev_pass_gpios(DeviceState *dev, DeviceState *container, + const char *name) +{ + int i; + NamedGPIOList *ngl =3D qdev_get_named_gpio_list(dev, name); + + for (i =3D 0; i < ngl->num_in; i++) { + const char *nm =3D ngl->name ? ngl->name : "unnamed-gpio-in"; + char *propname =3D g_strdup_printf("%s[%d]", nm, i); + + object_property_add_alias(OBJECT(container), propname, + OBJECT(dev), propname, + &error_abort); + g_free(propname); + } + for (i =3D 0; i < ngl->num_out; i++) { + const char *nm =3D ngl->name ? ngl->name : "unnamed-gpio-out"; + char *propname =3D g_strdup_printf("%s[%d]", nm, i); + + object_property_add_alias(OBJECT(container), propname, + OBJECT(dev), propname, + &error_abort); + g_free(propname); + } + QLIST_REMOVE(ngl, node); + QLIST_INSERT_HEAD(&container->gpios, ngl, node); +} diff --git a/hw/core/qdev.c b/hw/core/qdev.c index f9b6efe509..f73e7ded1a 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -346,190 +346,6 @@ BusState *qdev_get_parent_bus(DeviceState *dev) return dev->parent_bus; } =20 -static NamedGPIOList *qdev_get_named_gpio_list(DeviceState *dev, - const char *name) -{ - NamedGPIOList *ngl; - - QLIST_FOREACH(ngl, &dev->gpios, node) { - /* NULL is a valid and matchable name, otherwise do a normal - * strcmp match. - */ - if ((!ngl->name && !name) || - (name && ngl->name && strcmp(name, ngl->name) =3D=3D 0)) { - return ngl; - } - } - - ngl =3D g_malloc0(sizeof(*ngl)); - ngl->name =3D g_strdup(name); - QLIST_INSERT_HEAD(&dev->gpios, ngl, node); - return ngl; -} - -void qdev_init_gpio_in_named_with_opaque(DeviceState *dev, - qemu_irq_handler handler, - void *opaque, - const char *name, int n) -{ - int i; - NamedGPIOList *gpio_list =3D qdev_get_named_gpio_list(dev, name); - - assert(gpio_list->num_out =3D=3D 0 || !name); - gpio_list->in =3D qemu_extend_irqs(gpio_list->in, gpio_list->num_in, h= andler, - opaque, n); - - if (!name) { - name =3D "unnamed-gpio-in"; - } - for (i =3D gpio_list->num_in; i < gpio_list->num_in + n; i++) { - gchar *propname =3D g_strdup_printf("%s[%u]", name, i); - - object_property_add_child(OBJECT(dev), propname, - OBJECT(gpio_list->in[i]), &error_abort); - g_free(propname); - } - - gpio_list->num_in +=3D n; -} - -void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n) -{ - qdev_init_gpio_in_named(dev, handler, NULL, n); -} - -void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq *pins, - const char *name, int n) -{ - int i; - NamedGPIOList *gpio_list =3D qdev_get_named_gpio_list(dev, name); - - assert(gpio_list->num_in =3D=3D 0 || !name); - - if (!name) { - name =3D "unnamed-gpio-out"; - } - memset(pins, 0, sizeof(*pins) * n); - for (i =3D 0; i < n; ++i) { - gchar *propname =3D g_strdup_printf("%s[%u]", name, - gpio_list->num_out + i); - - object_property_add_link(OBJECT(dev), propname, TYPE_IRQ, - (Object **)&pins[i], - object_property_allow_set_link, - OBJ_PROP_LINK_STRONG, - &error_abort); - g_free(propname); - } - gpio_list->num_out +=3D n; -} - -void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n) -{ - qdev_init_gpio_out_named(dev, pins, NULL, n); -} - -qemu_irq qdev_get_gpio_in_named(DeviceState *dev, const char *name, int n) -{ - NamedGPIOList *gpio_list =3D qdev_get_named_gpio_list(dev, name); - - assert(n >=3D 0 && n < gpio_list->num_in); - return gpio_list->in[n]; -} - -qemu_irq qdev_get_gpio_in(DeviceState *dev, int n) -{ - return qdev_get_gpio_in_named(dev, NULL, n); -} - -void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n, - qemu_irq pin) -{ - char *propname =3D g_strdup_printf("%s[%d]", - name ? name : "unnamed-gpio-out", n); - if (pin) { - /* We need a name for object_property_set_link to work. If the - * object has a parent, object_property_add_child will come back - * with an error without doing anything. If it has none, it will - * never fail. So we can just call it with a NULL Error pointer. - */ - object_property_add_child(container_get(qdev_get_machine(), - "/unattached"), - "non-qdev-gpio[*]", OBJECT(pin), NULL); - } - object_property_set_link(OBJECT(dev), OBJECT(pin), propname, &error_ab= ort); - g_free(propname); -} - -qemu_irq qdev_get_gpio_out_connector(DeviceState *dev, const char *name, i= nt n) -{ - char *propname =3D g_strdup_printf("%s[%d]", - name ? name : "unnamed-gpio-out", n); - - qemu_irq ret =3D (qemu_irq)object_property_get_link(OBJECT(dev), propn= ame, - NULL); - - return ret; -} - -/* disconnect a GPIO output, returning the disconnected input (if any) */ - -static qemu_irq qdev_disconnect_gpio_out_named(DeviceState *dev, - const char *name, int n) -{ - char *propname =3D g_strdup_printf("%s[%d]", - name ? name : "unnamed-gpio-out", n); - - qemu_irq ret =3D (qemu_irq)object_property_get_link(OBJECT(dev), propn= ame, - NULL); - if (ret) { - object_property_set_link(OBJECT(dev), NULL, propname, NULL); - } - g_free(propname); - return ret; -} - -qemu_irq qdev_intercept_gpio_out(DeviceState *dev, qemu_irq icpt, - const char *name, int n) -{ - qemu_irq disconnected =3D qdev_disconnect_gpio_out_named(dev, name, n); - qdev_connect_gpio_out_named(dev, name, n, icpt); - return disconnected; -} - -void qdev_connect_gpio_out(DeviceState * dev, int n, qemu_irq pin) -{ - qdev_connect_gpio_out_named(dev, NULL, n, pin); -} - -void qdev_pass_gpios(DeviceState *dev, DeviceState *container, - const char *name) -{ - int i; - NamedGPIOList *ngl =3D qdev_get_named_gpio_list(dev, name); - - for (i =3D 0; i < ngl->num_in; i++) { - const char *nm =3D ngl->name ? ngl->name : "unnamed-gpio-in"; - char *propname =3D g_strdup_printf("%s[%d]", nm, i); - - object_property_add_alias(OBJECT(container), propname, - OBJECT(dev), propname, - &error_abort); - g_free(propname); - } - for (i =3D 0; i < ngl->num_out; i++) { - const char *nm =3D ngl->name ? ngl->name : "unnamed-gpio-out"; - char *propname =3D g_strdup_printf("%s[%d]", nm, i); - - object_property_add_alias(OBJECT(container), propname, - OBJECT(dev), propname, - &error_abort); - g_free(propname); - } - QLIST_REMOVE(ngl, node); - QLIST_INSERT_HEAD(&container->gpios, ngl, node); -} - BusState *qdev_get_child_bus(DeviceState *dev, const char *name) { BusState *bus; diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs index a799c83815..6789154807 100644 --- a/hw/core/Makefile.objs +++ b/hw/core/Makefile.objs @@ -13,6 +13,7 @@ common-obj-$(CONFIG_XILINX_AXI) +=3D stream.o common-obj-$(CONFIG_PTIMER) +=3D ptimer.o common-obj-$(CONFIG_SOFTMMU) +=3D sysbus.o common-obj-$(CONFIG_SOFTMMU) +=3D machine.o +common-obj-$(CONFIG_SOFTMMU) +=3D gpio.o common-obj-$(CONFIG_SOFTMMU) +=3D loader.o common-obj-$(CONFIG_FITLOADER) +=3D loader-fit.o common-obj-$(CONFIG_SOFTMMU) +=3D qdev-properties-system.o --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Sun Feb 8 06:21:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1556222700; cv=none; d=zoho.com; s=zohoarc; b=fJITFEmf0vN2t1v5Ep6NVy86RxBmCozbSR9C7iEqafJLY9UkaVdeDDl7BG+pIMGRyHF5xWc8s8V6B2HNowztAD6E5boPUsUdtWMe6G++t/d0Fw5324kYO52TxhUP/VjRLrcd6F8kBGTTBg/YQ582HeHpzv+gMitl7mtyKmY8XXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556222700; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Oyp9GmK8XudszZlubARYnYShpqk8evuQ2UkJVvONo1Y=; b=EbCEUdwJVNARamxai35AhiCdRg/QYGoyfeudk91f148xtVVHOJoSo2YIeoNd02TpX3kZxR470YZa9a6DdteO2WWsB1KMT12IcgBDGsN2CSkBqFRNqkm0L502+Hk3pPrsxO/g3oPBWowxUNTA73xoBDdmNIxiPxuATzt2oV1lkig= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1556222700894564.6083456461571; Thu, 25 Apr 2019 13:05:00 -0700 (PDT) Received: from localhost ([127.0.0.1]:34470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJkbz-0000Dm-6u for importer@patchew.org; Thu, 25 Apr 2019 16:04:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJkYW-0005lD-GF for qemu-devel@nongnu.org; Thu, 25 Apr 2019 16:01:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJkYQ-0007Pd-RU for qemu-devel@nongnu.org; Thu, 25 Apr 2019 16:01:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53208) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hJkYQ-00062f-A3 for qemu-devel@nongnu.org; Thu, 25 Apr 2019 16:01:10 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1F1DD30882A5; Thu, 25 Apr 2019 20:00:58 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56EF91A267; Thu, 25 Apr 2019 20:00:57 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Thu, 25 Apr 2019 17:00:49 -0300 Message-Id: <20190425200051.19906-3-ehabkost@redhat.com> In-Reply-To: <20190425200051.19906-1-ehabkost@redhat.com> References: <20190425200051.19906-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 25 Apr 2019 20:00:58 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/4] move qdev hotplug code to qdev-hotplug.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Markus Armbruster , Like Xu , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The qdev hotplug code is used only in softmmu mode, so move it to a separate file so we can eventually avoid compiling it in user-only mode. Signed-off-by: Eduardo Habkost --- hw/core/bus.c | 11 ------- hw/core/qdev-hotplug.c | 69 ++++++++++++++++++++++++++++++++++++++++++ hw/core/qdev.c | 35 --------------------- hw/core/Makefile.objs | 2 +- 4 files changed, 70 insertions(+), 47 deletions(-) create mode 100644 hw/core/qdev-hotplug.c diff --git a/hw/core/bus.c b/hw/core/bus.c index e09843f6ab..35e042416c 100644 --- a/hw/core/bus.c +++ b/hw/core/bus.c @@ -22,17 +22,6 @@ #include "hw/qdev.h" #include "qapi/error.h" =20 -void qbus_set_hotplug_handler(BusState *bus, Object *handler, Error **errp) -{ - object_property_set_link(OBJECT(bus), OBJECT(handler), - QDEV_HOTPLUG_HANDLER_PROPERTY, errp); -} - -void qbus_set_bus_hotplug_handler(BusState *bus, Error **errp) -{ - qbus_set_hotplug_handler(bus, OBJECT(bus), errp); -} - int qbus_walk_children(BusState *bus, qdev_walkerfn *pre_devfn, qbus_walkerfn *pre_busfn, qdev_walkerfn *post_devfn, qbus_walkerfn *post_busf= n, diff --git a/hw/core/qdev-hotplug.c b/hw/core/qdev-hotplug.c new file mode 100644 index 0000000000..8ab31043a7 --- /dev/null +++ b/hw/core/qdev-hotplug.c @@ -0,0 +1,69 @@ +/* + * qdev and qbus hotplug helpers + * + * Copyright (c) 2009 CodeSourcery + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#include "qemu/osdep.h" +#include "hw/qdev.h" +#include "sysemu/sysemu.h" +#include "hw/boards.h" + +void qbus_set_hotplug_handler(BusState *bus, Object *handler, Error **errp) +{ + object_property_set_link(OBJECT(bus), OBJECT(handler), + QDEV_HOTPLUG_HANDLER_PROPERTY, errp); +} + +void qbus_set_bus_hotplug_handler(BusState *bus, Error **errp) +{ + qbus_set_hotplug_handler(bus, OBJECT(bus), errp); +} + +HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev) +{ + MachineState *machine; + MachineClass *mc; + Object *m_obj =3D qdev_get_machine(); + + if (object_dynamic_cast(m_obj, TYPE_MACHINE)) { + machine =3D MACHINE(m_obj); + mc =3D MACHINE_GET_CLASS(machine); + if (mc->get_hotplug_handler) { + return mc->get_hotplug_handler(machine, dev); + } + } + + return NULL; +} + +HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev) +{ + if (dev->parent_bus) { + return dev->parent_bus->hotplug_handler; + } + return NULL; +} + +HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev) +{ + HotplugHandler *hotplug_ctrl =3D qdev_get_machine_hotplug_handler(dev); + + if (hotplug_ctrl =3D=3D NULL && dev->parent_bus) { + hotplug_ctrl =3D qdev_get_bus_hotplug_handler(dev); + } + return hotplug_ctrl; +} diff --git a/hw/core/qdev.c b/hw/core/qdev.c index f73e7ded1a..3015da0ac9 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -219,41 +219,6 @@ void qdev_set_legacy_instance_id(DeviceState *dev, int= alias_id, dev->alias_required_for_version =3D required_for_version; } =20 -HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev) -{ - MachineState *machine; - MachineClass *mc; - Object *m_obj =3D qdev_get_machine(); - - if (object_dynamic_cast(m_obj, TYPE_MACHINE)) { - machine =3D MACHINE(m_obj); - mc =3D MACHINE_GET_CLASS(machine); - if (mc->get_hotplug_handler) { - return mc->get_hotplug_handler(machine, dev); - } - } - - return NULL; -} - -HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev) -{ - if (dev->parent_bus) { - return dev->parent_bus->hotplug_handler; - } - return NULL; -} - -HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev) -{ - HotplugHandler *hotplug_ctrl =3D qdev_get_machine_hotplug_handler(dev); - - if (hotplug_ctrl =3D=3D NULL && dev->parent_bus) { - hotplug_ctrl =3D qdev_get_bus_hotplug_handler(dev); - } - return hotplug_ctrl; -} - static int qdev_reset_one(DeviceState *dev, void *opaque) { device_reset(dev); diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs index 6789154807..9c4f953716 100644 --- a/hw/core/Makefile.objs +++ b/hw/core/Makefile.objs @@ -1,6 +1,6 @@ # core qdev-related obj files, also used by *-user: common-obj-y +=3D qdev.o qdev-properties.o -common-obj-y +=3D bus.o reset.o +common-obj-y +=3D bus.o reset.o qdev-hotplug.o common-obj-$(CONFIG_SOFTMMU) +=3D qdev-fw.o common-obj-$(CONFIG_SOFTMMU) +=3D fw-path-provider.o # irq.o needed for qdev GPIO handling: --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Sun Feb 8 06:21:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1556222590; cv=none; d=zoho.com; s=zohoarc; b=LzDhVNGBYM4AtiZhsItxr6d2ifTsAaMSot4MKUyXF77Yks0EqrsqgfkxTzmuN/G3XQhB1rlQj+m6vjDOqp8grJbXBdAShVC4sgupt8S3/H7i+INSS07ExvmrfCeNlUcyV7DszlXN7bAiW7fvMtNgDAlnKHVEI7jzqS/8HyXOY1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556222590; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=VnX/ZFiyk5Eni8901G5rJg7FIi8Q8tKVkQIYb1C5/Qc=; b=NnYEx189vQDvMg39DoTN0QelFk1IkqrkSw8iUnrPUF4JSLTV/5vci0slJ0Oob9yNMGyqNUNzCp7pvLUkb7ZSp07NnON1rmW87pyZ//5YelVNcwGi1Cq64blCKN5bPWb0PO/THBXG7JwaMQuNeb2AYMJ7qZK87mXbC4qm2KLB8Zs= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15562225903291015.7392026977666; Thu, 25 Apr 2019 13:03:10 -0700 (PDT) Received: from localhost ([127.0.0.1]:34452 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJkaH-0006yf-30 for importer@patchew.org; Thu, 25 Apr 2019 16:03:05 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJkYS-0005kx-D6 for qemu-devel@nongnu.org; Thu, 25 Apr 2019 16:01:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJkYP-0007F5-5K for qemu-devel@nongnu.org; Thu, 25 Apr 2019 16:01:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59892) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hJkYM-0006HD-Ti for qemu-devel@nongnu.org; Thu, 25 Apr 2019 16:01:09 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0696B88E52; Thu, 25 Apr 2019 20:01:00 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DE001948E; Thu, 25 Apr 2019 20:00:59 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Thu, 25 Apr 2019 17:00:50 -0300 Message-Id: <20190425200051.19906-4-ehabkost@redhat.com> In-Reply-To: <20190425200051.19906-1-ehabkost@redhat.com> References: <20190425200051.19906-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 25 Apr 2019 20:01:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/4] qdev: Don't compile hotplug code in user-mode emulation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Markus Armbruster , Like Xu , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Move qdev-hotplug.o and hotplug.o to CONFIG_SOFTMMU because the code is not necessary for *-user. Provide a few stubs in qdev-hotplug-stubs.c to replace initialization functions that are called from qdev.c. Signed-off-by: Eduardo Habkost --- hw/core/qdev-hotplug-stubs.c | 44 ++++++++++++++++++++++++++++++++++++ hw/core/Makefile.objs | 6 +++-- tests/Makefile.include | 3 ++- 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 hw/core/qdev-hotplug-stubs.c diff --git a/hw/core/qdev-hotplug-stubs.c b/hw/core/qdev-hotplug-stubs.c new file mode 100644 index 0000000000..c710f23388 --- /dev/null +++ b/hw/core/qdev-hotplug-stubs.c @@ -0,0 +1,44 @@ +/* + * qdev hotplug handler stubs (for user-mode emulation and unit tests) + * + * Copyright (c) 2019 Red Hat Inc + * + * Authors: + * Eduardo Habkost + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#include "qemu/osdep.h" +#include "hw/qdev-core.h" +#include "hw/hotplug.h" + +HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev) +{ + return NULL; +} + +void hotplug_handler_pre_plug(HotplugHandler *plug_handler, + DeviceState *plugged_dev, + Error **errp) +{ + assert(plug_handler =3D=3D NULL); +} + +void hotplug_handler_plug(HotplugHandler *plug_handler, + DeviceState *plugged_dev, + Error **errp) +{ + assert(plug_handler =3D=3D NULL); +} diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs index 9c4f953716..284fc306c5 100644 --- a/hw/core/Makefile.objs +++ b/hw/core/Makefile.objs @@ -1,11 +1,10 @@ # core qdev-related obj files, also used by *-user: common-obj-y +=3D qdev.o qdev-properties.o -common-obj-y +=3D bus.o reset.o qdev-hotplug.o +common-obj-y +=3D bus.o reset.o common-obj-$(CONFIG_SOFTMMU) +=3D qdev-fw.o common-obj-$(CONFIG_SOFTMMU) +=3D fw-path-provider.o # irq.o needed for qdev GPIO handling: common-obj-y +=3D irq.o -common-obj-y +=3D hotplug.o common-obj-$(CONFIG_SOFTMMU) +=3D nmi.o =20 common-obj-$(CONFIG_EMPTY_SLOT) +=3D empty_slot.o @@ -13,6 +12,7 @@ common-obj-$(CONFIG_XILINX_AXI) +=3D stream.o common-obj-$(CONFIG_PTIMER) +=3D ptimer.o common-obj-$(CONFIG_SOFTMMU) +=3D sysbus.o common-obj-$(CONFIG_SOFTMMU) +=3D machine.o +common-obj-$(CONFIG_SOFTMMU) +=3D hotplug.o qdev-hotplug.o common-obj-$(CONFIG_SOFTMMU) +=3D gpio.o common-obj-$(CONFIG_SOFTMMU) +=3D loader.o common-obj-$(CONFIG_FITLOADER) +=3D loader-fit.o @@ -23,3 +23,5 @@ common-obj-$(CONFIG_SOFTMMU) +=3D split-irq.o common-obj-$(CONFIG_PLATFORM_BUS) +=3D platform-bus.o common-obj-$(CONFIG_SOFTMMU) +=3D generic-loader.o common-obj-$(CONFIG_SOFTMMU) +=3D null-machine.o + +common-obj-$(CONFIG_USER_ONLY) +=3D qdev-hotplug-stubs.o diff --git a/tests/Makefile.include b/tests/Makefile.include index e2432d5e77..fd5e7e0c77 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -568,7 +568,8 @@ tests/fp/%: $(MAKE) -C $(dir $@) $(notdir $@) =20 tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \ - hw/core/qdev.o hw/core/qdev-properties.o hw/core/hotplug.o\ + hw/core/qdev.o hw/core/qdev-properties.o \ + hw/core/qdev-hotplug-stubs.o \ hw/core/bus.o \ hw/core/irq.o \ hw/core/fw-path-provider.o \ --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Sun Feb 8 06:21:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1556222590; cv=none; d=zoho.com; s=zohoarc; b=YZtwf2NEj2kWt3FOyuFnp/5rKqL75WCgX5DcxW/BpHio8PxSyJmHKqf0ooHVqt+mJ5f6OIMNNmQrsVAU5wfi+GkTHs8FeFOvZOyf8blX7l8yU7bNBU8b7+3EdMlHV2dRxT+S/1w32utLegHunUjzGN0b7ZRw23I/HOioxwVsud4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556222590; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=W7yvJVqK+NAz4BsHy/ZlxwadYfDzpSYNNMCl6A/fvEg=; b=elR9hBYgS3inv2zKB8tsir+GPFnO98Qb+gM9+SF+boYMh/Clxq3bU0eD23zLEn2nOvX/rNCz7JxzM+MQkk+XrMU2ek11FD43xAOUCnJDqGHXiyzxL8xWFqJ7z6ArhRtrg/cOgh+GFwq/OE6sGIVOTvPMeUvzWj9Ti1uMZml7ix0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1556222590338373.6399168635328; Thu, 25 Apr 2019 13:03:10 -0700 (PDT) Received: from localhost ([127.0.0.1]:34454 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJkaG-0006yr-7L for importer@patchew.org; Thu, 25 Apr 2019 16:03:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJkYT-0005l5-K7 for qemu-devel@nongnu.org; Thu, 25 Apr 2019 16:01:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJkYQ-0007My-Et for qemu-devel@nongnu.org; Thu, 25 Apr 2019 16:01:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59916) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hJkYQ-0006XE-5A for qemu-devel@nongnu.org; Thu, 25 Apr 2019 16:01:10 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18E898123D; Thu, 25 Apr 2019 20:01:02 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85709600C0; Thu, 25 Apr 2019 20:01:01 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Thu, 25 Apr 2019 17:00:51 -0300 Message-Id: <20190425200051.19906-5-ehabkost@redhat.com> In-Reply-To: <20190425200051.19906-1-ehabkost@redhat.com> References: <20190425200051.19906-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 25 Apr 2019 20:01:02 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 4/4] qdev-hotplug: Don't check type of qdev_get_machine() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Markus Armbruster , Like Xu , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Now that qdev_get_machine_hotplug_handler() is only compiled in softmmu mode, we don't need to check if qdev_gt_machine() is really of type TYPE_MACHINE. Signed-off-by: Eduardo Habkost --- hw/core/qdev-hotplug.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/hw/core/qdev-hotplug.c b/hw/core/qdev-hotplug.c index 8ab31043a7..017500c1e1 100644 --- a/hw/core/qdev-hotplug.c +++ b/hw/core/qdev-hotplug.c @@ -35,16 +35,11 @@ void qbus_set_bus_hotplug_handler(BusState *bus, Error = **errp) =20 HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev) { - MachineState *machine; - MachineClass *mc; - Object *m_obj =3D qdev_get_machine(); + MachineState *machine =3D MACHINE(qdev_get_machine()); + MachineClass *mc =3D MACHINE_GET_CLASS(machine); =20 - if (object_dynamic_cast(m_obj, TYPE_MACHINE)) { - machine =3D MACHINE(m_obj); - mc =3D MACHINE_GET_CLASS(machine); - if (mc->get_hotplug_handler) { - return mc->get_hotplug_handler(machine, dev); - } + if (mc->get_hotplug_handler) { + return mc->get_hotplug_handler(machine, dev); } =20 return NULL; --=20 2.18.0.rc1.1.g3f1ff2140