* [Qemu-devel] [PATCH] lm832x: Take DeviceState pointer in lm832x_key_event()
@ 2011-07-28 14:47 Peter Maydell
2011-07-29 14:31 ` Anthony Liguori
0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2011-07-28 14:47 UTC (permalink / raw)
To: qemu-devel; +Cc: patches
Since lm832x has been qdev'ified, its users will generally
have a DeviceState pointer rather than an i2c_slave pointer,
so adjust lm832x_key_event's prototype to suit.
This allows the n810 (its only user) to actually pass a correct
pointer to it rather than NULL. The effect is that we no longer
segfault when a key is pressed.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
NB: this patch depends on the OMAP GPIO v2 patchset.
hw/i2c.h | 2 +-
hw/lm832x.c | 4 ++--
hw/nseries.c | 7 +++----
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/hw/i2c.h b/hw/i2c.h
index 5514402..9381d01 100644
--- a/hw/i2c.h
+++ b/hw/i2c.h
@@ -72,6 +72,6 @@ void wm8750_set_bclk_in(void *opaque, int new_hz);
void tmp105_set(i2c_slave *i2c, int temp);
/* lm832x.c */
-void lm832x_key_event(i2c_slave *i2c, int key, int state);
+void lm832x_key_event(DeviceState *dev, int key, int state);
#endif
diff --git a/hw/lm832x.c b/hw/lm832x.c
index 590a4cc..992ce49 100644
--- a/hw/lm832x.c
+++ b/hw/lm832x.c
@@ -474,9 +474,9 @@ static int lm8323_init(i2c_slave *i2c)
return 0;
}
-void lm832x_key_event(struct i2c_slave *i2c, int key, int state)
+void lm832x_key_event(DeviceState *dev, int key, int state)
{
- LM823KbdState *s = (LM823KbdState *) i2c;
+ LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, I2C_SLAVE_FROM_QDEV(dev));
if ((s->status & INT_ERROR) && (s->error & ERR_FIFOOVR))
return;
diff --git a/hw/nseries.c b/hw/nseries.c
index 32f2f53..45b52bb 100644
--- a/hw/nseries.c
+++ b/hw/nseries.c
@@ -45,7 +45,7 @@ struct n800_s {
i2c_bus *i2c;
int keymap[0x80];
- i2c_slave *kbd;
+ DeviceState *kbd;
TUSBState *usb;
void *retu;
@@ -362,7 +362,6 @@ static int n810_keys[0x80] = {
static void n810_kbd_setup(struct n800_s *s)
{
qemu_irq kbd_irq = qdev_get_gpio_in(s->cpu->gpio, N810_KEYBOARD_GPIO);
- DeviceState *dev;
int i;
for (i = 0; i < 0x80; i ++)
@@ -375,8 +374,8 @@ static void n810_kbd_setup(struct n800_s *s)
/* Attach the LM8322 keyboard to the I2C bus,
* should happen in n8x0_i2c_setup and s->kbd be initialised here. */
- dev = i2c_create_slave(s->i2c, "lm8323", N810_LM8323_ADDR);
- qdev_connect_gpio_out(dev, 0, kbd_irq);
+ s->kbd = i2c_create_slave(s->i2c, "lm8323", N810_LM8323_ADDR);
+ qdev_connect_gpio_out(s->kbd, 0, kbd_irq);
}
/* LCD MIPI DBI-C controller (URAL) */
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] lm832x: Take DeviceState pointer in lm832x_key_event()
2011-07-28 14:47 [Qemu-devel] [PATCH] lm832x: Take DeviceState pointer in lm832x_key_event() Peter Maydell
@ 2011-07-29 14:31 ` Anthony Liguori
2011-07-29 14:38 ` Peter Maydell
0 siblings, 1 reply; 3+ messages in thread
From: Anthony Liguori @ 2011-07-29 14:31 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, patches
On 07/28/2011 09:47 AM, Peter Maydell wrote:
> Since lm832x has been qdev'ified, its users will generally
> have a DeviceState pointer rather than an i2c_slave pointer,
> so adjust lm832x_key_event's prototype to suit.
>
> This allows the n810 (its only user) to actually pass a correct
> pointer to it rather than NULL. The effect is that we no longer
> segfault when a key is pressed.
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> NB: this patch depends on the OMAP GPIO v2 patchset.
Could you put together a pull request for these devices?
Regards,
Anthony Liguori
>
> hw/i2c.h | 2 +-
> hw/lm832x.c | 4 ++--
> hw/nseries.c | 7 +++----
> 3 files changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/hw/i2c.h b/hw/i2c.h
> index 5514402..9381d01 100644
> --- a/hw/i2c.h
> +++ b/hw/i2c.h
> @@ -72,6 +72,6 @@ void wm8750_set_bclk_in(void *opaque, int new_hz);
> void tmp105_set(i2c_slave *i2c, int temp);
>
> /* lm832x.c */
> -void lm832x_key_event(i2c_slave *i2c, int key, int state);
> +void lm832x_key_event(DeviceState *dev, int key, int state);
>
> #endif
> diff --git a/hw/lm832x.c b/hw/lm832x.c
> index 590a4cc..992ce49 100644
> --- a/hw/lm832x.c
> +++ b/hw/lm832x.c
> @@ -474,9 +474,9 @@ static int lm8323_init(i2c_slave *i2c)
> return 0;
> }
>
> -void lm832x_key_event(struct i2c_slave *i2c, int key, int state)
> +void lm832x_key_event(DeviceState *dev, int key, int state)
> {
> - LM823KbdState *s = (LM823KbdState *) i2c;
> + LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, I2C_SLAVE_FROM_QDEV(dev));
>
> if ((s->status& INT_ERROR)&& (s->error& ERR_FIFOOVR))
> return;
> diff --git a/hw/nseries.c b/hw/nseries.c
> index 32f2f53..45b52bb 100644
> --- a/hw/nseries.c
> +++ b/hw/nseries.c
> @@ -45,7 +45,7 @@ struct n800_s {
> i2c_bus *i2c;
>
> int keymap[0x80];
> - i2c_slave *kbd;
> + DeviceState *kbd;
>
> TUSBState *usb;
> void *retu;
> @@ -362,7 +362,6 @@ static int n810_keys[0x80] = {
> static void n810_kbd_setup(struct n800_s *s)
> {
> qemu_irq kbd_irq = qdev_get_gpio_in(s->cpu->gpio, N810_KEYBOARD_GPIO);
> - DeviceState *dev;
> int i;
>
> for (i = 0; i< 0x80; i ++)
> @@ -375,8 +374,8 @@ static void n810_kbd_setup(struct n800_s *s)
>
> /* Attach the LM8322 keyboard to the I2C bus,
> * should happen in n8x0_i2c_setup and s->kbd be initialised here. */
> - dev = i2c_create_slave(s->i2c, "lm8323", N810_LM8323_ADDR);
> - qdev_connect_gpio_out(dev, 0, kbd_irq);
> + s->kbd = i2c_create_slave(s->i2c, "lm8323", N810_LM8323_ADDR);
> + qdev_connect_gpio_out(s->kbd, 0, kbd_irq);
> }
>
> /* LCD MIPI DBI-C controller (URAL) */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] lm832x: Take DeviceState pointer in lm832x_key_event()
2011-07-29 14:31 ` Anthony Liguori
@ 2011-07-29 14:38 ` Peter Maydell
0 siblings, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2011-07-29 14:38 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel, patches
On 29 July 2011 15:31, Anthony Liguori <anthony@codemonkey.ws> wrote:
> On 07/28/2011 09:47 AM, Peter Maydell wrote:
>>
>> Since lm832x has been qdev'ified, its users will generally
>> have a DeviceState pointer rather than an i2c_slave pointer,
>> so adjust lm832x_key_event's prototype to suit.
>>
>> This allows the n810 (its only user) to actually pass a correct
>> pointer to it rather than NULL. The effect is that we no longer
>> segfault when a key is pressed.
>>
>> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
>> ---
>> NB: this patch depends on the OMAP GPIO v2 patchset.
>
> Could you put together a pull request for these devices?
Sure. Do you want just the GPIO patches and this patch,
or shall I put the nand/onenand patches in too?
thanks
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-07-29 14:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-28 14:47 [Qemu-devel] [PATCH] lm832x: Take DeviceState pointer in lm832x_key_event() Peter Maydell
2011-07-29 14:31 ` Anthony Liguori
2011-07-29 14:38 ` Peter Maydell
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).