aboutsummaryrefslogtreecommitdiff
path: root/hw/i2c
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>2020-05-12 09:00:20 +0200
committerMarkus Armbruster <armbru@redhat.com>2020-05-15 07:08:52 +0200
commit8e5c952b370b57beb642826882c80e1b66a9cf12 (patch)
tree1fad74d43f0e2e8a6424df685757d67cfbbae02e /hw/i2c
parent688ffbb4f72bf9a75c7ff3a899a9617de61d5fd6 (diff)
downloadqemu-8e5c952b370b57beb642826882c80e1b66a9cf12.zip
qemu-8e5c952b370b57beb642826882c80e1b66a9cf12.tar.gz
qemu-8e5c952b370b57beb642826882c80e1b66a9cf12.tar.bz2
hw: Remove unnecessary DEVICE() cast
The DEVICE() macro is defined as: #define DEVICE(obj) OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE) which expands to: ((DeviceState *)object_dynamic_cast_assert((Object *)(obj), (name), __FILE__, __LINE__, __func__)) This assertion can only fail when @obj points to something other than its stated type, i.e. when we're in undefined behavior country. Remove the unnecessary DEVICE() casts when we already know the pointer is of DeviceState type. Patch created mechanically using spatch with this script: @@ typedef DeviceState; DeviceState *s; @@ - DEVICE(s) + s Acked-by: David Gibson <david@gibson.dropbear.id.au> Acked-by: Paul Durrant <paul@xen.org> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Cédric Le Goater <clg@kaod.org> Acked-by: John Snow <jsnow@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20200512070020.22782-4-f4bug@amsat.org>
Diffstat (limited to 'hw/i2c')
-rw-r--r--hw/i2c/imx_i2c.c2
-rw-r--r--hw/i2c/mpc_i2c.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/hw/i2c/imx_i2c.c b/hw/i2c/imx_i2c.c
index 30b9aea..2e02e1c 100644
--- a/hw/i2c/imx_i2c.c
+++ b/hw/i2c/imx_i2c.c
@@ -305,7 +305,7 @@ static void imx_i2c_realize(DeviceState *dev, Error **errp)
IMX_I2C_MEM_SIZE);
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
- s->bus = i2c_init_bus(DEVICE(dev), NULL);
+ s->bus = i2c_init_bus(dev, NULL);
}
static void imx_i2c_class_init(ObjectClass *klass, void *data)
diff --git a/hw/i2c/mpc_i2c.c b/hw/i2c/mpc_i2c.c
index 0aa1be3..9a724f3 100644
--- a/hw/i2c/mpc_i2c.c
+++ b/hw/i2c/mpc_i2c.c
@@ -332,7 +332,7 @@ static void mpc_i2c_realize(DeviceState *dev, Error **errp)
memory_region_init_io(&i2c->iomem, OBJECT(i2c), &i2c_ops, i2c,
"mpc-i2c", 0x14);
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &i2c->iomem);
- i2c->bus = i2c_init_bus(DEVICE(dev), "i2c");
+ i2c->bus = i2c_init_bus(dev, "i2c");
}
static void mpc_i2c_class_init(ObjectClass *klass, void *data)