From patchwork Sun Feb 11 21:07:23 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: 10211549 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 0A483602CB for ; Sun, 11 Feb 2018 21:09:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0D7028800 for ; Sun, 11 Feb 2018 21:09:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E59302884C; Sun, 11 Feb 2018 21:09:45 +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=unavailable 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 976FE28800 for ; Sun, 11 Feb 2018 21:09:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932114AbeBKVJp (ORCPT ); Sun, 11 Feb 2018 16:09:45 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:41143 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932176AbeBKVHl (ORCPT ); Sun, 11 Feb 2018 16:07:41 -0500 Received: by mail-lf0-f68.google.com with SMTP id f136so17908736lff.8 for ; Sun, 11 Feb 2018 13:07:41 -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=HxTgpmgxk+qPYJZn1DQb4TrfDPZwvM2jp979aLWakstE681fj88uXLGiAPtkMVxgSF 6TL2Y2D+muEechbsnC6cubpS+G0Fnhd79ptRRaWl0UYkw4O/ZKk7lFb7+ZDDaw9xVn/Y 5IWLFyIGzHOkTIFyCruVtlUKKiCHMiiz4enMc= 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=mR11haIS8DmZitWvRRn5u54euKUoF0PjQ7mN9K/jTkKeUrYovygZIHgZuNNKf/gEuW QOtK2KotK07A9an3S5w6GdfpS+Sr3Jwji72RX91c83VOxFnBkNYmv6ePELfO/nGmigaq kP0LRJsV8uHcdalmMV4N7cEsLAc3l8bC4Lm/a5j63Aa92rrEaqADp0hi1l4gwxqXEwEz VKrzu6vpprdizi6wOswrwJ21djc6JGXDTR0GIiAlj++J9m5FaVhkCd192O8HpsUJiksg O1hJi3gk8AJOy5Ji/0LunLBwOMN4C7sqTvRwaIRPML/4bjw05Tf4+o0K2q+Fuw8mHFVD lzhQ== X-Gm-Message-State: APf1xPAF5pBMjcqD/vqSMFrG8I3UCneUqXX2rt4GNSgOlRTM7rFZYnm3 aMuNPdCFVnT1W+6ulvY4pHn+Vg== X-Google-Smtp-Source: AH8x227fltWVUTgbTL2nrouQvtsR/0YasNeHbYy9GBAc8C1FUMGQFflxGJ1S2Z5dLB9XR8+z0J9plQ== X-Received: by 10.25.24.37 with SMTP id o37mr1596167lfi.88.1518383260400; Sun, 11 Feb 2018 13:07:40 -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 y198sm1390477lfd.62.2018.02.11.13.07.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Feb 2018 13:07:39 -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 3/7] platform/x86: fujitsu-laptop: Simplify error paths Date: Sun, 11 Feb 2018 22:07:23 +0100 Message-Id: <20180211210727.12130-4-kernel@kempniu.pl> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180211210727.12130-1-kernel@kempniu.pl> References: <20180211210727.12130-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; }