linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yu Chen <yu.c.chen@intel.com>
To: Maximilian Luz <luzmaximilian@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
	platform-driver-x86@vger.kernel.org,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Hans de Goede <hdegoede@redhat.com>,
	Darren Hart <dvhart@infradead.org>,
	Andy Shevchenko <andy@infradead.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>
Subject: Re: [PATCH v2 1/2] platform: Fix device check for surfacepro3_button
Date: Tue, 2 Jul 2019 09:57:17 +0800	[thread overview]
Message-ID: <20190702015717.GA20346@chenyu-office.sh.intel.com> (raw)
In-Reply-To: <d7e17f54-4c33-fa8d-be03-9e507da8e495@gmail.com>

On Tue, Jul 02, 2019 at 03:33:20AM +0200, Maximilian Luz wrote:
> On 7/2/19 3:25 AM, Maximilian Luz wrote:
> > On 7/2/19 3:14 AM, Yu Chen wrote:
> > > On Tue, Jul 02, 2019 at 02:37:39AM +0200, Maximilian Luz wrote:
> > > > +/*
> > > > + * Surface Pro 4 and Surface Book 2 / Surface Pro 2017 use the same device
> > > > + * ID (MSHW0040) for the power/volume buttons. Make sure this is the right
> > > > + * device by checking for the _DSM method and OEM Platform Revision.
> > > > + */
> > > > +static int surface_button_check_MSHW0040(struct acpi_device *dev)
> > > > +{
> > > > +    acpi_handle handle = dev->handle;
> > > > +    union acpi_object *result;
> > > > +    u64 oem_platform_rev = 0;
> > > > +
> > > > +    // get OEM platform revision
> > > > +    result = acpi_evaluate_dsm_typed(handle, &MSHW0040_DSM_UUID,
> > > > +                     MSHW0040_DSM_REVISION,
> > > > +                     MSHW0040_DSM_GET_OMPR,
> > > > +                     NULL, ACPI_TYPE_INTEGER);
> > > > +
> > > Does it mean, only 5th, 6th and newer platforms have OEM platform revision?
> > > 3rd/4th will get NULL result? Or the opposite?
> > 
> > Correct, from my testing (with limited sample size) and AML code: 5th
> > and 6th generation devices have a non-zero OEM platform revision,
> > whereas 3rd and 4th gen. devices do not have any (i.e. result will be
> > NULL).
> > 
> > > > +    if (result) {
> > > > +        oem_platform_rev = result->integer.value;
> > > > +        ACPI_FREE(result);
> > > > +    }
> > > > +
> > > > +    dev_dbg(&dev->dev, "OEM Platform Revision %llu\n", oem_platform_rev);
> > > > +
> > > > +    return oem_platform_rev == 0 ? 0 : -ENODEV;
> > > if 3rd/4th do not have this oem rev information while 5th/newer have,
> > > why the latter returns NODEV(it actually has this info)?
> > 
> > Since we always expect a non-zero platform revision (for 5th/6th gen.),
> > we can initialize it to zero and use that as "unknown"/"not available".
> > So if it can not be determined, we return NODEV.
> 
> Sorry, small mistake here: If it can be determined (i.e. is 5th or 6th
> gen.) then we return NODEV. Not the other way around.
>
How about using a boolean, according to the function name, if a mshw0040 revison
is detected then returns true other wise false. Other than that,
Acked-by: Chen Yu <yu.c.chen@intel.com>

Best,
Chenyu
> Also to clarify on your last question:
> 
> On 7/2/19 3:14 AM, Yu Chen wrote:
> > >   static int surface_button_add(struct acpi_device *device)
> > >   {
> > >   	struct surface_button *button;
> > > @@ -154,6 +188,10 @@ static int surface_button_add(struct acpi_device *device)
> > >   	    strlen(SURFACE_BUTTON_OBJ_NAME)))
> > >   		return -ENODEV;
> > > +	error = surface_button_check_MSHW0040(device);
> > > +	if (error)
> > > +		return error;
> > > +
> > ditto, 3rd/4th get error=0?
> 
> You are correct.
> 
> Maximilian

  reply	other threads:[~2019-07-02  1:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-02  0:37 [PATCH 0/2] Support for buttons on newer MS Surface devices Maximilian Luz
2019-07-02  0:37 ` [PATCH v2 1/2] platform: Fix device check for surfacepro3_button Maximilian Luz
2019-07-02  1:14   ` Yu Chen
2019-07-02  1:25     ` Maximilian Luz
2019-07-02  1:33       ` Maximilian Luz
2019-07-02  1:57         ` Yu Chen [this message]
2019-07-02  2:04           ` Maximilian Luz
2019-07-18 17:43   ` Andy Shevchenko
2019-07-02  0:37 ` [PATCH v2 2/2] input: soc_button_array for newer surface devices Maximilian Luz
2019-07-04 15:31   ` Maximilian Luz
2019-07-16  7:21   ` Dmitry Torokhov
2019-07-16 18:19     ` Maximilian Luz
2019-07-16 20:18       ` Dmitry Torokhov
2019-07-17 19:23         ` Maximilian Luz
2019-07-02 17:13 ` [PATCH 0/2] Support for buttons on newer MS Surface devices Andy Shevchenko
2019-07-02 17:26   ` Maximilian Luz
2019-07-20 15:15 ` Maximilian Luz

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=20190702015717.GA20346@chenyu-office.sh.intel.com \
    --to=yu.c.chen@intel.com \
    --cc=andy@infradead.org \
    --cc=benjamin.tissoires@redhat.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dvhart@infradead.org \
    --cc=hdegoede@redhat.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luzmaximilian@gmail.com \
    --cc=platform-driver-x86@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).