From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 49/53] hw/i2c: Use DeviceClass::realize instead of I2CSlaveClass::init
Date: Thu, 31 May 2018 19:16:02 +0200 [thread overview]
Message-ID: <20180531171606.21604-11-pbonzini@redhat.com> (raw)
In-Reply-To: <20180531171606.21604-1-pbonzini@redhat.com>
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
I2CSlaveClass::init is no more used, remove it.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20180419212727.26095-3-f4bug@amsat.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20180528144509.15812-3-armbru@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/audio/wm8750.c | 8 +++-----
hw/display/ssd0303.c | 9 ++++-----
hw/gpio/max7310.c | 9 ++++-----
hw/i2c/core.c | 13 -------------
hw/input/lm832x.c | 9 ++++-----
hw/misc/tmp105.c | 7 +++----
hw/misc/tmp421.c | 8 +++-----
hw/nvram/eeprom_at24c.c | 24 +++++++++++-------------
hw/timer/twl92230.c | 11 ++++-------
include/hw/i2c/i2c.h | 3 ---
10 files changed, 36 insertions(+), 65 deletions(-)
diff --git a/hw/audio/wm8750.c b/hw/audio/wm8750.c
index 416a78e869..f4aa838f62 100644
--- a/hw/audio/wm8750.c
+++ b/hw/audio/wm8750.c
@@ -617,14 +617,12 @@ static const VMStateDescription vmstate_wm8750 = {
}
};
-static int wm8750_init(I2CSlave *i2c)
+static void wm8750_realize(DeviceState *dev, Error **errp)
{
- WM8750State *s = WM8750(i2c);
+ WM8750State *s = WM8750(dev);
AUD_register_card(CODEC, &s->card);
wm8750_reset(I2C_SLAVE(s));
-
- return 0;
}
#if 0
@@ -707,7 +705,7 @@ static void wm8750_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
I2CSlaveClass *sc = I2C_SLAVE_CLASS(klass);
- sc->init = wm8750_init;
+ dc->realize = wm8750_realize;
sc->event = wm8750_event;
sc->recv = wm8750_rx;
sc->send = wm8750_tx;
diff --git a/hw/display/ssd0303.c b/hw/display/ssd0303.c
index 68a80b9d64..eb90ba26be 100644
--- a/hw/display/ssd0303.c
+++ b/hw/display/ssd0303.c
@@ -297,13 +297,12 @@ static const GraphicHwOps ssd0303_ops = {
.gfx_update = ssd0303_update_display,
};
-static int ssd0303_init(I2CSlave *i2c)
+static void ssd0303_realize(DeviceState *dev, Error **errp)
{
- ssd0303_state *s = SSD0303(i2c);
+ ssd0303_state *s = SSD0303(dev);
- s->con = graphic_console_init(DEVICE(i2c), 0, &ssd0303_ops, s);
+ s->con = graphic_console_init(dev, 0, &ssd0303_ops, s);
qemu_console_resize(s->con, 96 * MAGNIFY, 16 * MAGNIFY);
- return 0;
}
static void ssd0303_class_init(ObjectClass *klass, void *data)
@@ -311,7 +310,7 @@ static void ssd0303_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
- k->init = ssd0303_init;
+ dc->realize = ssd0303_realize;
k->event = ssd0303_event;
k->recv = ssd0303_recv;
k->send = ssd0303_send;
diff --git a/hw/gpio/max7310.c b/hw/gpio/max7310.c
index 4c203ef5c6..a560e3afd2 100644
--- a/hw/gpio/max7310.c
+++ b/hw/gpio/max7310.c
@@ -182,14 +182,13 @@ static void max7310_gpio_set(void *opaque, int line, int level)
/* MAX7310 is SMBus-compatible (can be used with only SMBus protocols),
* but also accepts sequences that are not SMBus so return an I2C device. */
-static int max7310_init(I2CSlave *i2c)
+static void max7310_realize(DeviceState *dev, Error **errp)
{
- MAX7310State *s = MAX7310(i2c);
+ I2CSlave *i2c = I2C_SLAVE(dev);
+ MAX7310State *s = MAX7310(dev);
qdev_init_gpio_in(&i2c->qdev, max7310_gpio_set, 8);
qdev_init_gpio_out(&i2c->qdev, s->handler, 8);
-
- return 0;
}
static void max7310_class_init(ObjectClass *klass, void *data)
@@ -197,7 +196,7 @@ static void max7310_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
- k->init = max7310_init;
+ dc->realize = max7310_realize;
k->event = max7310_event;
k->recv = max7310_rx;
k->send = max7310_tx;
diff --git a/hw/i2c/core.c b/hw/i2c/core.c
index cfccefca3d..ab72d5bf2b 100644
--- a/hw/i2c/core.c
+++ b/hw/i2c/core.c
@@ -258,18 +258,6 @@ const VMStateDescription vmstate_i2c_slave = {
}
};
-static int i2c_slave_qdev_init(DeviceState *dev)
-{
- I2CSlave *s = I2C_SLAVE(dev);
- I2CSlaveClass *sc = I2C_SLAVE_GET_CLASS(s);
-
- if (sc->init) {
- return sc->init(s);
- }
-
- return 0;
-}
-
DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr)
{
DeviceState *dev;
@@ -283,7 +271,6 @@ DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr)
static void i2c_slave_class_init(ObjectClass *klass, void *data)
{
DeviceClass *k = DEVICE_CLASS(klass);
- k->init = i2c_slave_qdev_init;
set_bit(DEVICE_CATEGORY_MISC, k->categories);
k->bus_type = TYPE_I2C_BUS;
k->props = i2c_props;
diff --git a/hw/input/lm832x.c b/hw/input/lm832x.c
index d39953126b..74da30d9ca 100644
--- a/hw/input/lm832x.c
+++ b/hw/input/lm832x.c
@@ -464,20 +464,19 @@ static const VMStateDescription vmstate_lm_kbd = {
};
-static int lm8323_init(I2CSlave *i2c)
+static void lm8323_realize(DeviceState *dev, Error **errp)
{
- LM823KbdState *s = LM8323(i2c);
+ LM823KbdState *s = LM8323(dev);
s->model = 0x8323;
s->pwm.tm[0] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm0_tick, s);
s->pwm.tm[1] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm1_tick, s);
s->pwm.tm[2] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm2_tick, s);
- qdev_init_gpio_out(DEVICE(i2c), &s->nirq, 1);
+ qdev_init_gpio_out(dev, &s->nirq, 1);
lm_kbd_reset(s);
qemu_register_reset((void *) lm_kbd_reset, s);
- return 0;
}
void lm832x_key_event(DeviceState *dev, int key, int state)
@@ -505,7 +504,7 @@ static void lm8323_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
- k->init = lm8323_init;
+ dc->realize = lm8323_realize;
k->event = lm_i2c_event;
k->recv = lm_i2c_rx;
k->send = lm_i2c_tx;
diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c
index 9e22d64e36..0918f3a6ea 100644
--- a/hw/misc/tmp105.c
+++ b/hw/misc/tmp105.c
@@ -229,15 +229,14 @@ static void tmp105_reset(I2CSlave *i2c)
tmp105_interrupt_update(s);
}
-static int tmp105_init(I2CSlave *i2c)
+static void tmp105_realize(DeviceState *dev, Error **errp)
{
+ I2CSlave *i2c = I2C_SLAVE(dev);
TMP105State *s = TMP105(i2c);
qdev_init_gpio_out(&i2c->qdev, &s->pin, 1);
tmp105_reset(&s->i2c);
-
- return 0;
}
static void tmp105_initfn(Object *obj)
@@ -252,7 +251,7 @@ static void tmp105_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
- k->init = tmp105_init;
+ dc->realize = tmp105_realize;
k->event = tmp105_event;
k->recv = tmp105_rx;
k->send = tmp105_tx;
diff --git a/hw/misc/tmp421.c b/hw/misc/tmp421.c
index 4a505abbce..c234044305 100644
--- a/hw/misc/tmp421.c
+++ b/hw/misc/tmp421.c
@@ -335,13 +335,11 @@ static void tmp421_reset(I2CSlave *i2c)
s->status = 0;
}
-static int tmp421_init(I2CSlave *i2c)
+static void tmp421_realize(DeviceState *dev, Error **errp)
{
- TMP421State *s = TMP421(i2c);
+ TMP421State *s = TMP421(dev);
tmp421_reset(&s->i2c);
-
- return 0;
}
static void tmp421_initfn(Object *obj)
@@ -366,7 +364,7 @@ static void tmp421_class_init(ObjectClass *klass, void *data)
I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
TMP421Class *sc = TMP421_CLASS(klass);
- k->init = tmp421_init;
+ dc->realize = tmp421_realize;
k->event = tmp421_event;
k->recv = tmp421_rx;
k->send = tmp421_tx;
diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c
index 22183f5360..27cd01e615 100644
--- a/hw/nvram/eeprom_at24c.c
+++ b/hw/nvram/eeprom_at24c.c
@@ -116,31 +116,29 @@ int at24c_eeprom_send(I2CSlave *s, uint8_t data)
return 0;
}
-static
-int at24c_eeprom_init(I2CSlave *i2c)
+static void at24c_eeprom_realize(DeviceState *dev, Error **errp)
{
- EEPROMState *ee = AT24C_EE(i2c);
-
- ee->mem = g_malloc0(ee->rsize);
+ EEPROMState *ee = AT24C_EE(dev);
if (ee->blk) {
int64_t len = blk_getlength(ee->blk);
if (len != ee->rsize) {
- ERR(TYPE_AT24C_EE " : Backing file size %lu != %u\n",
- (unsigned long)len, (unsigned)ee->rsize);
- exit(1);
+ error_setg(errp, "%s: Backing file size %" PRId64 " != %u",
+ TYPE_AT24C_EE, len, ee->rsize);
+ return;
}
if (blk_set_perm(ee->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE,
BLK_PERM_ALL, &error_fatal) < 0)
{
- ERR(TYPE_AT24C_EE
- " : Backing file incorrect permission\n");
- exit(1);
+ error_setg(errp, "%s: Backing file incorrect permission",
+ TYPE_AT24C_EE);
+ return;
}
}
- return 0;
+
+ ee->mem = g_malloc0(ee->rsize);
}
static
@@ -178,7 +176,7 @@ void at24c_eeprom_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
- k->init = &at24c_eeprom_init;
+ dc->realize = &at24c_eeprom_realize;
k->event = &at24c_eeprom_event;
k->recv = &at24c_eeprom_recv;
k->send = &at24c_eeprom_send;
diff --git a/hw/timer/twl92230.c b/hw/timer/twl92230.c
index ef116c636c..3b43b46199 100644
--- a/hw/timer/twl92230.c
+++ b/hw/timer/twl92230.c
@@ -853,10 +853,9 @@ static const VMStateDescription vmstate_menelaus = {
}
};
-static int twl92230_init(I2CSlave *i2c)
+static void twl92230_realize(DeviceState *dev, Error **errp)
{
- DeviceState *dev = DEVICE(i2c);
- MenelausState *s = TWL92230(i2c);
+ MenelausState *s = TWL92230(dev);
s->rtc.hz_tm = timer_new_ms(rtc_clock, menelaus_rtc_hz, s);
/* Three output pins plus one interrupt pin. */
@@ -865,9 +864,7 @@ static int twl92230_init(I2CSlave *i2c)
/* Three input pins plus one power-button pin. */
qdev_init_gpio_in(dev, menelaus_gpio_set, 4);
- menelaus_reset(i2c);
-
- return 0;
+ menelaus_reset(I2C_SLAVE(dev));
}
static void twl92230_class_init(ObjectClass *klass, void *data)
@@ -875,7 +872,7 @@ static void twl92230_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
I2CSlaveClass *sc = I2C_SLAVE_CLASS(klass);
- sc->init = twl92230_init;
+ dc->realize = twl92230_realize;
sc->event = menelaus_event;
sc->recv = menelaus_rx;
sc->send = menelaus_tx;
diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
index d727379b48..5dc166158b 100644
--- a/include/hw/i2c/i2c.h
+++ b/include/hw/i2c/i2c.h
@@ -28,9 +28,6 @@ typedef struct I2CSlave I2CSlave;
typedef struct I2CSlaveClass {
DeviceClass parent_class;
- /* Callbacks provided by the device. */
- int (*init)(I2CSlave *dev);
-
/* Master to slave. Returns non-zero for a NAK, 0 for success. */
int (*send)(I2CSlave *s, uint8_t data);
--
2.17.0
next prev parent reply other threads:[~2018-05-31 17:16 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-31 17:12 [Qemu-devel] [PULL 00/53] Misc patches for 2018-05-31 Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 01/53] sandbox: disable -sandbox if CONFIG_SECCOMP undefined Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 02/53] vfio: Include "exec/address-spaces.h" directly in the source file Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 03/53] accel: Do not include "exec/address-spaces.h" if it is not necessary Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 04/53] target: " Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 05/53] memory: Do not include "exec/ioport.h" " Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 06/53] target/i386: " Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 07/53] target/xtensa: Include "qemu/timer.h" to use NANOSECONDS_PER_SECOND Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 08/53] target/ppc: Include "exec/exec-all.h" which provides tlb_flush() Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 09/53] target/hppa: Include "qemu/log.h" to use qemu_log() Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 10/53] target: Do not include "exec/exec-all.h" if it is not necessary Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 11/53] nios2: do not include exec-all.h from cpu.h Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 12/53] hw: Do not include "exec/ioport.h" if it is not necessary Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 13/53] hw: Do not include "exec/address-spaces.h" " Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 14/53] hw: Do not include "sysemu/block-backend.h" " Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 15/53] hw: Do not include "sysemu/blockdev.h" " Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 16/53] " Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 17/53] hw/block/nvme: Include "qemu/cutils.h" directly in the source file Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 18/53] hw/misc/mips_itu: Cleanup includes Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 19/53] hw/misc/sga: Use the correct ISA include Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 20/53] hw/hppa: Remove unused include Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 21/53] hw/i386/pc: " Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 22/53] hw/ide: " Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 23/53] hw: Clean "hw/devices.h" includes Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 24/53] qom: Document qom/device-list-properties implementation specific Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 25/53] qom: support orphan objects in object_get_canonical_path Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 26/53] virtio: free MemoryRegionCache when initialization fails Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 27/53] memory.h: Fix typo in documentation comment Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 28/53] memory: get rid of memory_region_init_reservation Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 29/53] memory: delete struct AddressSpaceOps Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 30/53] hw/isa/superio: Fix inconsistent use of Chardev->be Paolo Bonzini
2018-05-31 18:08 ` Philippe Mathieu-Daudé
2018-05-31 17:12 ` [Qemu-devel] [PULL 31/53] mux: fix ctrl-a b again Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 32/53] memfd: Avoid Coverity warning about integer overflow Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 33/53] exec.c: Initialize sa_flags passed to sigaction() Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 34/53] WHPX: dynamically load WHP libraries Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 35/53] WHPX: fix some compiler warnings Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 36/53] qemu-options: Mark the non-functional -clock option as deprecated Paolo Bonzini
2018-05-31 17:12 ` [Qemu-devel] [PULL 37/53] tcg: remove softfloat from --disable-tcg builds Paolo Bonzini
2018-05-31 17:15 ` [Qemu-devel] [PULL 39/53] ipmi: Use proper struct reference for KCS vmstate Paolo Bonzini
2018-05-31 17:15 ` [Qemu-devel] [PULL 40/53] docs/interop: add "firmware.json" Paolo Bonzini
2018-05-31 19:07 ` Eric Blake
2018-05-31 17:15 ` [Qemu-devel] [PULL 41/53] gdbstub: Prevent fd leakage Paolo Bonzini
2018-05-31 17:15 ` [Qemu-devel] [PULL 42/53] virtio-gpu-3d: Define VIRTIO_GPU_CAPSET_VIRGL2 elsewhere Paolo Bonzini
2018-05-31 17:15 ` [Qemu-devel] [PULL 43/53] scripts/update-linux-headers: Handle __aligned_u64 Paolo Bonzini
2018-05-31 17:15 ` [Qemu-devel] [PULL 44/53] scripts/update-linux-headers: Handle kernel license no longer being one file Paolo Bonzini
2018-05-31 17:15 ` [Qemu-devel] [PULL 45/53] target/i386/kvm.c: Handle renaming of KVM_HINTS_DEDICATED Paolo Bonzini
2018-05-31 17:15 ` [Qemu-devel] [PULL 46/53] Update Linux headers to 4.17-rc6 Paolo Bonzini
2018-05-31 17:16 ` [Qemu-devel] [PULL 47/53] target/i386/kvm.c: Remove compatibility shim for KVM_HINTS_REALTIME Paolo Bonzini
2018-05-31 17:16 ` [Qemu-devel] [PULL 48/53] hw/i2c/smbus: Use DeviceClass::realize instead of SMBusDeviceClass::init Paolo Bonzini
2018-05-31 17:16 ` Paolo Bonzini [this message]
2018-05-31 17:16 ` [Qemu-devel] [PULL 50/53] qdev: Simplify the SysBusDeviceClass::init path Paolo Bonzini
2018-05-31 17:16 ` [Qemu-devel] [PULL 51/53] qdev: Remove DeviceClass::init() and ::exit() Paolo Bonzini
2018-05-31 17:16 ` [Qemu-devel] [PULL 52/53] char: Remove unwanted crlf conversion Paolo Bonzini
2018-06-08 17:39 ` Greg Kurz
2018-06-08 17:56 ` Philippe Mathieu-Daudé
2018-06-09 7:31 ` Greg Kurz
2018-06-08 18:08 ` Patryk Olszewski
2018-05-31 17:16 ` [Qemu-devel] [PULL 53/53] memory: Make operations using MemoryRegionIoeventfd struct pass by pointer Paolo Bonzini
2018-05-31 17:16 ` [Qemu-devel] [PULL 37/53] tcg: remove softfloat from --disable-tcg builds Paolo Bonzini
2018-05-31 17:16 ` [Qemu-devel] [PULL 38/53] vmstate: Add a VSTRUCT type Paolo Bonzini
2018-05-31 17:52 ` [Qemu-devel] [PULL 00/53] Misc patches for 2018-05-31 Peter Maydell
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=20180531171606.21604-11-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--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).