From patchwork Mon Jan 9 13:14:16 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: 9504609 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 43FB860757 for ; Mon, 9 Jan 2017 13:15:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E374284C7 for ; Mon, 9 Jan 2017 13:15:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F2C0284D5; Mon, 9 Jan 2017 13:15:31 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 C66B7284C7 for ; Mon, 9 Jan 2017 13:15:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936967AbdAINPB (ORCPT ); Mon, 9 Jan 2017 08:15:01 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:35348 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758971AbdAINO0 (ORCPT ); Mon, 9 Jan 2017 08:14:26 -0500 Received: by mail-lf0-f66.google.com with SMTP id v186so5603470lfa.2 for ; Mon, 09 Jan 2017 05:14:25 -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=sxQ8FsdHRY5l8qgf5vjaKSlbI+BSPxKygFbzKIEoxYE=; b=RTCRBOBQmuT1WVxVNgqWADEvIiGJiBpQZy8a98r2UXbiGowTimY/HhZ5fiJmKp96Sz Bn0NPGEdf9et++ao0fDX5Wv3DwMrDwLBrKX7tqmiWETdhD/fLSFjXJ3b0fSQ0J7CqB51 Kx0K62fBJA6lrylNO5bIiqL4ZF9Lfk9HBYd4k= 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=sxQ8FsdHRY5l8qgf5vjaKSlbI+BSPxKygFbzKIEoxYE=; b=NBXtLI5M6EyNEh9CPbFuZu8KA0gGrmb3atfX1/HQoE9lnG0jMNk3SposYA1AjIf8Q2 j69/X6pMhOZuB9gVewYu7yAb7/c0cB2Dj6PJt6RmhKjazoum0NHB3UTr1FgI6daXujEB bqHDIhqwA3RD9SiJ6wBQciXiWv77QLmx7VYKPlDxBOkKBqaMuVYDWbb/1mucTwMOP3G4 CkOpRKvaBh8R3YpKnDcqkYq1+ypuZOMx1KGvHaYNtdLDVRFZJY8yJDqxlIYSMLVM4C7W 0d7Ikzr36qbeajksfHLoLnawno5dQBgUUu2bxKn0fXQZQDzdky3A4k6k0XhM/L/FMPou nd8w== X-Gm-Message-State: AIkVDXJYsBmvHbnSx20IsU/OKruShN5NlnNoXLrA+A3pmjSx4PzL0G9b7YPVCdKK6N68eg== X-Received: by 10.46.76.10 with SMTP id z10mr31056850lja.48.1483967664407; Mon, 09 Jan 2017 05:14:24 -0800 (PST) Received: from ozzy.hq.kempniu.pl ([2001:a10:160:3::3]) by smtp.googlemail.com with ESMTPSA id u77sm21457380lfg.22.2017.01.09.05.14.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jan 2017 05:14:23 -0800 (PST) From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= To: Jonathan Woithe , Darren Hart Cc: Andy Shevchenko , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] platform/x86: fujitsu-laptop: rework logolamp_set() to properly handle errors Date: Mon, 9 Jan 2017 14:14:16 +0100 Message-Id: <20170109131417.9677-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 --- Changes from v1: - Decrease indentation by rearranging logical conditions. - Split variable declarations into two lines. drivers/platform/x86/fujitsu-laptop.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c index b725a907a91f..34b8481fb0ed 100644 --- a/drivers/platform/x86/fujitsu-laptop.c +++ b/drivers/platform/x86/fujitsu-laptop.c @@ -271,15 +271,20 @@ 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 poweron = FUNC_LED_ON, always = FUNC_LED_ON; + int ret; + + if (brightness < LED_HALF) + poweron = FUNC_LED_OFF; + + if (brightness < LED_FULL) + always = FUNC_LED_OFF; + + 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,