linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Benjamin Tissoires <bentiss@kernel.org>
Cc: Jiri Kosina <jikos@kernel.org>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] HID: multitouch: make mt_set_mode() less cryptic
Date: Mon, 28 Oct 2024 12:04:36 -0700	[thread overview]
Message-ID: <Zx_gRK9siGDtJ3PN@google.com> (raw)
In-Reply-To: <nqj6hx3yhw3q5e5qtyqdxwpxt2xe3u45vibjcjqmpmsvs7opq3@snxzjynjpwyp>

On Mon, Oct 28, 2024 at 04:47:55PM +0100, Benjamin Tissoires wrote:
> On Oct 25 2024, Dmitry Torokhov wrote:
> > mt_set_mode() accepts 2 boolean switches indicating whether the device
> > (if it follows Windows Precision Touchpad specification) should report
> > hardware buttons and/or surface contacts. For a casual reader it is
> > completely not clear, as they look at the call site, which exact mode
> > is being requested.
> > 
> > Define report_mode enum and change mt_set_mode() to accept is as
> > an argument instead. This allows to write:
> > 
> > 	mt_set_modes(hdev, HID_LATENCY_NORMAL, TOUCHPAD_REPORT_ALL);
> > 
> > or
> > 
> > 	mt_set_modes(hdev, HID_LATENCY_HIGH, TOUCHPAD_REPORT_BUTTONS);
> > 
> > which makes intent much more clear.
> > 
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> >  drivers/hid/hid-multitouch.c | 29 +++++++++++++++++------------
> >  1 file changed, 17 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
> > index 99812c0f830b..e4bb2fb5596d 100644
> > --- a/drivers/hid/hid-multitouch.c
> > +++ b/drivers/hid/hid-multitouch.c
> > @@ -83,6 +83,13 @@ enum latency_mode {
> >  	HID_LATENCY_HIGH = 1,
> >  };
> >  
> > +enum report_mode {
> > +	TOUCHPAD_REPORT_NONE = 0,
> > +	TOUCHPAD_REPORT_BUTTONS = 1,
> > +	TOUCHPAD_REPORT_CONTACTS = 2,
> 
> Maybe to be more obvious, BIT(0) and BIT(1) for the 2 values above?
> 
> I'm just concerned that someone adds "3" if we ever need to add a new
> value.

Right, I'll change it.

> 
> > +	TOUCHPAD_REPORT_ALL = TOUCHPAD_REPORT_BUTTONS | TOUCHPAD_REPORT_CONTACTS,
> > +};
> > +
> >  #define MT_IO_FLAGS_RUNNING		0
> >  #define MT_IO_FLAGS_ACTIVE_SLOTS	1
> >  #define MT_IO_FLAGS_PENDING_SLOTS	2
> > @@ -1486,8 +1493,7 @@ static bool mt_need_to_apply_feature(struct hid_device *hdev,
> >  				     struct hid_field *field,
> >  				     struct hid_usage *usage,
> >  				     enum latency_mode latency,
> > -				     bool surface_switch,
> > -				     bool button_switch,
> > +				     enum report_mode report_mode,
> >  				     bool *inputmode_found)
> >  {
> >  	struct mt_device *td = hid_get_drvdata(hdev);
> > @@ -1542,11 +1548,11 @@ static bool mt_need_to_apply_feature(struct hid_device *hdev,
> >  		return true;
> >  
> >  	case HID_DG_SURFACESWITCH:
> > -		field->value[index] = surface_switch;
> > +		field->value[index] = report_mode & TOUCHPAD_REPORT_CONTACTS;
> 
> Just to be on the safe side:
> !!(report_mode & TOUCHPAD_REPORT_CONTACTS);

Oh, yes, that makes sense. I'll send an updated patch in a minute.

Thanks.

-- 
Dmitry

      reply	other threads:[~2024-10-28 19:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-25 22:32 [PATCH] HID: multitouch: make mt_set_mode() less cryptic Dmitry Torokhov
2024-10-28 15:47 ` Benjamin Tissoires
2024-10-28 19:04   ` Dmitry Torokhov [this message]

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=Zx_gRK9siGDtJ3PN@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=bentiss@kernel.org \
    --cc=jikos@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).