From patchwork Fri Mar 11 23:49:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriele Mazzotta X-Patchwork-Id: 8570481 Return-Path: X-Original-To: patchwork-platform-driver-x86@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AC3E7C0553 for ; Fri, 11 Mar 2016 23:50:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B15832034B for ; Fri, 11 Mar 2016 23:50:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C459B20260 for ; Fri, 11 Mar 2016 23:50:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751562AbcCKXuD (ORCPT ); Fri, 11 Mar 2016 18:50:03 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36517 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751407AbcCKXuC (ORCPT ); Fri, 11 Mar 2016 18:50:02 -0500 Received: by mail-wm0-f68.google.com with SMTP id l68so5004679wml.3; Fri, 11 Mar 2016 15:50:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=bWTKlfjIbxsP1tfOD8P2HhymJPU+4SHdXlFR5566P4o=; b=l0rYdsz72bZ8sBzxUijG7cSg1hPkL383N+R9DUbPQNqqNHm+QQnmC6e1+ZWeTn+apa MRBXh0xOeC+Ru+VyVRSBsUgoLoiVEQhvCtXRqHooMu9jWuFauXysK/jmbsL5rdNGCldt 2fqvRbLlWvKZb7q2R64ILpbElWJeaWpx0MLcCUR0V/QI1xTSD2q4U03xUZlhqTZZ9I4R XQQpnqaf3TSu6qhFXRvwb9Gh11CWhYwoCRVkcNVC503Ri/7CF4nWukRtUJmU/a4r0xJq 640Sx/vdIEU5LXNlqQbKmj+fJgiGoThW8g7s6sGAb6JCLLOQh3+1t4NfksqOJ12FFDCg dy2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=bWTKlfjIbxsP1tfOD8P2HhymJPU+4SHdXlFR5566P4o=; b=GaXoMTr8z62e/ddAAL0dSVLvsu5OZsq5ywrHd+m74yNBDfS/MijD5//7Qno45CwOsq buQkepWYGGjpppNqL/A163nIhGUVELW6Pkl4DTFS+j5HfdAT0xaLUd9NUV5kyI2eFid2 qoaW2xqGKXCjqUjN+lv/1RAdKfuOOwgu8l3q+gX+wHLSuPg+PlmJbntJ9WIKuxoGfzfT a3a0lFumYMT6Qwj0FD9Fgmj1kQNSyCjCrmlI9wKrcOEMvPI77khb1FQOOsCLHBfMuQRs y/WoZxdMXc6ZnThSdDDMyzV4e8fIrJB7sO3OO3ZVn9GY/VNi0ctRUnsrK1oXogrIWzt+ d0Lw== X-Gm-Message-State: AD7BkJKxpdHcxhC01nO9n1f9DMr2G4yA2SftS/zCCJBQEqBL2qakHMUqod8Iq6XbkKF1uQ== X-Received: by 10.28.50.133 with SMTP id y127mr5321636wmy.4.1457740200728; Fri, 11 Mar 2016 15:50:00 -0800 (PST) Received: from xps13.homenet (2-235-140-64.ip228.fastwebnet.it. [2.235.140.64]) by smtp.gmail.com with ESMTPSA id y62sm4461385wmg.12.2016.03.11.15.49.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Mar 2016 15:50:00 -0800 (PST) From: Gabriele Mazzotta To: dvhart@infradead.org Cc: Jared_Dominguez@dell.com, platform-driver-x86@vger.kernel.org, rjw@rjwysocki.net, alex.hung@canonical.com, arvidjaar@gmail.com, linux-kernel@vger.kernel.org, Gabriele Mazzotta Subject: [PATCH v2] dell-rbtn: Ignore ACPI notifications if device is suspended Date: Sat, 12 Mar 2016 00:49:35 +0100 Message-Id: <1457740175-8327-1-git-send-email-gabriele.mzt@gmail.com> X-Mailer: git-send-email 2.7.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some BIOSes unconditionally send an ACPI notification to RBTN when the system is resuming from suspend. This makes dell-rbtn send an input event to userspace as if a function key was pressed. Prevent this by ignoring all the notifications received while the device is suspended. Link: https://bugzilla.kernel.org/show_bug.cgi?id=106031 Signed-off-by: Gabriele Mazzotta Tested-by: Alex Hung Tested-By: Andrei Borzenkov --- drivers/platform/x86/dell-rbtn.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/platform/x86/dell-rbtn.c b/drivers/platform/x86/dell-rbtn.c index cd410e3..56b0da7 100644 --- a/drivers/platform/x86/dell-rbtn.c +++ b/drivers/platform/x86/dell-rbtn.c @@ -28,6 +28,7 @@ struct rbtn_data { enum rbtn_type type; struct rfkill *rfkill; struct input_dev *input_dev; + bool suspended; }; @@ -220,9 +221,44 @@ static const struct acpi_device_id rbtn_ids[] = { { "", 0 }, }; +#ifdef CONFIG_PM_SLEEP +static void ACPI_SYSTEM_XFACE rbtn_acpi_clear_flag(void *context) +{ + struct rbtn_data *rbtn_data = context; + + rbtn_data->suspended = false; +} + +static int rbtn_suspend(struct device *dev) +{ + struct acpi_device *device = to_acpi_device(dev); + struct rbtn_data *rbtn_data = acpi_driver_data(device); + + rbtn_data->suspended = true; + + return 0; +} + +static int rbtn_resume(struct device *dev) +{ + struct acpi_device *device = to_acpi_device(dev); + struct rbtn_data *rbtn_data = acpi_driver_data(device); + acpi_status status; + + status = acpi_os_execute(OSL_NOTIFY_HANDLER, + rbtn_acpi_clear_flag, rbtn_data); + if (ACPI_FAILURE(status)) + rbtn_data->suspended = false; + + return 0; +} +#endif +static SIMPLE_DEV_PM_OPS(rbtn_pm_ops, rbtn_suspend, rbtn_resume); + static struct acpi_driver rbtn_driver = { .name = "dell-rbtn", .ids = rbtn_ids, + .drv.pm = &rbtn_pm_ops, .ops = { .add = rbtn_add, .remove = rbtn_remove, @@ -384,6 +420,11 @@ static void rbtn_notify(struct acpi_device *device, u32 event) { struct rbtn_data *rbtn_data = device->driver_data; + if (rbtn_data->suspended) { + dev_dbg(&device->dev, "ACPI notification ignored\n"); + return; + } + if (event != 0x80) { dev_info(&device->dev, "Received unknown event (0x%x)\n", event);