Received: by 10.223.185.116 with SMTP id b49csp5433830wrg; Tue, 27 Feb 2018 13:17:48 -0800 (PST) X-Google-Smtp-Source: AH8x225Lroh0XtJZuEqF+JGwdjOOoe0XS8103kxp5XCx47YgtfBnGvNQycstMDpsv49fv0v4/0HU X-Received: by 10.101.93.138 with SMTP id f10mr12122438pgt.255.1519766268407; Tue, 27 Feb 2018 13:17:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519766268; cv=none; d=google.com; s=arc-20160816; b=oj9s5N3fSxgaFUF2mSTlQRgzBFPvhFqQXoMQMhRT6OTwhurzoIKBfFH4wnXhxYc4Vz DOfYFmpFGf9cPgKHtvG0OqvEMVyAW5BN3xKYVFRyax/OeMQ67YmPIYtfnZDlZ9lV1HRp BNZ0NLXCICn9qXX35j6pUV+OCUBrzmnqi8865M0SwNGUNhToIH8MYouHM3ZiJ1c3/0N9 CPN0J9GrEelUKtalOrEQJwmA5F4TWoDbNWQiBLFGR1baGeuy13Li9/4/bymJDafYSYNR xXJfEsnfGLiRK20jp7EPleOra/IwfvzAPEcez0aZa+W0NJcd6+ufEZ+G1QTufCStiajf unEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=hAzkt9NxwC1sRGtvIWMqi13eud7w+hmU8tvWwVBUeRA=; b=vNQNs7vnmU23eag0xLw3UUVqMJgMJ2BsHPJNM+z3GwdGxqXd9KbIT/6ahr0nEciLBW I60pRexwimXgOIiAwxfLqOhwv9EyXAtkgUvWBJY5ORi7ImorubMu3yLomPpujYW21XPV 4eNZXbHYPbjnsGFFEXHik2IBn0cmvKN7clerxuWd3LW5VrhA29NKSV6+60r0VKTf3nFV Qu0yEX6fT3Mry6cYHt457Htn+c5V7wY3B3E8VT2iMhnkIGVxLMpdaFxkVje9Hygy7NWp TYhind1DKBsKZGvy2rY73AI/kZCB3rVimDdJamIV7dHTix3Dlm7s5S923Lheq2mpA6NN NW6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kempniu.pl header.s=google header.b=JX4eMKA0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kempniu.pl Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c2-v6si65331pli.308.2018.02.27.13.17.32; Tue, 27 Feb 2018 13:17:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kempniu.pl header.s=google header.b=JX4eMKA0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kempniu.pl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752099AbeB0VQY (ORCPT + 99 others); Tue, 27 Feb 2018 16:16:24 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:40386 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751996AbeB0VP4 (ORCPT ); Tue, 27 Feb 2018 16:15:56 -0500 Received: by mail-lf0-f66.google.com with SMTP id 37so364929lfs.7 for ; Tue, 27 Feb 2018 13:15:55 -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=hAzkt9NxwC1sRGtvIWMqi13eud7w+hmU8tvWwVBUeRA=; b=JX4eMKA0Ww1N8I3nttSoPfSiS7NRr5H+st0zXHQud6u2i97sOcSK0qjbfbJwqMzATh oAgWBBkA2TwXr0uxSHOiRcrQ4hPuuNK2sPNOxSU5ppwICWIBZM2WxgedKxbHh5HfSV65 WupuD9X0Fn+zsyt6OAXuGL9xy4EjDGwYVCKII= 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=hAzkt9NxwC1sRGtvIWMqi13eud7w+hmU8tvWwVBUeRA=; b=P0l3TwsDrXV48u5bvYegKFz/YbK+pv5BEpqd+SO0wY+LaeN7qIiOshPhbkiy72TOoL OpKFkZmfa36mUAA6Gp4OKDe91Rz3wkhK8icoQIQssROTHzM+oiogc4dWU2qu4lULkHMR tfIGOW7wdLvrISTbFTBKzYoLAnZLD9lSvuxRTA1oypWTgHB9K/hA6/5W3IYNa98DXDoY QFWdkG8dUtok68qqLJxhEQsdGru0UPw4ZwBLmHxf26bwz/19HLE6+W0ngtrgcE5AsIfs ituRI0ZGnP/EHnfonTpCeu14ZakoLKqi6B3gXxyCuiExEsbvLdw5JzJ7IChl6f5Y9my4 Rong== X-Gm-Message-State: APf1xPANttObuFga0XWhdmewhHSg87PdwIzzDqM+9JM1yFiNtsZ2hppp 9JKPaW+tFOptRel0Is05Y0N49yvH X-Received: by 10.46.4.149 with SMTP id a21mr12080449ljf.138.1519766154832; Tue, 27 Feb 2018 13:15:54 -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.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 13:15:54 -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 7/7] platform/x86: fujitsu-laptop: Introduce fext_*() helper functions Date: Tue, 27 Feb 2018 22:15:39 +0100 Message-Id: <20180227211539.5708-8-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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Stop invoking call_fext_func() directly to improve code clarity and save some horizontal space. Signed-off-by: Michał Kępień --- drivers/platform/x86/fujitsu-laptop.c | 116 +++++++++++++++++----------------- 1 file changed, 59 insertions(+), 57 deletions(-) diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c index 46c9f4441c24..9ac9283fa707 100644 --- a/drivers/platform/x86/fujitsu-laptop.c +++ b/drivers/platform/x86/fujitsu-laptop.c @@ -184,6 +184,30 @@ static int call_fext_func(struct acpi_device *device, return value; } +static int fext_backlight(struct acpi_device *device, + int op, int feature, int state) +{ + return call_fext_func(device, FUNC_BACKLIGHT, op, feature, state); +} + +static int fext_buttons(struct acpi_device *device, + int op, int feature, int state) +{ + return call_fext_func(device, FUNC_BUTTONS, op, feature, state); +} + +static int fext_flags(struct acpi_device *device, + int op, int feature, int state) +{ + return call_fext_func(device, FUNC_FLAGS, op, feature, state); +} + +static int fext_leds(struct acpi_device *device, + int op, int feature, int state) +{ + return call_fext_func(device, FUNC_LEDS, op, feature, state); +} + /* Hardware access for LCD brightness control */ static int set_lcd_level(struct acpi_device *device, int level) @@ -274,12 +298,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, - FEAT_BACKLIGHT_POWER, + fext_backlight(fext, OP_SET, FEAT_BACKLIGHT_POWER, STATE_BACKLIGHT_OFF); else - call_fext_func(fext, FUNC_BACKLIGHT, OP_SET, - FEAT_BACKLIGHT_POWER, + fext_backlight(fext, OP_SET, FEAT_BACKLIGHT_POWER, STATE_BACKLIGHT_ON); } @@ -609,13 +631,11 @@ static int logolamp_set(struct led_classdev *cdev, if (brightness < LED_FULL) always = STATE_LED_OFF; - ret = call_fext_func(device, FUNC_LEDS, OP_SET, - FEAT_LOGOLAMP_POWERON, poweron); + ret = fext_leds(device, OP_SET, FEAT_LOGOLAMP_POWERON, poweron); if (ret < 0) return ret; - return call_fext_func(device, FUNC_LEDS, OP_SET, - FEAT_LOGOLAMP_ALWAYS, always); + return fext_leds(device, OP_SET, FEAT_LOGOLAMP_ALWAYS, always); } static enum led_brightness logolamp_get(struct led_classdev *cdev) @@ -623,13 +643,11 @@ 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, - FEAT_LOGOLAMP_ALWAYS, 0x0); + ret = fext_leds(device, OP_GET, FEAT_LOGOLAMP_ALWAYS, 0x0); if (ret == STATE_LED_ON) return LED_FULL; - ret = call_fext_func(device, FUNC_LEDS, OP_GET, - FEAT_LOGOLAMP_POWERON, 0x0); + ret = fext_leds(device, OP_GET, FEAT_LOGOLAMP_POWERON, 0x0); if (ret == STATE_LED_ON) return LED_HALF; @@ -642,11 +660,11 @@ static int kblamps_set(struct led_classdev *cdev, struct acpi_device *device = to_acpi_device(cdev->dev->parent); if (brightness >= LED_FULL) - return call_fext_func(device, FUNC_LEDS, OP_SET, - FEAT_KEYBOARD_LAMPS, STATE_LED_ON); + return fext_leds(device, OP_SET, FEAT_KEYBOARD_LAMPS, + STATE_LED_ON); else - return call_fext_func(device, FUNC_LEDS, OP_SET, - FEAT_KEYBOARD_LAMPS, STATE_LED_OFF); + return fext_leds(device, OP_SET, FEAT_KEYBOARD_LAMPS, + STATE_LED_OFF); } static enum led_brightness kblamps_get(struct led_classdev *cdev) @@ -654,8 +672,7 @@ static enum led_brightness kblamps_get(struct led_classdev *cdev) struct acpi_device *device = to_acpi_device(cdev->dev->parent); enum led_brightness brightness = LED_OFF; - if (call_fext_func(device, FUNC_LEDS, OP_GET, - FEAT_KEYBOARD_LAMPS, 0x0) == STATE_LED_ON) + if (fext_leds(device, OP_GET, FEAT_KEYBOARD_LAMPS, 0x0) == STATE_LED_ON) brightness = LED_FULL; return brightness; @@ -667,11 +684,11 @@ static int radio_led_set(struct led_classdev *cdev, struct acpi_device *device = to_acpi_device(cdev->dev->parent); if (brightness >= LED_FULL) - return call_fext_func(device, FUNC_FLAGS, OP_SET_EXT, - FEAT_RADIO_LED, STATE_RADIO_LED_ON); + return fext_flags(device, OP_SET_EXT, FEAT_RADIO_LED, + STATE_RADIO_LED_ON); else - return call_fext_func(device, FUNC_FLAGS, OP_SET_EXT, - FEAT_RADIO_LED, STATE_RADIO_LED_OFF); + return fext_flags(device, OP_SET_EXT, FEAT_RADIO_LED, + STATE_RADIO_LED_OFF); } static enum led_brightness radio_led_get(struct led_classdev *cdev) @@ -679,8 +696,7 @@ static enum led_brightness radio_led_get(struct led_classdev *cdev) struct acpi_device *device = to_acpi_device(cdev->dev->parent); enum led_brightness brightness = LED_OFF; - if (call_fext_func(device, FUNC_FLAGS, OP_GET_EXT, - 0x0, 0x0) & STATE_RADIO_LED_ON) + if (fext_flags(device, OP_GET_EXT, 0x0, 0x0) & STATE_RADIO_LED_ON) brightness = LED_FULL; return brightness; @@ -692,13 +708,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, FEAT_ECO_LED, 0x0); + curr = fext_leds(device, OP_GET, FEAT_ECO_LED, 0x0); if (brightness >= LED_FULL) - return call_fext_func(device, FUNC_LEDS, OP_SET, - FEAT_ECO_LED, curr | STATE_ECO_LED_ON); + return fext_leds(device, OP_SET, FEAT_ECO_LED, + curr | STATE_ECO_LED_ON); else - return call_fext_func(device, FUNC_LEDS, OP_SET, - FEAT_ECO_LED, curr & ~STATE_ECO_LED_ON); + return fext_leds(device, OP_SET, FEAT_ECO_LED, + curr & ~STATE_ECO_LED_ON); } static enum led_brightness eco_led_get(struct led_classdev *cdev) @@ -706,8 +722,7 @@ static enum led_brightness eco_led_get(struct led_classdev *cdev) struct acpi_device *device = to_acpi_device(cdev->dev->parent); enum led_brightness brightness = LED_OFF; - if (call_fext_func(device, FUNC_LEDS, OP_GET, - FEAT_ECO_LED, 0x0) & STATE_ECO_LED_ON) + if (fext_leds(device, OP_GET, FEAT_ECO_LED, 0x0) & STATE_ECO_LED_ON) brightness = LED_FULL; return brightness; @@ -719,8 +734,7 @@ static int acpi_fujitsu_laptop_leds_register(struct acpi_device *device) struct led_classdev *led; int ret; - if (call_fext_func(device, FUNC_LEDS, OP_GET_CAPS, - 0x0, 0x0) & FEAT_LOGOLAMP_POWERON) { + if (fext_leds(device, OP_GET_CAPS, 0x0, 0x0) & FEAT_LOGOLAMP_POWERON) { led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL); if (!led) return -ENOMEM; @@ -733,10 +747,8 @@ static int acpi_fujitsu_laptop_leds_register(struct acpi_device *device) return ret; } - if ((call_fext_func(device, FUNC_LEDS, OP_GET_CAPS, - 0x0, 0x0) & FEAT_KEYBOARD_LAMPS) && - (call_fext_func(device, FUNC_BUTTONS, OP_GET_CAPS, - 0x0, 0x0) == 0x0)) { + if ((fext_leds(device, OP_GET_CAPS, 0x0, 0x0) & FEAT_KEYBOARD_LAMPS) && + (fext_buttons(device, OP_GET_CAPS, 0x0, 0x0) == 0x0)) { led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL); if (!led) return -ENOMEM; @@ -777,10 +789,8 @@ static int acpi_fujitsu_laptop_leds_register(struct acpi_device *device) * bit 14 seems to indicate presence of said led as well. * Confirm by testing the status. */ - if ((call_fext_func(device, FUNC_LEDS, OP_GET_CAPS, - 0x0, 0x0) & BIT(14)) && - (call_fext_func(device, FUNC_LEDS, OP_GET, - FEAT_ECO_LED, 0x0) != UNSUPPORTED_CMD)) { + if ((fext_leds(device, OP_GET_CAPS, 0x0, 0x0) & BIT(14)) && + (fext_leds(device, OP_GET, FEAT_ECO_LED, 0x0) != UNSUPPORTED_CMD)) { led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL); if (!led) return -ENOMEM; @@ -822,15 +832,13 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device) pr_info("ACPI: %s [%s]\n", acpi_device_name(device), acpi_device_bid(device)); - while (call_fext_func(device, FUNC_BUTTONS, OP_GET_EVENTS, - 0x0, 0x0) != 0 && + while (fext_buttons(device, OP_GET_EVENTS, 0x0, 0x0) != 0 && i++ < HOTKEY_RINGBUFFER_SIZE) ; /* No action, result is discarded */ acpi_handle_debug(device->handle, "Discarded %i ringbuffer entries\n", i); - priv->flags_supported = call_fext_func(device, FUNC_FLAGS, OP_GET_CAPS, - 0x0, 0x0); + priv->flags_supported = fext_flags(device, OP_GET_CAPS, 0x0, 0x0); /* Make sure our bitmask of supported functions is cleared if the RFKILL function block is not implemented, like on the S7020. */ @@ -838,19 +846,16 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device) priv->flags_supported = 0; if (priv->flags_supported) - priv->flags_state = call_fext_func(device, FUNC_FLAGS, - OP_GET_EXT, 0x0, 0x0); + priv->flags_state = fext_flags(device, OP_GET_EXT, 0x0, 0x0); /* Suspect this is a keymap of the application panel, print it */ acpi_handle_info(device->handle, "BTNI: [0x%x]\n", - call_fext_func(device, FUNC_BUTTONS, OP_GET_CAPS, - 0x0, 0x0)); + fext_buttons(device, OP_GET_CAPS, 0x0, 0x0)); /* Sync backlight power status */ if (fujitsu_bl && fujitsu_bl->bl_device && acpi_video_get_backlight_type() == acpi_backlight_vendor) { - if (call_fext_func(fext, FUNC_BACKLIGHT, OP_GET, - FEAT_BACKLIGHT_POWER, + if (fext_backlight(fext, OP_GET, FEAT_BACKLIGHT_POWER, 0x0) == STATE_BACKLIGHT_OFF) fujitsu_bl->bl_device->props.power = FB_BLANK_POWERDOWN; else @@ -935,11 +940,9 @@ static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event) } if (priv->flags_supported) - priv->flags_state = call_fext_func(device, FUNC_FLAGS, - OP_GET_EXT, 0x0, 0x0); + priv->flags_state = fext_flags(device, OP_GET_EXT, 0x0, 0x0); - while ((irb = call_fext_func(device, FUNC_BUTTONS, OP_GET_EVENTS, - 0x0, 0x0)) != 0 && + while ((irb = fext_buttons(device, OP_GET_EVENTS, 0x0, 0x0)) != 0 && i++ < HOTKEY_RINGBUFFER_SIZE) { scancode = irb & 0x4ff; if (sparse_keymap_entry_from_scancode(priv->input, scancode)) @@ -956,8 +959,7 @@ static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event) * handled in software; its state is queried using FUNC_FLAGS */ if ((priv->flags_supported & BIT(26)) && - (call_fext_func(device, FUNC_FLAGS, OP_GET_EVENTS, - 0x0, 0x0) & BIT(26))) + (fext_flags(device, OP_GET_EVENTS, 0x0, 0x0) & BIT(26))) sparse_keymap_report_event(priv->input, BIT(26), 1, true); } -- 2.16.2