From patchwork Wed Apr 5 06:49:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBLxJlwaWXFhA==?= X-Patchwork-Id: 9663075 X-Patchwork-Delegate: dvhart@infradead.org 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 08B3960365 for ; Wed, 5 Apr 2017 06:52:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDBD828338 for ; Wed, 5 Apr 2017 06:52:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2A95284F8; Wed, 5 Apr 2017 06:52:21 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 6F68C284FE for ; Wed, 5 Apr 2017 06:52:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753759AbdDEGwT (ORCPT ); Wed, 5 Apr 2017 02:52:19 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:34905 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754251AbdDEGtT (ORCPT ); Wed, 5 Apr 2017 02:49:19 -0400 Received: by mail-lf0-f67.google.com with SMTP id v2so355245lfi.2 for ; Tue, 04 Apr 2017 23:49:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kempniu.pl; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kMVq00amCbsWftB7LzS8j96OkRGhylOeJ9f3gwO1NrA=; b=tUA7dux4N4Lr8v3pI5iHmup49aXl0FUUmneZwUNIEiDaMsN55MxksntpADJH+yQh1d A1uXIVRCL/IH4jucKxRVhOhtpgB0sVNRMBrH3YTbAH5195SKW57bcGsermFGdhLEoqe/ 8K2GZjz+irrMW0I5u643Xqhf9Grtw42tlaIs8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kMVq00amCbsWftB7LzS8j96OkRGhylOeJ9f3gwO1NrA=; b=SaA3wYXkxr24T0K2o7meFXWm9hlpNMoAP9V8ttLy1ohz9OCm+dgBBrAJ9qlaYn1RGl /ZUqPZ3cuz7dR0+b65VplRitloEC94nx53+5EL/+mN6mCV7xuz4XgrlORTdRwbiDraB9 DGRSxKB6Vlih+IWoiqYqmDfXlacrlicsNAwRMCL3icJPZweT5nH/OO9Zo9vZK6W9579n McDF51Kpo0MnJaQfB6c4X6tqmUK7PsCWzZUlbIWPdkjvDUyvOeUUJ7JMZ203WOHi6HPF UxbD0dO8OSym88XkYvgJ4bICBsn8SCAPCuXUbd7YDBfhscKv7rMCyDxe6bqAVsNXA4si 4Hkw== X-Gm-Message-State: AFeK/H0ofsWs0KMgAKenUa5JRXJIsDGmwRP1Q5fUHLbzU9iuBF3WSyQ9khZPQNlvsfkb4A== X-Received: by 10.46.87.89 with SMTP id r25mr8005965ljd.31.1491374957786; Tue, 04 Apr 2017 23:49:17 -0700 (PDT) Received: from ozzy.nask.waw.pl ([2001:a10:160:3::3]) by smtp.googlemail.com with ESMTPSA id o91sm3619921lfg.1.2017.04.04.23.49.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Apr 2017 23:49:17 -0700 (PDT) From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= To: Jonathan Woithe , Darren Hart , Andy Shevchenko Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 05/11] platform/x86: fujitsu-laptop: sync brightness in set_lcd_level() Date: Wed, 5 Apr 2017 08:49:04 +0200 Message-Id: <20170405064910.3162-6-kernel@kempniu.pl> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170405064910.3162-1-kernel@kempniu.pl> References: <20170405064910.3162-1-kernel@kempniu.pl> MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When using brightness keys and backlight device's sysfs interface alternately, an incorrect input event might be generated for a brightness key press. Consider the following sequence of events: 1. Set backlight brightness to 6 using brightness keys. 2. Write 4 to /sys/class/backlight/fujitsu-laptop/brightness. 3. Press the "brightness up" key. The input event generated in this scenario would be KEY_BRIGHTNESSDOWN, because before step 3 brightness_level would still be at 6. As the new brightness level is established using GBLL, it would evaluate to 5 (SBLL/SBL2 sets it to 4 in step 2 and pressing the "brightness up" key increases it by 1). This in turn would cause acpi_fujitsu_bl_notify() to observe a 6 -> 5 change, i.e. a decrease in brightness, while screen brightness would in fact be increased. Fix this by updating brightness_level in set_lcd_level. Signed-off-by: Michał Kępień --- drivers/platform/x86/fujitsu-laptop.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c index 6d4a2a36716b..b019060d6dc4 100644 --- a/drivers/platform/x86/fujitsu-laptop.c +++ b/drivers/platform/x86/fujitsu-laptop.c @@ -384,6 +384,8 @@ static int set_lcd_level(int level) return -ENODEV; } + fujitsu_bl->brightness_level = level; + return 0; }