Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11175218ybi; Thu, 25 Jul 2019 11:16:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjlF87+hkEOSmvlUe2cLyoZJJ3tfIlGWbrjmUaEH7FmSzYgiyOxPJJFK1pyuuqi7ERC7lf X-Received: by 2002:a63:6f81:: with SMTP id k123mr89216469pgc.12.1564078593054; Thu, 25 Jul 2019 11:16:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564078593; cv=none; d=google.com; s=arc-20160816; b=L7mIo6rN/p7lJFQ4BqH1N/F3OKevOtzKXiqFyx8IuuQZ1FbqrRcsX6UGe0hY5egvbu 1X/PaITqARcR0haK20UFaghG2uxo8KgWfpWCotSNWKKZfMxg0J1hwSIwXbadincAZZv7 93DcAWGfZeoi0oYbve7msI3tmQaZcikYuAG0BKpc3unaQJfF+wVkrUCT51iWlBF/ZVyT UnIhxBGmPbCWangDRRzObTUpGtrksi5raeAAEwI5Ziz3ahPkY4fKL9/zHu3+D0LlYeLX dmmsnbEk3yKrQYCROjVCWd/suiF2XvCFEWpNmT6hQkSKnJeMoaX4t90M86AfuCveLGSF xlXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=TpXeI3bjGZJFrAoMRGWEMRsLJE/ZUctqhpPZgA4Uju4=; b=mC1DUQHZom8KZkdg990qEAvROuSD2xVbshlUsfkR1brzJ+bl7fY7HneGweJaVLwp+k 7tIkM9SJ412q0tmr3aDxHQq8+1PtuohzYmXplZXr8CyEGmJwl5KXvKMbMQe5idmDZCOt e88JPoqz9TOQMaBHyZRGSJqxWVV2osfLAUh6wz/uPz+VLndguyUWwIUQH8L3op58IUCZ /qB/gCCC0tntCOL3dGp+bjvI2wBBduc+TfvUB1DZj0X/TqwDiSe3exWgdnBsX7Oi0XjN KOt7eMrvHlrxXESTRfIVfsI4ALxzhyIeqYLZvfYfj0TKNpsEBryHhMEsRlo2A1OrPgrt S46w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ok+ytzS/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c4si18534054pfn.71.2019.07.25.11.16.17; Thu, 25 Jul 2019 11:16:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ok+ytzS/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727232AbfGYR6G (ORCPT + 99 others); Thu, 25 Jul 2019 13:58:06 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:46207 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726673AbfGYR6F (ORCPT ); Thu, 25 Jul 2019 13:58:05 -0400 Received: by mail-pl1-f195.google.com with SMTP id c2so23668067plz.13; Thu, 25 Jul 2019 10:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TpXeI3bjGZJFrAoMRGWEMRsLJE/ZUctqhpPZgA4Uju4=; b=ok+ytzS/Q9CbY/1VOtr6oEyeKil7vtncL3AnGuH9fdCXnD2A3GhbiqokFNplhJe3G/ URl/lfz/oqLFXBH1zlNAzZl+er5dJT4I0aDzQ334dCuaHSP6RYp5i51mgT8dOvggKnH4 58xT2Kt0AH2DICErB3525JLaUXiMmDdKIZhij64A0D6ESK/QbKu2cfMf/hGLml3RMAKX 72hrZ1d/ATtOmyfTyg0iaEIwOyoLXfNsWa57EYWC0VjAQ7/37np0/o+omNVxxi5cpY9W r7HEh47aN1eWyA4lIoY+by12qXRtCcuhqdC+uLDYxKFrbIohVL7qaoYMspwy7zRKK4tM bFnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TpXeI3bjGZJFrAoMRGWEMRsLJE/ZUctqhpPZgA4Uju4=; b=fKQpVDrYJUuTCrb1s6auTI8p/lQez5/Qrjuzv3/yVDvSgzDS6AqyN1DkIwf3siSxPY bTK3TT0ijI5zqh2LvbrVmho6UQ7kGUDeIckkFuZuxulZ+wRO3zBvX4pR0WB8bbKEedLX rK10FkZWmDug2Z2Zd8Kv1MwXnHAiYlD78ISi3TXIbEu/to568SAV+2Xc+hEOngkatgmT J+IgVVvFDeEqItclDJWysVXu1oSAEanO+PrbSQoaVhd5dvwPyCIbCVubKQo/02THOppm GcQziTs/SrcFAqYumgVG+U179J2AqivWJvw37ev03EYAd4SHXhWq0Nb6grCgvnZA6AMP RP2w== X-Gm-Message-State: APjAAAU/huuFApT5jqHYOj366NOeVIJS8XehMAnwy38r2VGl65C/HS/c SKvvPPwyisvjAz38KgLWdNvPingl81cododNtkY= X-Received: by 2002:a17:902:694a:: with SMTP id k10mr91300116plt.255.1564077485133; Thu, 25 Jul 2019 10:58:05 -0700 (PDT) MIME-Version: 1.0 References: <20190720150511.95076-1-luzmaximilian@gmail.com> <20190720150511.95076-2-luzmaximilian@gmail.com> In-Reply-To: <20190720150511.95076-2-luzmaximilian@gmail.com> From: Andy Shevchenko Date: Thu, 25 Jul 2019 20:57:53 +0300 Message-ID: Subject: Re: [PATCH v3 1/2] platform/x86: surfacepro3_button: Fix device check To: Maximilian Luz Cc: Linux Kernel Mailing List , linux-input , Platform Driver , Dmitry Torokhov , Hans de Goede , Chen Yu , Darren Hart , Andy Shevchenko , Benjamin Tissoires Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 20, 2019 at 6:05 PM Maximilian Luz wrote: > > Do not use the surfacepro3_button driver on newer Microsoft Surface > models, only use it on the Surface Pro 3 and 4. Newer models (5th, 6th > and possibly future generations) use the same device as the Surface Pro > 4 to represent their volume and power buttons (MSHW0040), but their > actual implementation is significantly different. This patch ensures > that the surfacepro3_button driver is only used on the Pro 3 and 4 > models, allowing a different driver to bind on other models. > Acked-by: Andy Shevchenko assuming it will go thru Input subsystem. > Signed-off-by: Maximilian Luz > --- > drivers/platform/x86/surfacepro3_button.c | 47 +++++++++++++++++++++++ > 1 file changed, 47 insertions(+) > > diff --git a/drivers/platform/x86/surfacepro3_button.c b/drivers/platform/x86/surfacepro3_button.c > index 47c6d000465a..ec515223f654 100644 > --- a/drivers/platform/x86/surfacepro3_button.c > +++ b/drivers/platform/x86/surfacepro3_button.c > @@ -20,6 +20,12 @@ > #define SURFACE_BUTTON_OBJ_NAME "VGBI" > #define SURFACE_BUTTON_DEVICE_NAME "Surface Pro 3/4 Buttons" > > +#define MSHW0040_DSM_REVISION 0x01 > +#define MSHW0040_DSM_GET_OMPR 0x02 // get OEM Platform Revision > +static const guid_t MSHW0040_DSM_UUID = > + GUID_INIT(0x6fd05c69, 0xcde3, 0x49f4, 0x95, 0xed, 0xab, 0x16, 0x65, > + 0x49, 0x80, 0x35); > + > #define SURFACE_BUTTON_NOTIFY_TABLET_MODE 0xc8 > > #define SURFACE_BUTTON_NOTIFY_PRESS_POWER 0xc6 > @@ -142,6 +148,44 @@ static int surface_button_resume(struct device *dev) > } > #endif > > +/* > + * 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. > + * > + * Returns true if the driver should bind to this device, i.e. the device is > + * either MSWH0028 (Pro 3) or MSHW0040 on a Pro 4 or Book 1. > + */ > +static bool surface_button_check_MSHW0040(struct acpi_device *dev) > +{ > + acpi_handle handle = dev->handle; > + union acpi_object *result; > + u64 oem_platform_rev = 0; // valid revisions are nonzero > + > + // get OEM platform revision > + result = acpi_evaluate_dsm_typed(handle, &MSHW0040_DSM_UUID, > + MSHW0040_DSM_REVISION, > + MSHW0040_DSM_GET_OMPR, > + NULL, ACPI_TYPE_INTEGER); > + > + /* > + * If evaluating the _DSM fails, the method is not present. This means > + * that we have either MSHW0028 or MSHW0040 on Pro 4 or Book 1, so we > + * should use this driver. We use revision 0 indicating it is > + * unavailable. > + */ > + > + 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; > +} > + > + > static int surface_button_add(struct acpi_device *device) > { > struct surface_button *button; > @@ -154,6 +198,9 @@ static int surface_button_add(struct acpi_device *device) > strlen(SURFACE_BUTTON_OBJ_NAME))) > return -ENODEV; > > + if (!surface_button_check_MSHW0040(device)) > + return -ENODEV; > + > button = kzalloc(sizeof(struct surface_button), GFP_KERNEL); > if (!button) > return -ENOMEM; > -- > 2.22.0 > -- With Best Regards, Andy Shevchenko