From patchwork Thu Jan 29 00:18:07 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian McMenamin X-Patchwork-Id: 4499 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n0T0MJWp017604 for ; Thu, 29 Jan 2009 00:22:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760282AbZA2AVO (ORCPT ); Wed, 28 Jan 2009 19:21:14 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758432AbZA2AVN (ORCPT ); Wed, 28 Jan 2009 19:21:13 -0500 Received: from mk-filter-4-a-1.mail.uk.tiscali.com ([212.74.100.55]:23121 "EHLO mk-filter-4-a-1.mail.uk.tiscali.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760282AbZA2AVL (ORCPT ); Wed, 28 Jan 2009 19:21:11 -0500 X-MUA: Evolution 2.24.3 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhIFAIeEgElQLLDG/2dsb2JhbACBbsl4hUcG X-IronPort-AV: E=Sophos;i="4.37,340,1231113600"; d="scan'208";a="134939758" Received: from 80-44-176-198.dynamic.dsl.as9105.com (HELO newgolddream.info) ([80.44.176.198]) by smtp.tiscali.co.uk with ESMTP; 29 Jan 2009 00:20:23 +0000 Received: from [192.168.62.105] (bossclass.local [192.168.62.105]) by newgolddream.info (8.14.3/8.14.3/Debian-4) with ESMTP id n0T0INkh015633; Thu, 29 Jan 2009 00:18:45 GMT Subject: [PATCH RFC] sh: maple: Add support for SEGA Dreamcast VMU and clean up maple bus driver (3/3) From: Adrian McMenamin To: Paul Mundt Cc: Greg KH , Dmitry Torokhov , dwmw2 , linux-sh , LKML , linux-input , MTD In-Reply-To: <1233187750.6734.27.camel@localhost.localdomain> References: <1233186456.6734.16.camel@localhost.localdomain> <1233187069.6734.21.camel@localhost.localdomain> <1233187750.6734.27.camel@localhost.localdomain> Date: Thu, 29 Jan 2009 00:18:07 +0000 Message-Id: <1233188287.6734.32.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.24.3 X-Spam-Status: No, score=-4.2 required=4.5 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on dragoneye X-Virus-Scanned: ClamAV version 0.94.2, clamav-milter version 0.94.1rc1 on newgolddream.info X-Virus-Status: Clean Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org Consequential patch to the maple keyboard driver and general fix to the keyboard driver. Signed-off-by: Adrian McMenamin --- -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/keyboard/maple_keyb.c b/drivers/input/keyboard/maple_keyb.c index 22f17a5..8d3bb1d 100644 --- a/drivers/input/keyboard/maple_keyb.c +++ b/drivers/input/keyboard/maple_keyb.c @@ -140,7 +140,7 @@ static void dc_kbd_callback(struct mapleq *mq) { struct maple_device *mapledev = mq->dev; struct dc_kbd *kbd = maple_get_drvdata(mapledev); - unsigned long *buf = mq->recvbuf; + unsigned long *buf = (unsigned long *)(mq->recvbuf->buf); /* * We should always get the lock because the only @@ -159,22 +159,41 @@ static void dc_kbd_callback(struct mapleq *mq) static int probe_maple_kbd(struct device *dev) { - struct maple_device *mdev = to_maple_dev(dev); - struct maple_driver *mdrv = to_maple_driver(dev->driver); + struct maple_device *mdev; + struct maple_driver *mdrv; int i, error; struct dc_kbd *kbd; struct input_dev *idev; - if (!(mdev->function & MAPLE_FUNC_KEYBOARD)) - return -EINVAL; + mdev = to_maple_dev(dev); + if (!mdev) { + error = EINVAL; + goto fail; + } + + mdrv = to_maple_driver(dev->driver); + if (!mdrv) { + error = EINVAL; + goto fail; + } + + if (!(mdev->function & MAPLE_FUNC_KEYBOARD)) { + error = EINVAL; + goto fail; + } kbd = kzalloc(sizeof(struct dc_kbd), GFP_KERNEL); - idev = input_allocate_device(); - if (!kbd || !idev) { - error = -ENOMEM; + if (!kbd) { + error = ENOMEM; goto fail; } + idev = input_allocate_device(); + if (!idev) { + error = ENOMEM; + goto fail_idev_alloc; + } + kbd->dev = idev; memcpy(kbd->keycode, dc_kbd_keycode, sizeof(kbd->keycode)); @@ -195,7 +214,7 @@ static int probe_maple_kbd(struct device *dev) error = input_register_device(idev); if (error) - goto fail; + goto fail_register; /* Maple polling is locked to VBLANK - which may be just 50/s */ maple_getcond_callback(mdev, dc_kbd_callback, HZ/50, @@ -207,11 +226,13 @@ static int probe_maple_kbd(struct device *dev) return error; -fail: +fail_register: + maple_set_drvdata(mdev, NULL); input_free_device(idev); +fail_idev_alloc: kfree(kbd); - maple_set_drvdata(mdev, NULL); - return error; +fail: + return -error; } static int remove_maple_kbd(struct device *dev)