From patchwork Wed May 31 09:41:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lv Zheng X-Patchwork-Id: 9756457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0728E602CC for ; Wed, 31 May 2017 09:42:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECD43269E2 for ; Wed, 31 May 2017 09:41:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF9C128405; Wed, 31 May 2017 09:41:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BABC728474 for ; Wed, 31 May 2017 09:41:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751070AbdEaJl5 (ORCPT ); Wed, 31 May 2017 05:41:57 -0400 Received: from mga01.intel.com ([192.55.52.88]:56752 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750994AbdEaJl5 (ORCPT ); Wed, 31 May 2017 05:41:57 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 May 2017 02:41:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,422,1491289200"; d="scan'208";a="93835916" Received: from unknown (HELO lvzheng-MOBLsp3.sh.intel.com) ([10.239.159.181]) by orsmga002.jf.intel.com with ESMTP; 31 May 2017 02:41:53 -0700 From: Lv Zheng To: "Rafael J . Wysocki" , "Rafael J . Wysocki" , Len Brown Cc: Lv Zheng , Lv Zheng , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, systemd-devel@lists.freedesktop.org, Benjamin Tissoires , Peter Hutterer Subject: [RFC PATCH v4 1/5] ACPI: button: Add indication of BIOS notification and faked events Date: Wed, 31 May 2017 17:41:50 +0800 Message-Id: <236859123733c251757726cca329ca5b405d1ee8.1496221776.git.lv.zheng@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <2a779ae8c280c968b3237ac4a3d9580df7262a46.1493951798.git.lv.zheng@intel.com> References: <2a779ae8c280c968b3237ac4a3d9580df7262a46.1493951798.git.lv.zheng@intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds a parameter to acpi_lid_notify_state() so that it can act differently against BIOS notification and kernel faked events. Cc: Cc: Benjamin Tissoires Cc: Peter Hutterer Signed-off-by: Lv Zheng --- drivers/acpi/button.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 9ad8cdb..725a15a 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -138,7 +138,8 @@ static int acpi_lid_evaluate_state(struct acpi_device *device) return lid_state ? 1 : 0; } -static int acpi_lid_notify_state(struct acpi_device *device, int state) +static int acpi_lid_notify_state(struct acpi_device *device, + int state, bool is_bios_event) { struct acpi_button *button = acpi_driver_data(device); int ret; @@ -360,7 +361,8 @@ int acpi_lid_open(void) } EXPORT_SYMBOL(acpi_lid_open); -static int acpi_lid_update_state(struct acpi_device *device) +static int acpi_lid_update_state(struct acpi_device *device, + bool is_bios_event) { int state; @@ -368,17 +370,17 @@ static int acpi_lid_update_state(struct acpi_device *device) if (state < 0) return state; - return acpi_lid_notify_state(device, state); + return acpi_lid_notify_state(device, state, is_bios_event); } static void acpi_lid_initialize_state(struct acpi_device *device) { switch (lid_init_state) { case ACPI_BUTTON_LID_INIT_OPEN: - (void)acpi_lid_notify_state(device, 1); + (void)acpi_lid_notify_state(device, 1, false); break; case ACPI_BUTTON_LID_INIT_METHOD: - (void)acpi_lid_update_state(device); + (void)acpi_lid_update_state(device, false); break; case ACPI_BUTTON_LID_INIT_IGNORE: default: @@ -398,7 +400,7 @@ static void acpi_button_notify(struct acpi_device *device, u32 event) case ACPI_BUTTON_NOTIFY_STATUS: input = button->input; if (button->type == ACPI_BUTTON_TYPE_LID) { - acpi_lid_update_state(device); + acpi_lid_update_state(device, true); } else { int keycode;