mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Henrik Rydberg" <rydberg@euromail.se>
To: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Jiri Kosina <jkosina@suse.cz>, Stephane Chatty <chatty@enac.fr>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/9] HID: multitouch: add support for Nexio 42" panel
Date: Mon, 4 Feb 2013 12:42:26 +0100	[thread overview]
Message-ID: <20130204114226.GB4313@polaris.bitmath.org> (raw)
In-Reply-To: <CAN+gG=FO7boJ7mQefL=JoggNiUS7ea6=W=+g=5fvMzpMB0x5+g@mail.gmail.com>

Hi Benjamin,

> > Why not an index here?
> 
> Just because an index is not sufficient. You need two things: an index
> within the field, and the actual field (a pointer to a struct
> hid_field). Each .value is local to a field, and even if in most of
> the case, the contact count is alone in its field, it would mean to
> take the risk that a new device does not follow this logic.

The field value is passed to process_mt_event() in a fairly
straight-forward fashion, I was imagining that behavior could be
copied somehow.

> So the actual pointer to the contact count value seemed to be the
> shortest way to do it. But it can be easily changed.

Keeping a pointer into the core structure creates unwanted
dependencies to the scope of that value, making an eventual core
refactoring even harder, not to mention trickier to debug. So even
though it looks neat in the code, it pushes the problem forward.

> >> @@ -251,6 +257,9 @@ static ssize_t mt_set_quirks(struct device *dev,
> >>
> >>       td->mtclass.quirks = val;
> >>
> >> +     if (!td->contactcount)
> >> +             td->mtclass.quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE;
> >> +
> >
> > Why override the overrider here?
> 
> This callback is called from the user-space through the sysfs
> attribute. So, it is not called in the same time that the
> mt_post_parse function. This is just to avoid a user setting this
> quirk once the device is up and running leading to a potential oops.

Yes, but the quirk _is_ user modifiable. Hence, the problem lies in
equating the user-modifiable quirk with the branch control of the
program.

> > An index into the the struct actually passed in mt_report() feels safer.
> 
> again, you need to store "field" and "usage->usage_index". Agree, it
> would be safer but it will take more space... :)

If you think the code change is not only correct, but also moves the
whole code base in a good direction, by all means.

> >> @@ -750,11 +765,15 @@ static void mt_post_parse_default_settings(struct mt_device *td)
> >>  static void mt_post_parse(struct mt_device *td)
> >>  {
> >>       struct mt_fields *f = td->fields;
> >> +     struct mt_class *cls = &td->mtclass;
> >>
> >>       if (td->touches_by_report > 0) {
> >>               int field_count_per_touch = f->length / td->touches_by_report;
> >>               td->last_slot_field = f->usages[field_count_per_touch - 1];
> >>       }
> >> +
> >> +     if (!td->contactcount)
> >> +             cls->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE;
> >
> > Since MT_QUIRK_CONTACT_CNT_ACCURATE is a quirk, modifiable by the
> > user, it should probably not validate num_expected in the code. Better
> > use the contact count index or something equivalent for that.
> 
> As when the user changes the quirk, we validate it, this is not required.

True, barring the comments above.

Thanks,
Henrik

  reply	other threads:[~2013-02-04 11:36 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-31 16:22 [PATCH v2 0/9] Support of Nexio 42" and new default class for hid-multitouch Benjamin Tissoires
2013-01-31 16:22 ` [PATCH v2 1/9] HID: core: add "report" hook, called once the report has been parsed Benjamin Tissoires
2013-02-03 12:27   ` Henrik Rydberg
2013-02-04  9:24     ` Benjamin Tissoires
2013-02-04 11:21       ` Henrik Rydberg
2013-02-04  9:34     ` Jiri Kosina
2013-02-04  9:41       ` Benjamin Tissoires
2013-01-31 16:22 ` [PATCH v2 2/9] HID: multitouch: use the callback "report" instead of sequential events Benjamin Tissoires
2013-01-31 16:22 ` [PATCH v2 3/9] HID: multitouch: add support for Nexio 42" panel Benjamin Tissoires
2013-02-03 13:00   ` Henrik Rydberg
2013-02-04  9:36     ` Benjamin Tissoires
2013-02-04 11:42       ` Henrik Rydberg [this message]
2013-02-04 13:42         ` Benjamin Tissoires
2013-01-31 16:22 ` [PATCH v2 4/9] HID: multitouch: fix Win8 protocol for Sharp like devices Benjamin Tissoires
2013-01-31 16:22 ` [PATCH v2 5/9] HID: multitouch: ensure that serial devices make no use of contact count Benjamin Tissoires
2013-01-31 16:22 ` [PATCH v2 6/9] HID: multitouch: fix protocol for Sitronix 1403:5001 Benjamin Tissoires
2013-01-31 16:22 ` [PATCH v2 7/9] HID: multitouch: fix protocol for Cando 2087:0a02 Benjamin Tissoires
2013-01-31 16:22 ` [PATCH v2 8/9] HID: multitouch: fix protocol for Elo panels Benjamin Tissoires
2013-01-31 16:22 ` [PATCH v2 9/9] HID: multitouch: make MT_CLS_ALWAYS_TRUE the new default class Benjamin Tissoires
2013-02-03 13:07 ` [PATCH v2 0/9] Support of Nexio 42" and new default class for hid-multitouch Henrik Rydberg
2013-02-04  9:38   ` Benjamin Tissoires
2013-02-04 11:54     ` Henrik Rydberg
2013-02-05 11:13       ` Jiri Kosina
2013-02-06 11:04         ` Benjamin Tissoires
2013-02-06 13:11           ` Jiri Kosina
2013-02-06 13:28             ` Benjamin Tissoires
2013-02-06 13:31               ` 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=20130204114226.GB4313@polaris.bitmath.org \
    --to=rydberg@euromail.se \
    --cc=benjamin.tissoires@gmail.com \
    --cc=chatty@enac.fr \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®