From patchwork Tue Feb 20 05:24:50 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: 10229419 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 BAC0C602DC for ; Tue, 20 Feb 2018 05:26:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAC5526E97 for ; Tue, 20 Feb 2018 05:26:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9EEDD283A5; Tue, 20 Feb 2018 05:26:18 +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=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 2684E26E97 for ; Tue, 20 Feb 2018 05:26:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750710AbeBTF0R (ORCPT ); Tue, 20 Feb 2018 00:26:17 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:37783 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751043AbeBTFZF (ORCPT ); Tue, 20 Feb 2018 00:25:05 -0500 Received: by mail-lf0-f68.google.com with SMTP id y19so2455037lfd.4 for ; Mon, 19 Feb 2018 21:25:05 -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=a70poZ7odeYYBLPLLZ80sygYko3DRWLFW4LhJYvtWV0=; b=ffl2b9k38554jrxzfMdR960bp2yI8bXlnIicjOi8X4XQ04wAB2Ibl9r15siYI6Eftk RtQOdYkGNJls6y8Oa/lHbuPPK80g3eqRrMK3Luc9JCGhsgcdKOrS8xgQIhMYh6uIxChN EX9400UZWqMFwH39eJ5Pp8KjVyWmhvYuKCjHU= 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=a70poZ7odeYYBLPLLZ80sygYko3DRWLFW4LhJYvtWV0=; b=crtFKZHg06qsPXbKg2PRNrKsKUXe+2j72gbnzA5Y/frX5XiN2KMzdNcCSwA6QF3OdH VbkFdiCkCdAL1Pykjc+cQjICu6jpZfVh2FS9mnkoWaq2Kl9VWG/FWByaHBz76MbWuQUS EDyo8hXbsFLfkn+SNHZqQ4Kkh5v3xYlIjZSRAw30UI+YF0H4CUocqmES4p0ibAU628KI nTcqksIBTyaAKiqbY8EqAuIcqQjEpYchp5nPtMZdETw/HY+j4+V6W1vkk3zhKcBxgzMM ZOUoNVQ5hOJDeShb8w1F+ZLlZ52QD/iL0pfGlgnU9ZlXH/Ow2Z5T2wwwAF7Aiz4aGX17 2i5w== X-Gm-Message-State: APf1xPCC/QDLekgrFs7kNue5R7CU9R/RyYN1rsJpeRjpvO9VPBTACsbH do8gNr8qO6LfOLnT9BcUhaQvTQ== X-Google-Smtp-Source: AH8x224PGA6S+g0OoQTUgYM/Ij6tfjZZt1d5dRvCx6yLEe0IgY9lYUoEa1NnhU8TA/8MY+gU5vCsIg== X-Received: by 10.46.85.157 with SMTP id g29mr10474073lje.118.1519104304357; Mon, 19 Feb 2018 21:25:04 -0800 (PST) Received: from kmp-mobile.hq.kempniu.pl (kmp-mobile.hq.kempniu.pl. [2001:470:64df:111::1b01]) by smtp.googlemail.com with ESMTPSA id b27sm3978286ljb.84.2018.02.19.21.25.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Feb 2018 21:25:03 -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 v2 3/7] platform/x86: fujitsu-laptop: Simplify error paths Date: Tue, 20 Feb 2018 06:24:50 +0100 Message-Id: <20180220052454.11134-4-kernel@kempniu.pl> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180220052454.11134-1-kernel@kempniu.pl> References: <20180220052454.11134-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 Replace the last few lines of acpi_fujitsu_bl_add() with a simple return in order to improve code readability without changing the logic. As acpi_fujitsu_laptop_add() uses a managed memory allocation for device-specific data, it is fine to just return immediately upon kfifo allocation failure. Do that instead of jumping to the end of the function to improve code readability. Running out of memory while allocating the kfifo does not seem probable enough to warrant logging an error message, so do not do it. Signed-off-by: Michał Kępień --- drivers/platform/x86/fujitsu-laptop.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c index 7f30a427a16c..94ff7f86fa8f 100644 --- a/drivers/platform/x86/fujitsu-laptop.c +++ b/drivers/platform/x86/fujitsu-laptop.c @@ -410,11 +410,7 @@ static int acpi_fujitsu_bl_add(struct acpi_device *device) if (ret) return ret; - ret = fujitsu_backlight_register(device); - if (ret) - return ret; - - return 0; + return fujitsu_backlight_register(device); } /* Brightness notify */ @@ -790,10 +786,8 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device) spin_lock_init(&priv->fifo_lock); ret = kfifo_alloc(&priv->fifo, RINGBUFFERSIZE * sizeof(int), GFP_KERNEL); - if (ret) { - pr_err("kfifo_alloc failed\n"); - goto err_stop; - } + if (ret) + return ret; pr_info("ACPI: %s [%s]\n", acpi_device_name(device), acpi_device_bid(device)); @@ -845,7 +839,7 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device) err_free_fifo: kfifo_free(&priv->fifo); -err_stop: + return ret; }