linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>,
	Andrew Morton <akpm@linux-foundation.org>,
	Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	linux-next@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	linux-input@vger.kernel.org
Subject: Re: linux-next: Tree for July 30
Date: Fri, 1 Aug 2008 12:12:19 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.1.10.0808011201480.3277@nehalem.linux-foundation.org> (raw)
In-Reply-To: <20080731194207.GA12233@anvil.corenet.prv>


Ok, I apparently missed this whole subthread yesterday, only getting back 
to it when going over my old queues.

On Thu, 31 Jul 2008, Dmitry Torokhov wrote:
> 
> Input: paper over a bug in Synaptics X driver

Yeah, it's not pretty, but how about moving that EV_KEY thing into the 
switch() statement? Also, the printk could certainly be a bit more useful.

But before doing _any_ of that, the first thing to do should be to not 
have that four-deep indentation by just splitting that horrible function 
up a bit.

IOW, start off with a patch like the appended, and _then_ add the special 
case handling to the EV_KEY thing. It would probably be most easily done 
by just literally limiting "len" to OLD_KEY_MAX. Something like

   #define OLD_KEY_MAX 0x1ff
   ...
	case EV_KEY:
		bits = dev->keybit;
		len = KEY_MAX;
		/* Hacky workaround for old bug in Xorg */
		if (buf_len == OLD_KEY_MAX) 
			len = OLD_KEY_MAX;
		break;
  ...

or similar.

Yeah, it's not pretty, but pragmatism before beauty.

		Linus
---
 drivers/input/evdev.c |   44 ++++++++++++++++++++++++--------------------
 1 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 2d65411..ef8c2ed 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -647,6 +647,28 @@ static int str_to_user(const char *str, unsigned int maxlen, void __user *p)
 	return copy_to_user(p, str, len) ? -EFAULT : len;
 }
 
+static int handle_eviocgbit(struct input_dev *dev, unsigned int cmd, void __user *p, int compat_mode)
+{
+	unsigned long *bits;
+	int len;
+
+	switch (_IOC_NR(cmd) & EV_MAX) {
+
+	case      0: bits = dev->evbit;  len = EV_MAX;  break;
+	case EV_KEY: bits = dev->keybit; len = KEY_MAX; break;
+	case EV_REL: bits = dev->relbit; len = REL_MAX; break;
+	case EV_ABS: bits = dev->absbit; len = ABS_MAX; break;
+	case EV_MSC: bits = dev->mscbit; len = MSC_MAX; break;
+	case EV_LED: bits = dev->ledbit; len = LED_MAX; break;
+	case EV_SND: bits = dev->sndbit; len = SND_MAX; break;
+	case EV_FF:  bits = dev->ffbit;  len = FF_MAX;  break;
+	case EV_SW:  bits = dev->swbit;  len = SW_MAX;  break;
+	default: return -EINVAL;
+	}
+	return bits_to_user(bits, len, _IOC_SIZE(cmd), p, compat_mode);
+}
+
+
 static long evdev_do_ioctl(struct file *file, unsigned int cmd,
 			   void __user *p, int compat_mode)
 {
@@ -733,26 +755,8 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
 
 		if (_IOC_DIR(cmd) == _IOC_READ) {
 
-			if ((_IOC_NR(cmd) & ~EV_MAX) == _IOC_NR(EVIOCGBIT(0, 0))) {
-
-				unsigned long *bits;
-				int len;
-
-				switch (_IOC_NR(cmd) & EV_MAX) {
-
-				case      0: bits = dev->evbit;  len = EV_MAX;  break;
-				case EV_KEY: bits = dev->keybit; len = KEY_MAX; break;
-				case EV_REL: bits = dev->relbit; len = REL_MAX; break;
-				case EV_ABS: bits = dev->absbit; len = ABS_MAX; break;
-				case EV_MSC: bits = dev->mscbit; len = MSC_MAX; break;
-				case EV_LED: bits = dev->ledbit; len = LED_MAX; break;
-				case EV_SND: bits = dev->sndbit; len = SND_MAX; break;
-				case EV_FF:  bits = dev->ffbit;  len = FF_MAX;  break;
-				case EV_SW:  bits = dev->swbit;  len = SW_MAX;  break;
-				default: return -EINVAL;
-				}
-				return bits_to_user(bits, len, _IOC_SIZE(cmd), p, compat_mode);
-			}
+			if ((_IOC_NR(cmd) & ~EV_MAX) == _IOC_NR(EVIOCGBIT(0, 0)))
+				return handle_eviocgbit(dev, cmd, p, compat_mode);
 
 			if (_IOC_NR(cmd) == _IOC_NR(EVIOCGKEY(0)))
 				return bits_to_user(dev->key, KEY_MAX, _IOC_SIZE(cmd),

  parent reply	other threads:[~2008-08-01 19:12 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080730170635.f737ffe9.sfr@canb.auug.org.au>
2008-07-31  6:10 ` linux-next: Tree for July 30 Andrew Morton
2008-07-31 14:07   ` Dmitry Torokhov
2008-07-31 15:36     ` Bartlomiej Zolnierkiewicz
2008-07-31 15:56       ` Dmitry Torokhov
2008-07-31 17:44         ` Andrew Morton
2008-07-31 18:17           ` Dmitry Torokhov
2008-07-31 18:26             ` Andrew Morton
2008-07-31 18:34               ` Dmitry Torokhov
2008-07-31 18:55                 ` Andrew Morton
2008-07-31 19:03                   ` Dmitry Torokhov
2008-07-31 19:20                   ` Hugh Dickins
2008-07-31 18:48             ` Rafael J. Wysocki
2008-07-31 18:54               ` Dmitry Torokhov
2008-07-31 19:10                 ` Linus Torvalds
2008-07-31 19:24                   ` Dmitry Torokhov
2008-07-31 19:42                     ` Dmitry Torokhov
2008-07-31 20:10                       ` Andrew Morton
2008-08-07 18:11                         ` Dmitry Torokhov
2008-08-07 18:50                           ` Andrew Morton
2008-08-07 19:06                             ` Dmitry Torokhov
2008-08-07 18:55                           ` Rafael J. Wysocki
2008-08-01 19:12                       ` Linus Torvalds [this message]
2008-08-01 19:23                         ` Dmitry Torokhov
2008-08-01 19:26                           ` Linus Torvalds
2008-07-31 19:44                     ` Linus Torvalds
2008-07-31 20:05                       ` Dmitry Torokhov
2008-07-31 20:16                         ` Linus Torvalds
2008-07-31 20:28                           ` Linus Torvalds
2008-07-31 20:39                             ` Dmitry Torokhov
2008-07-31 20:28                           ` Dmitry Torokhov
2008-07-31 19:13                 ` Andrew Morton
2008-07-31 19:57                 ` Rafael J. Wysocki
2008-08-04  5:47   ` Stephen Rothwell

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=alpine.LFD.1.10.0808011201480.3277@nehalem.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=bzolnier@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=rjw@sisk.pl \
    --cc=sfr@canb.auug.org.au \
    /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).