From patchwork Tue Feb 27 21:15:34 2018 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: 10246087 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 4CC8160362 for ; Tue, 27 Feb 2018 21:17:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39E2127F85 for ; Tue, 27 Feb 2018 21:17:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E8F12817F; Tue, 27 Feb 2018 21:17:47 +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 9348F27F9F for ; Tue, 27 Feb 2018 21:17:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751663AbeB0VRp (ORCPT ); Tue, 27 Feb 2018 16:17:45 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:42909 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751997AbeB0VPu (ORCPT ); Tue, 27 Feb 2018 16:15:50 -0500 Received: by mail-lf0-f65.google.com with SMTP id t204so355276lff.9 for ; Tue, 27 Feb 2018 13:15:49 -0800 (PST) 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=oKkG7gqIgJk6rSigWbLKlgTAs4E48wxE6FTh4PTFieM=; b=kILX2UQBNU7QwBgf06MZU/Q8uXuqioXmPeqW7+dHGpMHsmuiB00r8VvSyw72eAWMh+ G7EgwmhyAzqcu9B2AmKpJluMlhoAGaa+bqKY2/7+qjho3FLyJiOBSzaLhG+YzGFZxDzI I8QSMmptbrfV4UwX+iLDsIAeXWwDu5yV4R8jU= 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=oKkG7gqIgJk6rSigWbLKlgTAs4E48wxE6FTh4PTFieM=; b=Ofq7nMjI9GEk4vs/ZGN3fJFtA2lpcxGr35jWicG6WFhnX9yjSN5pTiIeHznvHUSl/b OobO4FVVyQOVpGi0zaEAQF5pfhqZqXoDlQJyQoGxwH8lCw1liO/fIhmTkUtHZA5t26HK LdbKNHyrcmOl7bCd+PF5kvaHYxKsR6t+tIUiRi35Wr7erXlU9WLnGGwQVyKO5CQyP8K0 7JeztVFe24dOfnd/8t0zsIh59XxPcXfM7RjhXL+kQQ8UwjATqKDbUSoQnWwbvohA5oH1 lofOFKdge1CPeJmtXvKOV3j4ktFTSn/gJv2GwOMNj/0DmnjErbLKXQsl9tgnX0iejW/W oUmw== X-Gm-Message-State: APf1xPAYhXJ+PkUGt59bksvQJck2quSCmmcko9n9EIKxBneQ1LPtlvxE RGGw7kANGcB1rJnPg2XaRHBTkw== X-Google-Smtp-Source: AG47ELveXtuvEeixkdJ8l4HgEbTUO+RsREjyvIyXnm0CE7iKDJjk3VgX0x2KI6oB4NcEVIjmJbg0jQ== X-Received: by 10.25.181.8 with SMTP id e8mr10570569lff.94.1519766148951; Tue, 27 Feb 2018 13:15:48 -0800 (PST) Received: from kmp-mobile.hq.kempniu.pl (kmp-mobile.hq.kempniu.pl. [2001:470:64df:111::d0d7]) by smtp.googlemail.com with ESMTPSA id l5sm16288lje.58.2018.02.27.13.15.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 13:15:48 -0800 (PST) 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 2/7] platform/x86: fujitsu-laptop: Define constants for FUNC features Date: Tue, 27 Feb 2018 22:15:34 +0100 Message-Id: <20180227211539.5708-3-kernel@kempniu.pl> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180227211539.5708-1-kernel@kempniu.pl> References: <20180227211539.5708-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 Various functions exposed by the firmware through the FUNC interface allow operations to be performed on certain features. Make sure these features are referred to by consistently named constants instead of integers in order to better convey the intent of each call_fext_func() invocation. Signed-off-by: Michał Kępień --- drivers/platform/x86/fujitsu-laptop.c | 53 +++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c index 74775caeb609..087b5d1f2f4a 100644 --- a/drivers/platform/x86/fujitsu-laptop.c +++ b/drivers/platform/x86/fujitsu-laptop.c @@ -103,15 +103,18 @@ /* FUNC interface - LED control */ #define FUNC_LED_OFF BIT(0) #define FUNC_LED_ON (BIT(0) | BIT(16) | BIT(17)) -#define LOGOLAMP_POWERON BIT(13) -#define LOGOLAMP_ALWAYS BIT(14) -#define KEYBOARD_LAMPS BIT(8) +#define FEAT_LOGOLAMP_POWERON BIT(13) +#define FEAT_LOGOLAMP_ALWAYS BIT(14) +#define FEAT_KEYBOARD_LAMPS BIT(8) + +#define FEAT_RADIO_LED BIT(5) #define RADIO_LED_ON BIT(5) -#define ECO_LED BIT(16) + +#define FEAT_ECO_LED BIT(16) #define ECO_LED_ON BIT(19) /* FUNC interface - backlight power control */ -#define BACKLIGHT_PARAM_POWER BIT(2) +#define FEAT_BACKLIGHT_POWER BIT(2) #define BACKLIGHT_OFF (BIT(0) | BIT(1)) #define BACKLIGHT_ON 0 @@ -273,10 +276,10 @@ static int bl_update_status(struct backlight_device *b) if (fext) { if (b->props.power == FB_BLANK_POWERDOWN) call_fext_func(fext, FUNC_BACKLIGHT, OP_SET, - BACKLIGHT_PARAM_POWER, BACKLIGHT_OFF); + FEAT_BACKLIGHT_POWER, BACKLIGHT_OFF); else call_fext_func(fext, FUNC_BACKLIGHT, OP_SET, - BACKLIGHT_PARAM_POWER, BACKLIGHT_ON); + FEAT_BACKLIGHT_POWER, BACKLIGHT_ON); } return set_lcd_level(device, b->props.brightness); @@ -606,12 +609,12 @@ static int logolamp_set(struct led_classdev *cdev, always = FUNC_LED_OFF; ret = call_fext_func(device, FUNC_LEDS, OP_SET, - LOGOLAMP_POWERON, poweron); + FEAT_LOGOLAMP_POWERON, poweron); if (ret < 0) return ret; return call_fext_func(device, FUNC_LEDS, OP_SET, - LOGOLAMP_ALWAYS, always); + FEAT_LOGOLAMP_ALWAYS, always); } static enum led_brightness logolamp_get(struct led_classdev *cdev) @@ -619,11 +622,13 @@ static enum led_brightness logolamp_get(struct led_classdev *cdev) struct acpi_device *device = to_acpi_device(cdev->dev->parent); int ret; - ret = call_fext_func(device, FUNC_LEDS, OP_GET, LOGOLAMP_ALWAYS, 0x0); + ret = call_fext_func(device, FUNC_LEDS, OP_GET, + FEAT_LOGOLAMP_ALWAYS, 0x0); if (ret == FUNC_LED_ON) return LED_FULL; - ret = call_fext_func(device, FUNC_LEDS, OP_GET, LOGOLAMP_POWERON, 0x0); + ret = call_fext_func(device, FUNC_LEDS, OP_GET, + FEAT_LOGOLAMP_POWERON, 0x0); if (ret == FUNC_LED_ON) return LED_HALF; @@ -637,10 +642,10 @@ static int kblamps_set(struct led_classdev *cdev, if (brightness >= LED_FULL) return call_fext_func(device, FUNC_LEDS, OP_SET, - KEYBOARD_LAMPS, FUNC_LED_ON); + FEAT_KEYBOARD_LAMPS, FUNC_LED_ON); else return call_fext_func(device, FUNC_LEDS, OP_SET, - KEYBOARD_LAMPS, FUNC_LED_OFF); + FEAT_KEYBOARD_LAMPS, FUNC_LED_OFF); } static enum led_brightness kblamps_get(struct led_classdev *cdev) @@ -649,7 +654,7 @@ static enum led_brightness kblamps_get(struct led_classdev *cdev) enum led_brightness brightness = LED_OFF; if (call_fext_func(device, FUNC_LEDS, OP_GET, - KEYBOARD_LAMPS, 0x0) == FUNC_LED_ON) + FEAT_KEYBOARD_LAMPS, 0x0) == FUNC_LED_ON) brightness = LED_FULL; return brightness; @@ -662,10 +667,10 @@ static int radio_led_set(struct led_classdev *cdev, if (brightness >= LED_FULL) return call_fext_func(device, FUNC_FLAGS, OP_SET_EXT, - RADIO_LED_ON, RADIO_LED_ON); + FEAT_RADIO_LED, RADIO_LED_ON); else return call_fext_func(device, FUNC_FLAGS, OP_SET_EXT, - RADIO_LED_ON, 0x0); + FEAT_RADIO_LED, 0x0); } static enum led_brightness radio_led_get(struct led_classdev *cdev) @@ -686,13 +691,13 @@ static int eco_led_set(struct led_classdev *cdev, struct acpi_device *device = to_acpi_device(cdev->dev->parent); int curr; - curr = call_fext_func(device, FUNC_LEDS, OP_GET, ECO_LED, 0x0); + curr = call_fext_func(device, FUNC_LEDS, OP_GET, FEAT_ECO_LED, 0x0); if (brightness >= LED_FULL) return call_fext_func(device, FUNC_LEDS, OP_SET, - ECO_LED, curr | ECO_LED_ON); + FEAT_ECO_LED, curr | ECO_LED_ON); else return call_fext_func(device, FUNC_LEDS, OP_SET, - ECO_LED, curr & ~ECO_LED_ON); + FEAT_ECO_LED, curr & ~ECO_LED_ON); } static enum led_brightness eco_led_get(struct led_classdev *cdev) @@ -701,7 +706,7 @@ static enum led_brightness eco_led_get(struct led_classdev *cdev) enum led_brightness brightness = LED_OFF; if (call_fext_func(device, FUNC_LEDS, OP_GET, - ECO_LED, 0x0) & ECO_LED_ON) + FEAT_ECO_LED, 0x0) & ECO_LED_ON) brightness = LED_FULL; return brightness; @@ -714,7 +719,7 @@ static int acpi_fujitsu_laptop_leds_register(struct acpi_device *device) int ret; if (call_fext_func(device, FUNC_LEDS, OP_GET_CAPS, - 0x0, 0x0) & LOGOLAMP_POWERON) { + 0x0, 0x0) & FEAT_LOGOLAMP_POWERON) { led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL); if (!led) return -ENOMEM; @@ -728,7 +733,7 @@ static int acpi_fujitsu_laptop_leds_register(struct acpi_device *device) } if ((call_fext_func(device, FUNC_LEDS, OP_GET_CAPS, - 0x0, 0x0) & KEYBOARD_LAMPS) && + 0x0, 0x0) & FEAT_KEYBOARD_LAMPS) && (call_fext_func(device, FUNC_BUTTONS, OP_GET_CAPS, 0x0, 0x0) == 0x0)) { led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL); @@ -774,7 +779,7 @@ static int acpi_fujitsu_laptop_leds_register(struct acpi_device *device) if ((call_fext_func(device, FUNC_LEDS, OP_GET_CAPS, 0x0, 0x0) & BIT(14)) && (call_fext_func(device, FUNC_LEDS, OP_GET, - ECO_LED, 0x0) != UNSUPPORTED_CMD)) { + FEAT_ECO_LED, 0x0) != UNSUPPORTED_CMD)) { led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL); if (!led) return -ENOMEM; @@ -844,7 +849,7 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device) if (fujitsu_bl && fujitsu_bl->bl_device && acpi_video_get_backlight_type() == acpi_backlight_vendor) { if (call_fext_func(fext, FUNC_BACKLIGHT, OP_GET, - BACKLIGHT_PARAM_POWER, 0x0) == BACKLIGHT_OFF) + FEAT_BACKLIGHT_POWER, 0x0) == BACKLIGHT_OFF) fujitsu_bl->bl_device->props.power = FB_BLANK_POWERDOWN; else fujitsu_bl->bl_device->props.power = FB_BLANK_UNBLANK;