linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	Thomas Hellstrom <thellstrom@vmware.com>,
	pali.rohar@gmail.com, jckeerthan@gmail.com,
	till2.schaefer@uni-dortmund.de, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/6] Input: psmouse - factor out common protocol probing code
Date: Thu, 3 Dec 2015 09:33:53 +0100	[thread overview]
Message-ID: <565FFE71.4050404@redhat.com> (raw)
In-Reply-To: <20151202191839.GD15531@dtor-ws>

Hi,

On 02-12-15 20:18, Dmitry Torokhov wrote:
> Hi Hans,
>
> On Wed, Dec 02, 2015 at 04:20:48PM +0100, Hans de Goede wrote:
>> Hi,
>>
>> Thanks for splitting out the series, patches 1 - 4 look good to me and are:
>>
>> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
>>
>> I've some comments inline for this one.
>
> Thanks for spending time on reviewing this.
>
>>> @@ -1025,68 +1053,48 @@ static int psmouse_extensions(struct psmouse *psmouse,
>>>   	 * Trackpads.
>>>   	 */
>>>   	if (max_proto > PSMOUSE_IMEX &&
>>> -			cypress_detect(psmouse, set_properties) == 0) {
>>> -		if (IS_ENABLED(CONFIG_MOUSE_PS2_CYPRESS)) {
>>> -			if (cypress_init(psmouse) == 0)
>>> -				return PSMOUSE_CYPRESS;
>>> -
>>> -			/*
>>> -			 * Finger Sensing Pad probe upsets some modules of
>>> -			 * Cypress Trackpad, must avoid Finger Sensing Pad
>>> -			 * probe if Cypress Trackpad device detected.
>>> -			 */
>>> -			return PSMOUSE_PS2;
>>> -		}
>>> -
>>> -		max_proto = PSMOUSE_IMEX;
>>> +	    psmouse_try_protocol(psmouse, PSMOUSE_CYPRESS, &max_proto,
>>> +				 set_properties, true)) {
>>> +		return PSMOUSE_CYPRESS;
>>>   	}
>>
>> The protocols array has the CYPRESS entry wrapped in "#ifdef CONFIG_MOUSE_PS2_CYPRESS"
>> so this bit of the patches changes behavior of the probe order if
>> CONFIG_MOUSE_PS2_CYPRESS is not enabled. Before this patch the max_proto would
>> get limited to PSMOUSE_IMEX, but now the:
>>
>> 	proto = __psmouse_protocol_by_type(type);
>> 	if (!proto)
>> 		return false;
>>
>> Part of psmouse_try_protocol will trigger and then max_proto will stay unmodified.
>>
>> I think this can best be fixed by always including CYPRESS in the proto array,
>> and have init be a stub which always fails when CYPRESS is not actually enabled.
>
> I would not want to do that as that would make cypress be in the list of
> supported protocols whereas it is actually compiled out.
>
> BUT, there is actually no problem, the original code was misleading.
> cypress_detect() is already a stub returning -ENOSYS when
> CONFIG_MOUSE_PS2_CYPRESS is not enabled, so we would never went into
> that "if" body in that case.

Ah, so the whole "if (IS_ENABLED(CONFIG_MOUSE_PS2_CYPRESS))" check in the original
code was not really necessary, I see.

> I'll make a patch cleaning it up, but won't repost the whole series so
> as to not clutter the list.

Ack.

>>>
>>>   	if (max_proto > PSMOUSE_IMEX) {
>>> -		if (psmouse_do_detect(genius_detect,
>>> -				      psmouse, set_properties) == 0)
>>> +		if (psmouse_try_protocol(psmouse, PSMOUSE_GENPS,
>>> +					 &max_proto, set_properties, true))
>>>   			return PSMOUSE_GENPS;
>>>
>>> -		if (psmouse_do_detect(ps2pp_init,
>>> -				      psmouse, set_properties) == 0)
>>> +		if (psmouse_try_protocol(psmouse, PSMOUSE_PS2PP,
>>> +					 &max_proto, set_properties, true))
>>>   			return PSMOUSE_PS2PP;
>>
>> The PS2PP entry in the protocols table has an init function, by passing
>> in true here you are causing this to get called, where as it was not
>> being called before.
>
> No, it has detect function only (but called ps2pp_init), I'll post the
> patch renaming it to ps2pp_detect.

Right, I misread that as it having an init function.

>> p.s.
>>
>> After this change, a whole lot of the code has the form of:
>>
>> 	if (max_proto >= PSMOUSE_FOO &&
>> 	    psmouse_try_protocol(psmouse, ...)) {
>> 		return PSMOUSE_BAR;
>> 	}
>>
>> Maybe you can do a follow-up which makes PSMOUSE_FOO a parameter to
>> psmouse_try_protocol and move the test into psmouse_try_protocol?
>
> I considered it, but some protocols we detect unconditionally and some
> conditionally, passing a parameter woudl somewhat hide it. Plus
> try_protocol() already has a lot of parameters.

Ok.

>> Also you may want to consider to drop the {} around the single return
>> statement most of this code-blocks now have. Maybe best to do
>> this in a followup patch to keep the diff readable.
>
> I like to keep the braces if "if" condition is multi-line to better see
> where condition ends and body starts.

Fair enough, I've no problem with that.

With the above explanations this patch is:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans

  reply	other threads:[~2015-12-03  8:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-29  5:13 [PATCH 0/6] Only probe select protocols on pass through PS/2 prots Dmitry Torokhov
2015-11-29  5:13 ` [PATCH 1/6] Input: psmouse - use switch statement in psmouse_process_byte() Dmitry Torokhov
2015-12-11 11:37   ` Pali Rohár
2015-11-29  5:13 ` [PATCH 2/6] Input: psmouse - fix comment style Dmitry Torokhov
2015-12-11 11:39   ` Pali Rohár
2015-11-29  5:13 ` [PATCH 3/6] Input: psmouse - rearrange Focaltech init code Dmitry Torokhov
2015-12-11 11:44   ` Pali Rohár
2015-11-29  5:13 ` [PATCH 4/6] Input: psmouse - move protocol descriptions around Dmitry Torokhov
2015-12-11 11:46   ` Pali Rohár
2015-11-29  5:13 ` [PATCH 5/6] Input: psmouse - factor out common protocol probing code Dmitry Torokhov
2015-12-02 15:20   ` Hans de Goede
2015-12-02 19:18     ` Dmitry Torokhov
2015-12-03  8:33       ` Hans de Goede [this message]
2015-11-29  5:13 ` [PATCH 6/6] Input: psmouse - limit protocols that we try on passthrough ports Dmitry Torokhov
2015-12-02 15:21   ` Hans de Goede
2015-12-11 11:50   ` Pali Rohár

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=565FFE71.4050404@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jckeerthan@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pali.rohar@gmail.com \
    --cc=thellstrom@vmware.com \
    --cc=till2.schaefer@uni-dortmund.de \
    /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).