From patchwork Wed Apr 5 06:49:02 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: 9663071 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 CFF8460364 for ; Wed, 5 Apr 2017 06:52:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF92B28509 for ; Wed, 5 Apr 2017 06:52:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B445D28338; 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=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 4F878284F8 for ; Wed, 5 Apr 2017 06:52:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754299AbdDEGtT (ORCPT ); Wed, 5 Apr 2017 02:49:19 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:36810 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754137AbdDEGtR (ORCPT ); Wed, 5 Apr 2017 02:49:17 -0400 Received: by mail-lf0-f66.google.com with SMTP id n78so353443lfi.3 for ; Tue, 04 Apr 2017 23:49: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=NmAXs03B1u11PSzI643X19OJ/Xsc/vsbhzNPHSS5ROc=; b=NkWG29B7gniOUXwjmE939KUrsYUJ+dV4AxBkbAuEsLOhDAsz7XaX5Pnq2nFsDttXqA zigZ4ena7XFA8NWcjPGkCfYiaTK7nTbtHGIA2hCkRmh4ad3vamoMsN++96L+TW6qa1Ml hso+Gv7+8mBZ5gZO3jtuwKpcVmJ4AkR4TW458= 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=NmAXs03B1u11PSzI643X19OJ/Xsc/vsbhzNPHSS5ROc=; b=H3CrY/I0hLeMvFqLIzgEhoySVLpn6QxKA6OcFJiEccPp+Qz9Xn3JybxHF/Kq4qTacQ Yrss+7egPpVc+mpYSdel6PDddoui+PcXknOlrY1bllkngXmUs/zp5OwxDBCFhVR29OYy kTv6jBC1hX2e8w2HmDBC4Rmzwd0ZUGkzAuMn49D39Bn/KcfIxZvcwujNu/GppyxrJ45a N2tCUDfIHjA/qvAeCP+VLwQAAPJO8dtgbo/Miuh85UWdvYIvzio+P4hkaMEhyBk3HOcq aFtxDI8eg6vec8xZD492WVbbLGpeIsyXryEmmws5w2PAaoO5yMZifEq4GN+rTHUWkUMG 968w== X-Gm-Message-State: AFeK/H3/p+uSWYn3EcR0WhDFetQxV7FpF1xgEg/VnBYE1Y73j0tzvNk1E6sru2mViHLoFQ== X-Received: by 10.46.22.28 with SMTP id w28mr7593476ljd.123.1491374956085; Tue, 04 Apr 2017 23:49:16 -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.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Apr 2017 23:49: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 v2 03/11] platform/x86: fujitsu-laptop: merge set_lcd_level_alt() into set_lcd_level() Date: Wed, 5 Apr 2017 08:49:02 +0200 Message-Id: <20170405064910.3162-4-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 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 59107a599d22..2f563aa00592 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); }