From: "Alastair D'Silva" <alastair@au1.ibm.com>
To: qemu-arm@nongnu.org
Cc: qemu-devel@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
"Cédric Le Goater" <clg@kaod.org>,
"Andrew Jeffery" <andrew@aj.id.au>,
"Joel Stanley" <joel@jms.id.au>,
"Alastair D'Silva" <alastair@d-silva.org>
Subject: [Qemu-devel] [PATCH v2 2/6] hw/i2c: Add a NULL check for i2c slave init callbacks
Date: Wed, 30 Nov 2016 16:36:25 +1100 [thread overview]
Message-ID: <20161130053629.23340-3-alastair@au1.ibm.com> (raw)
In-Reply-To: <20161130053629.23340-1-alastair@au1.ibm.com>
From: Alastair D'Silva <alastair@d-silva.org>
Add a NULL check for i2c slave init callbacks, so that we no longer
need to implement empty init functions.
Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
---
hw/arm/pxa2xx.c | 9 +--------
hw/arm/tosa.c | 7 -------
hw/arm/z2.c | 7 -------
hw/i2c/core.c | 6 +++++-
hw/timer/ds1338.c | 6 ------
5 files changed, 6 insertions(+), 29 deletions(-)
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index 21ea1d6..bdcf6bc 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -1449,17 +1449,10 @@ static const VMStateDescription vmstate_pxa2xx_i2c = {
}
};
-static int pxa2xx_i2c_slave_init(I2CSlave *i2c)
-{
- /* Nothing to do. */
- return 0;
-}
-
static void pxa2xx_i2c_slave_class_init(ObjectClass *klass, void *data)
{
I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
- k->init = pxa2xx_i2c_slave_init;
k->event = pxa2xx_i2c_event;
k->recv = pxa2xx_i2c_rx;
k->send = pxa2xx_i2c_tx;
@@ -2070,7 +2063,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
}
if (!revision)
revision = "pxa270";
-
+
s->cpu = cpu_arm_init(revision);
if (s->cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
index 1ee12f4..39d9dbb 100644
--- a/hw/arm/tosa.c
+++ b/hw/arm/tosa.c
@@ -202,12 +202,6 @@ static int tosa_dac_recv(I2CSlave *s)
return -1;
}
-static int tosa_dac_init(I2CSlave *i2c)
-{
- /* Nothing to do. */
- return 0;
-}
-
static void tosa_tg_init(PXA2xxState *cpu)
{
I2CBus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
@@ -275,7 +269,6 @@ static void tosa_dac_class_init(ObjectClass *klass, void *data)
{
I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
- k->init = tosa_dac_init;
k->event = tosa_dac_event;
k->recv = tosa_dac_recv;
k->send = tosa_dac_send;
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
index 68a92f3..b3a6bbd 100644
--- a/hw/arm/z2.c
+++ b/hw/arm/z2.c
@@ -263,12 +263,6 @@ static int aer915_recv(I2CSlave *slave)
return retval;
}
-static int aer915_init(I2CSlave *i2c)
-{
- /* Nothing to do. */
- return 0;
-}
-
static VMStateDescription vmstate_aer915_state = {
.name = "aer915",
.version_id = 1,
@@ -285,7 +279,6 @@ static void aer915_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
- k->init = aer915_init;
k->event = aer915_event;
k->recv = aer915_recv;
k->send = aer915_send;
diff --git a/hw/i2c/core.c b/hw/i2c/core.c
index abd4c4c..ae3ca94 100644
--- a/hw/i2c/core.c
+++ b/hw/i2c/core.c
@@ -260,7 +260,11 @@ static int i2c_slave_qdev_init(DeviceState *dev)
I2CSlave *s = I2C_SLAVE(dev);
I2CSlaveClass *sc = I2C_SLAVE_GET_CLASS(s);
- return sc->init(s);
+ if (sc->init) {
+ return sc->init(s);
+ } else {
+ return 0;
+ }
}
DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr)
diff --git a/hw/timer/ds1338.c b/hw/timer/ds1338.c
index 0112949..f5d04dd 100644
--- a/hw/timer/ds1338.c
+++ b/hw/timer/ds1338.c
@@ -198,11 +198,6 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data)
return 0;
}
-static int ds1338_init(I2CSlave *i2c)
-{
- return 0;
-}
-
static void ds1338_reset(DeviceState *dev)
{
DS1338State *s = DS1338(dev);
@@ -220,7 +215,6 @@ static void ds1338_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
- k->init = ds1338_init;
k->event = ds1338_event;
k->recv = ds1338_recv;
k->send = ds1338_send;
--
2.9.3
next prev parent reply other threads:[~2016-11-30 5:37 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-30 5:36 [Qemu-devel] [PATCH v2 0/6] Add support for the Epson RX8900 RTC to the aspeed board Alastair D'Silva
2016-11-30 5:36 ` [Qemu-devel] [PATCH v2 1/6] arm: Uniquely name imx25 I2C buses Alastair D'Silva
2016-11-30 8:18 ` Cédric Le Goater
2016-12-01 0:42 ` Alastair D'Silva
2016-12-01 3:10 ` Alexey Kardashevskiy
2016-12-01 12:31 ` Cédric Le Goater
2016-12-01 22:45 ` Alastair D'Silva
2016-12-01 23:34 ` Alexey Kardashevskiy
2016-12-02 7:55 ` Cédric Le Goater
2016-12-03 7:16 ` Alexey Kardashevskiy
2016-12-03 7:48 ` Cédric Le Goater
2016-11-30 5:36 ` Alastair D'Silva [this message]
2016-11-30 8:02 ` [Qemu-devel] [PATCH v2 2/6] hw/i2c: Add a NULL check for i2c slave init callbacks Cédric Le Goater
2016-12-01 3:13 ` Alexey Kardashevskiy
2016-11-30 5:36 ` [Qemu-devel] [PATCH v2 3/6] qtest: Support named interrupts Alastair D'Silva
2016-11-30 5:36 ` [Qemu-devel] [PATCH v2 4/6] hw/timer: Add Epson RX8900 RTC support Alastair D'Silva
2016-11-30 8:03 ` Cédric Le Goater
2016-12-01 5:53 ` Alexey Kardashevskiy
2016-12-02 0:19 ` Alastair D'Silva
2016-12-02 2:48 ` Alexey Kardashevskiy
2016-12-02 3:30 ` Alastair D'Silva
2016-12-02 4:07 ` Alexey Kardashevskiy
2016-12-02 4:48 ` Alastair D'Silva
2016-11-30 5:36 ` [Qemu-devel] [PATCH v2 5/6] tests: Test all implemented RX8900 functionality Alastair D'Silva
2016-11-30 5:36 ` [Qemu-devel] [PATCH v2 6/6] arm: Add an RX8900 RTC to the ASpeed board Alastair D'Silva
2016-11-30 8:16 ` Cédric Le Goater
2016-11-30 5:50 ` [Qemu-devel] [PATCH v2 0/6] Add support for the Epson RX8900 RTC to the aspeed board Alastair D'Silva
2016-11-30 6:55 ` no-reply
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=20161130053629.23340-3-alastair@au1.ibm.com \
--to=alastair@au1.ibm.com \
--cc=alastair@d-silva.org \
--cc=andrew@aj.id.au \
--cc=clg@kaod.org \
--cc=joel@jms.id.au \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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 NNTP newsgroup(s).