Received: by 10.223.185.116 with SMTP id b49csp245032wrg; Mon, 19 Feb 2018 21:28:12 -0800 (PST) X-Google-Smtp-Source: AH8x226QKpzQBbEfypQlg1iEeq1RZCkOt/csYHD7spQ9LImXKobXm9yy/aRB0zIXPABPe1PJKWKO X-Received: by 10.99.122.12 with SMTP id v12mr14301846pgc.128.1519104492867; Mon, 19 Feb 2018 21:28:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519104492; cv=none; d=google.com; s=arc-20160816; b=PbgEPqyPrmJ8wSU1kDqvSlgs9gxix+UPjfuLUlGjZZLGqySze+LHYZANvkTjJ1mcbj vQQhrvYjWeJe417DSsC0oFcWo5EKgVhNefOUf17QRVZ0N3+vIa1lDA9udrYWzD9FYdF2 pU3owSUG/Z0FqfPyKdQJGnicQvZXPmP3L32IrGTBxptWzLmyby4w8o56rTbuLUxAFwxC 3bezsZaCnNA1ALmFUe3/0MkQzVMUb0c7/60GT37ZdTtTeUdV+AxRADkovtRod+MRcWab ypzOOiQGg2+J1xxGggsoAiJd8rgLfuNp+FwTxioeTRBeo4WILlPjG6tXdLQdik/8xmcn bsVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=a70poZ7odeYYBLPLLZ80sygYko3DRWLFW4LhJYvtWV0=; b=KNGWf5rlk5Udf/3KtcBGsZnLJFs+AvKY/ffnR1QwnRploLX4bldjjuaw6Kdt3HNg7m kZ5/4W2XW8yIBwqf0HhLqkTRCLOURnt24OnMcnVQTfJeSqsHlJMrt+XW+NIF8++5xJMS kRPkJfu7MycwFTipDgu4GHJoC8B6OkB/GaCaJnKrBWSHu91YuLPf+5uRmChkH3RAPwNP 14cGf9vKRzVzaVRjmA7hDKmzGV2iCLGokENmESpd4pmu4xATscc4R5zh72q1P+wnsfrB 8Vl2lMbZgBVfCuA7JltnhNHI429mpEzKD/9+clHLybLXsq0YfE70XciIi/d8oYt6QEOc L4hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kempniu.pl header.s=google header.b=ffl2b9k3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kempniu.pl Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m7-v6si1856873pln.711.2018.02.19.21.27.58; Mon, 19 Feb 2018 21:28:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kempniu.pl header.s=google header.b=ffl2b9k3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kempniu.pl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751416AbeBTF0Q (ORCPT + 99 others); Tue, 20 Feb 2018 00:26:16 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:42829 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750710AbeBTFZF (ORCPT ); Tue, 20 Feb 2018 00:25:05 -0500 Received: by mail-lf0-f65.google.com with SMTP id t204so2429382lff.9 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=RB6bFtgRJm41m5hakjdFME/1GAsgFx0tSItMLP6eKk/9Xl7+5FQju81rzRpKa+yLFW 36TWf2/ItDawvq1teOZp+pEroQo+y8DFIaEnYr3sCbXf3uKMnwTgnLUgauGeQ6l8+7yV 3LYcQOTsk4ORyqZH8vNoN9hYOdE+q/BU4e162am0psLyaJ7FOiSIu/Ab19vopmhun9nK CjE2d/Hq/DoNTq5ICSw/ovrq7bwQyJ2tuBHgDX/QKRAuKE7s3ypqNYpLHuTTYfXImyZW bQJQB7AYwwtsr34hQ8xjjNo3NiGYYSSDCGAv1bkmgFNvE848577/4CSlge5kR0+HTdT6 nLyw== X-Gm-Message-State: APf1xPAMEq0+VcixvmrB01k1bnuJl16r1SkJ7gvhy5TcRx7qTKx5lZcj W4f6oGCayu3P9LormaeVpHhp8w== 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- 2.16.1