From patchwork Fri Jul 29 15:35:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 107419 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B6251B6F64 for ; Sat, 30 Jul 2011 02:24:03 +1000 (EST) Received: from localhost ([::1]:35578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qmp6y-0001YF-OT for incoming@patchwork.ozlabs.org; Fri, 29 Jul 2011 11:36:28 -0400 Received: from eggs.gnu.org ([140.186.70.92]:47951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qmp6S-0000Yh-DO for qemu-devel@nongnu.org; Fri, 29 Jul 2011 11:35:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qmp6Q-000298-5j for qemu-devel@nongnu.org; Fri, 29 Jul 2011 11:35:56 -0400 Received: from mnementh.archaic.org.uk ([81.2.115.146]:36200) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qmp6P-0001zI-R3 for qemu-devel@nongnu.org; Fri, 29 Jul 2011 11:35:54 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1Qmp60-0007Zh-53; Fri, 29 Jul 2011 16:35:28 +0100 From: Peter Maydell To: qemu-devel@nongnu.org, Anthony Liguori Date: Fri, 29 Jul 2011 16:35:18 +0100 Message-Id: <1311953728-29084-6-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1311953728-29084-1-git-send-email-peter.maydell@linaro.org> References: <1311953728-29084-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 81.2.115.146 Subject: [Qemu-devel] [PATCH 05/15] lm832x: Take DeviceState pointer in lm832x_key_event() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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) */