From patchwork Sat Apr 16 00:27:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giedrius Statkevi?ius X-Patchwork-Id: 8860341 Return-Path: X-Original-To: patchwork-platform-driver-x86@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E62539F1D3 for ; Sat, 16 Apr 2016 00:32:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1BC0420155 for ; Sat, 16 Apr 2016 00:32:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4B87720107 for ; Sat, 16 Apr 2016 00:32:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752172AbcDPAbt (ORCPT ); Fri, 15 Apr 2016 20:31:49 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:35049 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751581AbcDPAbe (ORCPT ); Fri, 15 Apr 2016 20:31:34 -0400 Received: by mail-wm0-f46.google.com with SMTP id a140so51041839wma.0; Fri, 15 Apr 2016 17:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mNR61+iSLPAkkTG/uPaH4CI0fdEfAxSoo65Nsn4F18k=; b=fewKxiTRV6EOKIWt6DY1IDuVhYv6Ql8TVQhDirkFK5R2OEwVx/+AYUpLO9OXhFXsAJ iGNAfeYahA6bOImLWewtNUMG/ZaHX7ajhDGYh8d7M9IbqyjGrGyBu+APA1jAinskgF1l kUM65dy6wZS2l33uax0Z2My3QMd4Ed08hohmGoxTdCK12YU63TC2qYakaIqAnZvr4Tuc zH1GqVOskknmGWHl45JBG9RSyTh2/e7Qv4KX0/CUAn++C9K7xDoMqAQtUgfwsCOLHvIq UGorWzNW2iY5k654gfq/jUppX+79Volxu22JTM/uTuOPNVhPLE8TLWahhovhnUdHpkac hVJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mNR61+iSLPAkkTG/uPaH4CI0fdEfAxSoo65Nsn4F18k=; b=PB7rkJUgfvtIi11vpJzn7JSPW2ocvgVdbH/AJFInmksRXdqmVUuBGC3vFh6L/zx/98 w4sMbO5t6ST6BHwkeOAxLLb2qCqVcuZBiMUIMowo1ARugRgkAs1B9s8EtF+CGHoKksd9 itS6mfKGXvkTq/uEceqSlEcnMwZxfjKZTGTH7xLapRt+EqfiDoyM9lHM1CTP+dk3Leqx TCSFkYPOnIhwSX3HOuH5VXYp3bYmGMdZRB9Lhwhaoep2xhuBNaJHNRpeZGl+k2oFoIDh vbnIy5bmTzJ+mMiy8TsgK6RnReGWPWHaRX6Ne7AWF6FcWE5K3gUj/J5PRdu0XQnomGmT mkNw== X-Gm-Message-State: AOPr4FVtwvTWRnju+nvENDPVcCoNPIRp+WIyiiL3XQt0rZO3JSywW6qtIgmMoEKyEMvuGg== X-Received: by 10.194.164.228 with SMTP id yt4mr11719262wjb.64.1460766692566; Fri, 15 Apr 2016 17:31:32 -0700 (PDT) Received: from tyrael.localdomain (78-57-189-147.static.zebra.lt. [78.57.189.147]) by smtp.gmail.com with ESMTPSA id r8sm51303582wjz.34.2016.04.15.17.31.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Apr 2016 17:31:31 -0700 (PDT) From: =?UTF-8?q?Giedrius=20Statkevi=C4=8Dius?= To: corentin.chary@gmail.com, dvhart@infradead.org Cc: acpi4asus-user@lists.sourceforge.net, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Giedrius=20Statkevi=C4=8Dius?= Subject: [PATCH] asus-laptop: correct error handling in asus_read_brightness() Date: Sat, 16 Apr 2016 03:27:12 +0300 Message-Id: <1460766432-5390-1-git-send-email-giedrius.statkevicius@gmail.com> X-Mailer: git-send-email 2.8.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-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It is possible that acpi_evaluate_integer might fail and value would not be set to any value so correct this defect by returning 0 in case of an error. This is also the correct thing to return because the backlight subsystem will print the old value of brightness in this case. Signed-off-by: Giedrius Statkevi?ius --- drivers/platform/x86/asus-laptop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index 9a69734..15f1311 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c @@ -775,8 +775,10 @@ static int asus_read_brightness(struct backlight_device *bd) rv = acpi_evaluate_integer(asus->handle, METHOD_BRIGHTNESS_GET, NULL, &value); - if (ACPI_FAILURE(rv)) + if (ACPI_FAILURE(rv)) { pr_warn("Error reading brightness\n"); + return 0; + } return value; }