Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2738818ybi; Mon, 1 Jul 2019 18:05:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxBSbIEkHrouksDBzntxD4JHfXp+x84hGy6Vj/NxWpLOFGg81IYBbptCJI4FDVVY+FG+A1 X-Received: by 2002:a17:90a:9bca:: with SMTP id b10mr2413499pjw.90.1562029501866; Mon, 01 Jul 2019 18:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562029501; cv=none; d=google.com; s=arc-20160816; b=ztacF8WOpeBUrFqJWqj9zWjSvqnkZ/Rk+P2OyfVOxW6+KvOtwupPuHUrhbAyEXh8p7 o+ZNCa2QRTo49goanJrx0Mdh1LQorakklX8FLsZPKevZ7ZKjEefxGM1XrJ6wM+TRD6Rc ROmdygn17Mt84qJOvvMvfvTOssotfuS1vh2FpiCFPMhHdx5N/etse2tCdMwpM25h3/6T napcsIew8oJmhdXVtbC1SJGjtJDqtYSDPnGvX9zP8BOntW4ykzXYF46JVRY06TOAeKJW SrQobILUr/7ly2HfQcF+t6XvdqSrZyBuDODeg6Brr3d+8qFiNbwP8Y8pM0EAc3Jwplqz pl7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=+qYcy3EbXYrZ/3QkQvpdlYTJYigiz4jq1ah5auCyDMs=; b=e5IBury5aFOUp16nn90xDm23EqQeDW4aoag85M03dXsBGtgUNA0ib2ltSwSiSgDHYX h/7aBXNR9AnvTe6mRR6KUnw3CBkCXH7sp7E86d1HaYLvKurVKTGSJUVcXKAa/MJ3IE+L sSennDFDR1+GuRnTqLThPsid/KVw1BqKq9UGreI8cQnRuwYWtHnrKHvPjvkKew2dVdz2 FZ6+Rw1LiGB7/kHEOWuYtAWc7GGqQVv2Gn7I1NdgpCBCZ4jZhVs8VQ3p8ZSWphJEdSYX dk7pIi/tR/aUGHtj5MUO/B/LeUO5qei1dfkQMarcdplZDg2zDLv6WS4dEoR5xPDPZ+AP cPTA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f7si10736906pgv.105.2019.07.01.18.04.46; Mon, 01 Jul 2019 18:05:01 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727132AbfGBBEV (ORCPT + 99 others); Mon, 1 Jul 2019 21:04:21 -0400 Received: from mga05.intel.com ([192.55.52.43]:58523 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727047AbfGBBEV (ORCPT ); Mon, 1 Jul 2019 21:04:21 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Jul 2019 18:04:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,441,1557212400"; d="scan'208";a="184379133" Received: from chenyu-office.sh.intel.com ([10.239.158.163]) by fmsmga001.fm.intel.com with ESMTP; 01 Jul 2019 18:04:18 -0700 Date: Tue, 2 Jul 2019 09:14:44 +0800 From: Yu Chen To: Maximilian Luz Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, platform-driver-x86@vger.kernel.org, Dmitry Torokhov , Hans de Goede , Darren Hart , Andy Shevchenko , Benjamin Tissoires Subject: Re: [PATCH v2 1/2] platform: Fix device check for surfacepro3_button Message-ID: <20190702011443.GA19902@chenyu-office.sh.intel.com> References: <20190702003740.75970-1-luzmaximilian@gmail.com> <20190702003740.75970-2-luzmaximilian@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190702003740.75970-2-luzmaximilian@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Jul 02, 2019 at 02:37:39AM +0200, 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 > acutal 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. > This method overall looks ok to me. > Signed-off-by: Maximilian Luz > --- > drivers/platform/x86/surfacepro3_button.c | 38 +++++++++++++++++++++++ > 1 file changed, 38 insertions(+) > > diff --git a/drivers/platform/x86/surfacepro3_button.c b/drivers/platform/x86/surfacepro3_button.c > index 47c6d000465a..0e2c7dfafd9f 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,34 @@ 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. > + */ > +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? > + 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)? > +} > + > + > 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? > button = kzalloc(sizeof(struct surface_button), GFP_KERNEL); > if (!button) > return -ENOMEM; > -- > 2.22.0 > Best, Yu