From patchwork Thu Jan 5 13:11:29 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: 9499007 X-Patchwork-Delegate: andy.shevchenko@gmail.com 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 7E5BE60413 for ; Thu, 5 Jan 2017 13:12:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 779AA283E5 for ; Thu, 5 Jan 2017 13:12:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C80E283EB; Thu, 5 Jan 2017 13:12:24 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 90E0F283E5 for ; Thu, 5 Jan 2017 13:12:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033790AbdAENMW (ORCPT ); Thu, 5 Jan 2017 08:12:22 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:32843 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936161AbdAENMT (ORCPT ); Thu, 5 Jan 2017 08:12:19 -0500 Received: by mail-lf0-f66.google.com with SMTP id k62so852947lfg.0 for ; Thu, 05 Jan 2017 05:11:37 -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:mime-version :content-transfer-encoding; bh=6cFbL193PvzAkx4qBLhTJlMyU0RlwlKGIPNb7BOfK98=; b=qXSzIuVSArjnjeHrsuH1+YOzb5EkK0iWLpHZ2y5w09nXcwLVPGMENvm7rQGFwL+Bmp XIyMyu1skYL9FcDoZePckZu52HKiIp0EIVeONL4O5a7HwQ5laIDb6JWk7smN4niGmJT7 38fYnXKxLxnGkE+eVuz6/VOlAx6p90jHe1TM8= 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:mime-version :content-transfer-encoding; bh=6cFbL193PvzAkx4qBLhTJlMyU0RlwlKGIPNb7BOfK98=; b=LVIP4IOoLhSKwTs3BD15sfKOo1C55Hq9n2hO0gGzjLuHvNMyNNaN/RsV2Y6aMr2Ktb 7g78ZVhiQe94BYJwtFqqRCfzrNwQiD+HnSRteMPLjwgvxN7A/nO4lY2mLu3UuuIChVQq ZVRuGvS/8OqfYAZveTaUCjve0biH+5ijqXxyQEXNbqjujtD63f6Rj9TIokFZQL7Hg4y4 CK9ahaTXbzzk87ahinYi7bKBBv1925fU2+ZKoGsKExHE2JvgaslJt+IGgnxXEOcV+m+O +bhwQ0FZH4Fsv6p+gfjWPZoPyiA6JwrC4XJ+XI7tWn1UvKD8MYU7IhZA+5ajjP1Z94rL 4z5A== X-Gm-Message-State: AIkVDXKcfC3y9yg7ubqk3LYCPxujoVnshw5tUkJYgySwb+CdiW1YEdRCtpwSKJV+sT6LGQ== X-Received: by 10.25.32.208 with SMTP id g199mr790150lfg.7.1483621896375; Thu, 05 Jan 2017 05:11:36 -0800 (PST) Received: from ozzy.hq.kempniu.pl ([2001:a10:160:3::3]) by smtp.googlemail.com with ESMTPSA id z9sm18358385lja.1.2017.01.05.05.11.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jan 2017 05:11:35 -0800 (PST) From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= To: Jonathan Woithe , Darren Hart Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] platform/x86: fujitsu-laptop: rework logolamp_set() to properly handle errors Date: Thu, 5 Jan 2017 14:11:29 +0100 Message-Id: <20170105131129.5750-1-kernel@kempniu.pl> X-Mailer: git-send-email 2.11.0 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 Potential errors returned by some call_fext_func() calls inside logolamp_set() are currently ignored. Rework logolamp_set() to properly handle them. This causes one more call_fext_func() call to be made in the LED_OFF case, though one could argue that this is logically the right thing to do (even though the extra call is not needed to shut the LED off). Signed-off-by: Michał Kępień Acked-by: Jonathan Woithe --- This is a follow-up to a recent patch, "platform/x86: fujitsu-laptop: use brightness_set_blocking for LED-setting callbacks" and thus needs the latter to be applied first (currently it is already applied in testing). Instead of sticking "if (ret < 0) return ret;" in two branches I decided to restructure logolamp_set() for improved clarity and also to make it resemble logolamp_get() a bit more. drivers/platform/x86/fujitsu-laptop.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c index b725a907a91f..12f7a8346dd0 100644 --- a/drivers/platform/x86/fujitsu-laptop.c +++ b/drivers/platform/x86/fujitsu-laptop.c @@ -271,15 +271,19 @@ static int call_fext_func(int cmd, int arg0, int arg1, int arg2) static int logolamp_set(struct led_classdev *cdev, enum led_brightness brightness) { - if (brightness >= LED_FULL) { - call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON); - return call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_ON); - } else if (brightness >= LED_HALF) { - call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON); - return call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_OFF); - } else { - return call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_OFF); + int ret, poweron = FUNC_LED_OFF, always = FUNC_LED_OFF; + + if (brightness >= LED_HALF) { + poweron = FUNC_LED_ON; + if (brightness >= LED_FULL) + always = FUNC_LED_ON; } + + ret = call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, poweron); + if (ret < 0) + return ret; + + return call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, always); } static int kblamps_set(struct led_classdev *cdev,