From patchwork Thu Mar 30 10:35:01 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: 9653723 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 10D5460350 for ; Thu, 30 Mar 2017 10:38:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F06762857F for ; Thu, 30 Mar 2017 10:38:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E54D828582; Thu, 30 Mar 2017 10:38:29 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable 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 9871A28581 for ; Thu, 30 Mar 2017 10:38:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933656AbdC3KfW (ORCPT ); Thu, 30 Mar 2017 06:35:22 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:35946 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933644AbdC3KfS (ORCPT ); Thu, 30 Mar 2017 06:35:18 -0400 Received: by mail-lf0-f68.google.com with SMTP id n78so4163108lfi.3 for ; Thu, 30 Mar 2017 03:35:17 -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=ilgyVK5Guq7ycPo5b/uviM5E1fzuOaA0DyuLSWwmxCU=; b=JoWTUjU4MiihYXplKFGNiNg7+qchHGo6YG7QQ6hz8yBhoz/dqP0K5lB1pE+CxtoiBx OtnnRzt0AIMz4ozBzuUemKF5u0yMb0VOdDDFwDxGghtUavzEMcWFtN6XQECZfmFvzxmv w70IPF0Km3XT17OFl0bUfq6ZkFnKcVGtr+q/0= 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=ilgyVK5Guq7ycPo5b/uviM5E1fzuOaA0DyuLSWwmxCU=; b=JHdUr6LP7N+vYD9KY8x6VeOerV3s+kvNrXBqEbAOnG/J2X2aR09pTADrGvNAyrFmSa NXrM3I+2rmPCxqXRuUfCVvEGQ6jjxHkDYkFnMYkWPicnirafoVV9A/ZhLblzGfPlm59o wK19jqH3gK/C7Nle1oDwikk/gW25zzCH0awX/oKDXfAU56p32DaoLpqfciSczQ6w/TH+ U9TWaB7LlXmxbzbyODAYzwK4KV9fas+bdmyJkWi6ABqT0LqfMmoBkLbx0swQ1NcUrXyK 4oto5/0XujDMtBqNh0ck8PSQKz59XckTL69X8RfPlHspJX4BhzsPLiY5S45GxV/d49cF PQEw== X-Gm-Message-State: AFeK/H1uhFNbuSGdASDcWzBIwd7XFz3XZTRbnkyssaHD2hrW373Gu4yGml9kBUdN/SN5wA== X-Received: by 10.46.21.13 with SMTP id s13mr1768050ljd.112.1490870116166; Thu, 30 Mar 2017 03:35:16 -0700 (PDT) Received: from ozzy.nask.waw.pl ([2001:a10:160:3::3]) by smtp.googlemail.com with ESMTPSA id x1sm296975lfb.54.2017.03.30.03.35.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Mar 2017 03:35:15 -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 03/11] platform/x86: fujitsu-laptop: merge set_lcd_level_alt() into set_lcd_level() Date: Thu, 30 Mar 2017 12:35:01 +0200 Message-Id: <20170330103509.32509-4-kernel@kempniu.pl> X-Mailer: git-send-email 2.12.1 In-Reply-To: <20170330103509.32509-1-kernel@kempniu.pl> References: <20170330103509.32509-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 Depending on the value of the use_alt_lcd_levels module parameter, one of two functions is used for setting LCD brightness level. These functions are almost identical and only differ in the name of the ACPI method they call. Instead of checking the value of use_alt_lcd_levels at each call site, move that check to set_lcd_level() and get rid of set_lcd_level_alt(). Signed-off-by: Michał Kępień --- drivers/platform/x86/fujitsu-laptop.c | 54 +++++++++++------------------------ 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c index a9520e732c8b..5005400b57bb 100644 --- a/drivers/platform/x86/fujitsu-laptop.c +++ b/drivers/platform/x86/fujitsu-laptop.c @@ -360,41 +360,26 @@ static int set_lcd_level(int level) { acpi_status status = AE_OK; acpi_handle handle = NULL; - - vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBLL [%d]\n", - level); - - if (level < 0 || level >= fujitsu_bl->max_brightness) - return -EINVAL; - - status = acpi_get_handle(fujitsu_bl->acpi_handle, "SBLL", &handle); - if (ACPI_FAILURE(status)) { - vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBLL not present\n"); - return -ENODEV; + char *method; + + switch (use_alt_lcd_levels) { + case 1: + method = "SBL2"; + break; + default: + method = "SBLL"; + break; } - - status = acpi_execute_simple_method(handle, NULL, level); - if (ACPI_FAILURE(status)) - return -ENODEV; - - return 0; -} - -static int set_lcd_level_alt(int level) -{ - acpi_status status = AE_OK; - acpi_handle handle = NULL; - - vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBL2 [%d]\n", - level); + vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via %s [%d]\n", + method, level); if (level < 0 || level >= fujitsu_bl->max_brightness) return -EINVAL; - status = acpi_get_handle(fujitsu_bl->acpi_handle, "SBL2", &handle); + status = acpi_get_handle(fujitsu_bl->acpi_handle, method, &handle); if (ACPI_FAILURE(status)) { - vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBL2 not present\n"); + vdbg_printk(FUJLAPTOP_DBG_ERROR, "%s not present\n", method); return -ENODEV; } @@ -463,10 +448,7 @@ static int bl_update_status(struct backlight_device *b) "Unable to adjust backlight power, error code %i\n", ret); - if (use_alt_lcd_levels) - ret = set_lcd_level_alt(b->props.brightness); - else - ret = set_lcd_level(b->props.brightness); + ret = set_lcd_level(b->props.brightness); if (ret != 0) vdbg_printk(FUJLAPTOP_DBG_ERROR, "Unable to adjust LCD brightness, error code %i\n", @@ -679,12 +661,8 @@ static void acpi_fujitsu_bl_notify(struct acpi_device *device, u32 event) if (oldb == newb) return; - if (disable_brightness_adjust != 1) { - if (use_alt_lcd_levels) - set_lcd_level_alt(newb); - else - set_lcd_level(newb); - } + if (disable_brightness_adjust != 1) + set_lcd_level(newb); sparse_keymap_report_event(input, oldb < newb, 1, true); }