diff mbox

[RFC] sh: maple: Add support for SEGA Dreamcast VMU and clean up maple bus driver (3/3)

Message ID 1233188287.6734.32.camel@localhost.localdomain (mailing list archive)
State Changes Requested
Headers show

Commit Message

Adrian McMenamin Jan. 29, 2009, 12:18 a.m. UTC
Consequential patch to the maple keyboard driver and general fix to the keyboard driver.

Signed-off-by: Adrian McMenamin <adrian@mcmen.demon.co.uk>
---



--
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

Comments

Paul Mundt Jan. 29, 2009, 2:57 a.m. UTC | #1
On Thu, Jan 29, 2009 at 12:18:07AM +0000, Adrian McMenamin wrote:
> +	if (!(mdev->function & MAPLE_FUNC_KEYBOARD)) {
> +		error = EINVAL;
> +		goto fail;
> +	}
>  
What is this all about? If the function doesn't match, you should never
enter the probe routine in the first place. The bus code should already
get this right.
--
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
Mike Frysinger Jan. 29, 2009, 5:46 a.m. UTC | #2
On Wednesday 28 January 2009 19:18:07 Adrian McMenamin wrote:
> --- a/drivers/input/keyboard/maple_keyb.c
> +++ b/drivers/input/keyboard/maple_keyb.c
> -	if (!kbd || !idev) {
> -		error = -ENOMEM;
> +	if (!kbd) {
> +		error = ENOMEM;
>  		goto fail;
>  	}
> ...
> -	return error;
> +fail:
> +	return -error;

this driver has the weird/broken error inverting other patches of yours have 
had recently ... that stuff really needs to stop showing up ;)
-mike
--
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
Adrian McMenamin Jan. 29, 2009, 10:34 a.m. UTC | #3
On Thu, January 29, 2009 2:57 am, Paul Mundt wrote:
> On Thu, Jan 29, 2009 at 12:18:07AM +0000, Adrian McMenamin wrote:
>> +	if (!(mdev->function & MAPLE_FUNC_KEYBOARD)) {
>> +		error = EINVAL;
>> +		goto fail;
>> +	}
>>
> What is this all about? If the function doesn't match, you should never
> enter the probe routine in the first place. The bus code should already
> get this right.
>

It does, it is a fragment of old code from when the bus code was wrong
which for reasons which pass understanding I rewrote rather than just
excised.

--
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 mbox

Patch

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)