Linux Input Archive on lore.kernel.org
 help / color / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Jiri Kosina <jkosina@suse.cz>
Cc: Gary Stein <lordcnidarian@gmail.com>,
	linux-input@vger.kernel.org,
	Jussi Kivilinna <jussi.kivilinna@mbnet.fi>,
	Anssi Hannula <anssi.hannula@gmail.com>
Subject: Re: [PATCH] Add Driver for Logitech Flight System G940
Date: Sat, 19 Dec 2009 00:53:54 -0800
Message-ID: <20091219085353.GA2782@core.coreip.homeip.net> (raw)
In-Reply-To: <alpine.LNX.2.00.0912151451060.3755@pobox.suse.cz>

On Tue, Dec 15, 2009 at 02:53:26PM +0100, Jiri Kosina wrote:
> On Thu, 10 Dec 2009, Gary Stein wrote:
> 
> > This is a cleaned up and updated driver for the G940.  I followed most 
> > of the checkpatch notes except for some of the 80 column stuff, the 
> > sections of where most of that code is hid-core.c also doesn't seem to 
> > care about it.
> 
> Yup, that's OK, thanks.
> 
> Please also fix up a few comments on various places which are wrongly 
> intended, such as
> 
> > +       /* maxusage should be 63, maximum fields
> > +               likely a better way to ensure this data is clean */
> 
> which should rather be in a format more similar to
> 
> 	/* 
> 	 * first comment line
> 	 * second comment line
> 	 */
> 
> > However, also in this code is the (int) cast fix that I send before to 
> > linux-kernel in ff-memless.  Without this, my driver or the normal 
> > logitech driver for other sticks seems to work for me.
> 
> Dmitry, will you pick that one up for your tree? 
> 

Yes, but not quite like that - I think there may be more issues with
'gain' being unsigned int. How about below instead?

[Some more people added to CC.]

-- 
Dmitry

Input: ff-memless - another fix for signed to unsigned overflow

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>

The commit 9e68177ef93b2f34eee5a1e1707bceef4b9ba69c changed 'gain' from
signed to unsigned to fix an issue with rumble effect calculation, however
it introduced problems when calculating constant effects. Having 'gain'
being unsigned int was an unfortunate choice since it dominates all
implicit type conversions causing everything to be treated as unsigned
int.

Let's change it back to signed int and simply add proper casts to rumble
effect calculations.

Reported-by: Gary Stein <lordcnidarian@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/input/ff-memless.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)


diff --git a/drivers/input/ff-memless.c b/drivers/input/ff-memless.c
index b483b29..768a9a2 100644
--- a/drivers/input/ff-memless.c
+++ b/drivers/input/ff-memless.c
@@ -225,7 +225,7 @@ static int get_compatible_type(struct ff_device *ff, int effect_type)
  */
 static void ml_combine_effects(struct ff_effect *effect,
 			       struct ml_effect_state *state,
-			       unsigned int gain)
+			       int gain)
 {
 	struct ff_effect *new = state->effect;
 	unsigned int strong, weak, i;
@@ -252,8 +252,8 @@ static void ml_combine_effects(struct ff_effect *effect,
 		break;
 
 	case FF_RUMBLE:
-		strong = new->u.rumble.strong_magnitude * gain / 0xffff;
-		weak = new->u.rumble.weak_magnitude * gain / 0xffff;
+		strong = (u32)new->u.rumble.strong_magnitude * gain / 0xffff;
+		weak = (u32)new->u.rumble.weak_magnitude * gain / 0xffff;
 		effect->u.rumble.strong_magnitude =
 			min(strong + effect->u.rumble.strong_magnitude,
 			    0xffffU);

  reply index

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-08 22:39 Gary Stein
2009-12-09  6:36 ` Dmitry Torokhov
2009-12-09 13:24 ` Jiri Kosina
2009-12-10 17:47   ` Gary Stein
2009-12-10 18:12     ` Dmitry Torokhov
2009-12-10 20:37   ` Gary Stein
2009-12-15 13:53     ` Jiri Kosina
2009-12-19  8:53       ` Dmitry Torokhov [this message]
2009-12-25  0:17         ` Anssi Hannula
2009-12-23 13:23       ` Jiri Kosina

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=20091219085353.GA2782@core.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=anssi.hannula@gmail.com \
    --cc=jkosina@suse.cz \
    --cc=jussi.kivilinna@mbnet.fi \
    --cc=linux-input@vger.kernel.org \
    --cc=lordcnidarian@gmail.com \
    /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

Linux Input Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-input/0 linux-input/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-input linux-input/ https://lore.kernel.org/linux-input \
		linux-input@vger.kernel.org
	public-inbox-index linux-input

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-input


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git