From: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 6/7] max7310: finish qdev'ication
Date: Fri, 11 Feb 2011 23:57:38 +0300 [thread overview]
Message-ID: <1297457859-15685-6-git-send-email-dbaryshkov@gmail.com> (raw)
In-Reply-To: <1297457859-15685-1-git-send-email-dbaryshkov@gmail.com>
1) Move GPIO-related functionality to qdev. Now one can use directly
qdev_get_gpio_in()/qdev_connect_gpio_out() on max7310 devices.
2) Make reset to be called through qdev.reset callback.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
hw/i2c.h | 5 -----
hw/max7310.c | 26 +++++---------------------
2 files changed, 5 insertions(+), 26 deletions(-)
diff --git a/hw/i2c.h b/hw/i2c.h
index 83fd917..5514402 100644
--- a/hw/i2c.h
+++ b/hw/i2c.h
@@ -59,11 +59,6 @@ void i2c_register_slave(I2CSlaveInfo *type);
DeviceState *i2c_create_slave(i2c_bus *bus, const char *name, uint8_t addr);
-/* max7310.c */
-void max7310_reset(i2c_slave *i2c);
-qemu_irq *max7310_gpio_in_get(i2c_slave *i2c);
-void max7310_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler);
-
/* wm8750.c */
void wm8750_data_req_set(DeviceState *dev,
void (*data_req)(void *, int, int), void *opaque);
diff --git a/hw/max7310.c b/hw/max7310.c
index c302eb6..c1bdb2e 100644
--- a/hw/max7310.c
+++ b/hw/max7310.c
@@ -23,9 +23,9 @@ typedef struct {
qemu_irq *gpio_in;
} MAX7310State;
-void max7310_reset(i2c_slave *i2c)
+static void max7310_reset(DeviceState *dev)
{
- MAX7310State *s = (MAX7310State *) i2c;
+ MAX7310State *s = FROM_I2C_SLAVE(MAX7310State, I2C_SLAVE_FROM_QDEV(dev));
s->level &= s->direction;
s->direction = 0xff;
s->polarity = 0xf0;
@@ -179,33 +179,17 @@ static int max7310_init(i2c_slave *i2c)
{
MAX7310State *s = FROM_I2C_SLAVE(MAX7310State, i2c);
- s->gpio_in = qemu_allocate_irqs(max7310_gpio_set, s,
- ARRAY_SIZE(s->handler));
-
- max7310_reset(&s->i2c);
+ qdev_init_gpio_in(&i2c->qdev, max7310_gpio_set, 8);
+ qdev_init_gpio_out(&i2c->qdev, s->handler, 8);
return 0;
}
-qemu_irq *max7310_gpio_in_get(i2c_slave *i2c)
-{
- MAX7310State *s = (MAX7310State *) i2c;
- return s->gpio_in;
-}
-
-void max7310_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler)
-{
- MAX7310State *s = (MAX7310State *) i2c;
- if (line >= ARRAY_SIZE(s->handler) || line < 0)
- hw_error("bad GPIO line");
-
- s->handler[line] = handler;
-}
-
static I2CSlaveInfo max7310_info = {
.qdev.name = "max7310",
.qdev.size = sizeof(MAX7310State),
.qdev.vmsd = &vmstate_max7310,
+ .qdev.reset = max7310_reset,
.init = max7310_init,
.event = max7310_event,
.recv = max7310_rx,
--
1.7.2.3
next prev parent reply other threads:[~2011-02-11 20:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-11 20:57 [Qemu-devel] [PATCH 1/7] Add scoop post_load callback that sets IRQs to loaded levels Dmitry Eremin-Solenikov
2011-02-11 20:57 ` [Qemu-devel] [PATCH 2/7] Drop unnecessary inclusions of pxa.h header Dmitry Eremin-Solenikov
2011-02-11 20:57 ` [Qemu-devel] [PATCH 3/7] mainstone: pass one irq to the mst_fpga instead of the whole PIC Dmitry Eremin-Solenikov
2011-02-11 20:57 ` [Qemu-devel] [PATCH 4/7] tc6393xb: correct NAND isr assertion Dmitry Eremin-Solenikov
2011-02-11 20:57 ` [Qemu-devel] [PATCH 5/7] tosa: we aren't connected to VBus, pass this info to Linux kernel Dmitry Eremin-Solenikov
2011-02-11 20:57 ` Dmitry Eremin-Solenikov [this message]
2011-02-11 20:57 ` [Qemu-devel] [PATCH 7/7] pxa2xx: convert i2c master to use qdev/vmsd Dmitry Eremin-Solenikov
2011-02-11 22:37 ` [Qemu-devel] [PATCH 1/7] Add scoop post_load callback that sets IRQs to loaded levels andrzej zaborowski
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=1297457859-15685-6-git-send-email-dbaryshkov@gmail.com \
--to=dbaryshkov@gmail.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).