From patchwork Sun Nov 15 06:20:36 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 60062 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 nAF6KlbI016699 for ; Sun, 15 Nov 2009 06:20:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751656AbZKOGUh (ORCPT ); Sun, 15 Nov 2009 01:20:37 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751637AbZKOGUh (ORCPT ); Sun, 15 Nov 2009 01:20:37 -0500 Received: from mail-pw0-f42.google.com ([209.85.160.42]:36232 "EHLO mail-pw0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751202AbZKOGUg (ORCPT ); Sun, 15 Nov 2009 01:20:36 -0500 Received: by pwi3 with SMTP id 3so2716873pwi.21 for ; Sat, 14 Nov 2009 22:20:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=CE8SZfZvuqot7T6MBkFdwCiinFmMy9CaVDitcFtfJpQ=; b=pUN6gfFQ10UV3e6RMvdvXqPPkoshp1OmYVY2ETNAS3q9MZwqIlOTkK44XfPMmvGLSi CUrtAH/QYUB+JxRK+4xP2JE8YE8nHoJM4mYv828vBBHmQ7dtdJA+1qd31VTm2jiCxYup 3GfsMC61OgnKpjCA2qkSQxpnvfbiwqfC6d76s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=m/Rq6575Lf5q3nN/GQuDW+wLc55b3yIlF5nAoLZRk1edsilusrZpaJJ/Hmx/LnMdPZ 5maLY5yGocipWHawF075LUMDiVCcTwjCT4UDk1RkfZC2HN0jYmi/7c6v6E1c+bvWk5UD GD1CyQktkPhNWyiTH/G9wM1fJ0s8/fO4gRI+g= Received: by 10.115.101.27 with SMTP id d27mr3724927wam.126.1258266042141; Sat, 14 Nov 2009 22:20:42 -0800 (PST) Received: from mailhub.coreip.homeip.net (c-24-6-153-137.hsd1.ca.comcast.net [24.6.153.137]) by mx.google.com with ESMTPS id 23sm581200pxi.1.2009.11.14.22.20.39 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 14 Nov 2009 22:20:40 -0800 (PST) Date: Sat, 14 Nov 2009 22:20:36 -0800 From: Dmitry Torokhov To: Andrey Borzenkov Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: Three buttons reported on two-button touchpad Message-ID: <20091115062036.GA9844@core.coreip.homeip.net> References: <200911141551.14263.arvidjaar@mail.ru> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <200911141551.14263.arvidjaar@mail.ru> User-Agent: Mutt/1.5.19 (2009-01-05) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org diff --git a/drivers/input/mouse/hgpk.c b/drivers/input/mouse/hgpk.c index de1e553..b146237 100644 --- a/drivers/input/mouse/hgpk.c +++ b/drivers/input/mouse/hgpk.c @@ -430,19 +430,6 @@ static int hgpk_register(struct psmouse *psmouse) struct input_dev *dev = psmouse->dev; int err; - /* unset the things that psmouse-base sets which we don't have */ - __clear_bit(BTN_MIDDLE, dev->keybit); - - /* set the things we do have */ - __set_bit(EV_KEY, dev->evbit); - __set_bit(EV_REL, dev->evbit); - - __set_bit(REL_X, dev->relbit); - __set_bit(REL_Y, dev->relbit); - - __set_bit(BTN_LEFT, dev->keybit); - __set_bit(BTN_RIGHT, dev->keybit); - /* register handlers */ psmouse->protocol_handler = hgpk_process_byte; psmouse->poll = hgpk_poll; diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c index ab5dc5f..543c240 100644 --- a/drivers/input/mouse/logips2pp.c +++ b/drivers/input/mouse/logips2pp.c @@ -404,8 +404,8 @@ int ps2pp_init(struct psmouse *psmouse, bool set_properties) } } - if (buttons < 3) - __clear_bit(BTN_MIDDLE, psmouse->dev->keybit); + if (buttons >= 3) + __set_bit(BTN_MIDDLE, psmouse->dev->keybit); if (model_info) ps2pp_set_model_properties(psmouse, model_info, use_ps2pp); diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 5bd6484..560d647 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c @@ -425,6 +425,7 @@ static int genius_detect(struct psmouse *psmouse, bool set_properties) return -1; if (set_properties) { + __set_bit(BTN_MIDDLE, psmouse->dev->keybit); __set_bit(BTN_EXTRA, psmouse->dev->keybit); __set_bit(BTN_SIDE, psmouse->dev->keybit); __set_bit(REL_WHEEL, psmouse->dev->relbit); @@ -460,8 +461,10 @@ static int intellimouse_detect(struct psmouse *psmouse, bool set_properties) __set_bit(BTN_MIDDLE, psmouse->dev->keybit); __set_bit(REL_WHEEL, psmouse->dev->relbit); - if (!psmouse->vendor) psmouse->vendor = "Generic"; - if (!psmouse->name) psmouse->name = "Wheel Mouse"; + if (!psmouse->vendor) + psmouse->vendor = "Generic"; + if (!psmouse->name) + psmouse->name = "Wheel Mouse"; psmouse->pktsize = 4; } @@ -504,8 +507,10 @@ static int im_explorer_detect(struct psmouse *psmouse, bool set_properties) __set_bit(BTN_SIDE, psmouse->dev->keybit); __set_bit(BTN_EXTRA, psmouse->dev->keybit); - if (!psmouse->vendor) psmouse->vendor = "Generic"; - if (!psmouse->name) psmouse->name = "Explorer Mouse"; + if (!psmouse->vendor) + psmouse->vendor = "Generic"; + if (!psmouse->name) + psmouse->name = "Explorer Mouse"; psmouse->pktsize = 4; } @@ -536,6 +541,7 @@ static int thinking_detect(struct psmouse *psmouse, bool set_properties) return -1; if (set_properties) { + __set_bit(BTN_MIDDLE, psmouse->dev->keybit); __set_bit(BTN_EXTRA, psmouse->dev->keybit); psmouse->vendor = "Kensington"; @@ -551,8 +557,16 @@ static int thinking_detect(struct psmouse *psmouse, bool set_properties) static int ps2bare_detect(struct psmouse *psmouse, bool set_properties) { if (set_properties) { - if (!psmouse->vendor) psmouse->vendor = "Generic"; - if (!psmouse->name) psmouse->name = "Mouse"; + if (!psmouse->vendor) + psmouse->vendor = "Generic"; + if (!psmouse->name) + psmouse->name = "Mouse"; + +/* + * We have no way of figuring true number of buttons so let's + * assume that the device has 3. + */ + __set_bit(BTN_MIDDLE, psmouse->dev->keybit); } return 0; @@ -567,6 +581,8 @@ static int cortron_detect(struct psmouse *psmouse, bool set_properties) if (set_properties) { psmouse->vendor = "Cortron"; psmouse->name = "PS/2 Trackball"; + + __set_bit(BTN_MIDDLE, psmouse->dev->keybit); __set_bit(BTN_SIDE, psmouse->dev->keybit); } @@ -1184,15 +1200,16 @@ static void psmouse_disconnect(struct serio *serio) mutex_unlock(&psmouse_mutex); } -static int psmouse_switch_protocol(struct psmouse *psmouse, const struct psmouse_protocol *proto) +static int psmouse_switch_protocol(struct psmouse *psmouse, + const struct psmouse_protocol *proto) { struct input_dev *input_dev = psmouse->dev; input_dev->dev.parent = &psmouse->ps2dev.serio->dev; input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); - input_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | - BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); + input_dev->keybit[BIT_WORD(BTN_MOUSE)] = + BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT); input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); psmouse->set_rate = psmouse_set_rate; @@ -1209,8 +1226,7 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, const struct psmouse return -1; psmouse->type = proto->type; - } - else + } else psmouse->type = psmouse_extensions(psmouse, psmouse_max_proto, true); diff --git a/drivers/input/mouse/sentelic.c b/drivers/input/mouse/sentelic.c index f84cbd9..77b9fd0 100644 --- a/drivers/input/mouse/sentelic.c +++ b/drivers/input/mouse/sentelic.c @@ -836,6 +836,7 @@ int fsp_init(struct psmouse *psmouse) priv->flags |= FSPDRV_FLAG_EN_OPC; /* Set up various supported input event bits */ + __set_bit(BTN_MIDDLE, psmouse->dev->keybit); __set_bit(BTN_BACK, psmouse->dev->keybit); __set_bit(BTN_FORWARD, psmouse->dev->keybit); __set_bit(REL_WHEEL, psmouse->dev->relbit); diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c index e354362..63d4a67 100644 --- a/drivers/input/mouse/trackpoint.c +++ b/drivers/input/mouse/trackpoint.c @@ -284,7 +284,6 @@ static int trackpoint_reconnect(struct psmouse *psmouse) int trackpoint_detect(struct psmouse *psmouse, bool set_properties) { - struct trackpoint_data *priv; struct ps2dev *ps2dev = &psmouse->ps2dev; unsigned char firmware_id; unsigned char button_info; @@ -301,8 +300,8 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties) button_info = 0; } - psmouse->private = priv = kzalloc(sizeof(struct trackpoint_data), GFP_KERNEL); - if (!priv) + psmouse->private = kzalloc(sizeof(struct trackpoint_data), GFP_KERNEL); + if (!psmouse->private) return -1; psmouse->vendor = "IBM"; @@ -311,7 +310,10 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties) psmouse->reconnect = trackpoint_reconnect; psmouse->disconnect = trackpoint_disconnect; - trackpoint_defaults(priv); + if ((button_info & 0x0f) >= 3) + __set_bit(BTN_MIDDLE, psmouse->dev->keybit); + + trackpoint_defaults(psmouse->private); trackpoint_sync(psmouse); error = sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group); @@ -319,7 +321,8 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties) printk(KERN_ERR "trackpoint.c: failed to create sysfs attributes, error: %d\n", error); - kfree(priv); + kfree(psmouse->private); + psmouse->private = NULL; return -1; }