Received: by 10.223.185.116 with SMTP id b49csp1483053wrg; Sun, 11 Feb 2018 13:10:44 -0800 (PST) X-Google-Smtp-Source: AH8x226Mptv2WCg/ei4XLRg+cKE8IP8xcv42FaI8wkZ3cvn4gfodK4m9JYmqgJHpjEwAEdMjous2 X-Received: by 10.98.67.68 with SMTP id q65mr122701pfa.129.1518383444388; Sun, 11 Feb 2018 13:10:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518383444; cv=none; d=google.com; s=arc-20160816; b=ILWgdQ+mjCetzrDpm4EX0v+Sk/i8TnzCESamYwIp74nMJtFDvtzC65w4z5FVi4T73Z C+6WZDpNnISaAoYziZ99YeKqcSevOAWthSGI5WM6wB4ahkEqFKtk29VlnRp/nuCQQt1l /nMh/rA6atRBbLV3WZ0GXvxVKGhe4iR8/QbNQGqvXuIbMSEQ8mmwGN5+9c5GLryjBrvE W7q2472JPqllQhXo0wXl8Ko35TJmVZNhvEE5udbvAffPa/NKk3/MlwVNUgvCtgPr30sA fTA0EhYhhgbAO5pV5oDq+sp8mnXPXgg2N0RE3wNXgoG4ezDpwRlSKbRZnrF3gMGcCx4g O57g== 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=OAXqjppfVB4UyWuc7A9JoOo4cumo7OeLsSsKGkNKApljl9dJYJlJ8vSi8+3zAD6m2z yWiwu1DM27D0MmKT2lzMXGIRlAH2zyk4D3kdSjIY/dt6+Gz0YW4cLYewZ82M6W9JoDMj 6gu+tWtZXVpC1Gknx0TvsnQMMA6g3L09S7u+4b4Vjwln2N1iqrvFPeYZob9ikj1+NdF0 Q2dMfw4zcbVt8WftliIo+6URC5bNGw+Q5vA1LMcZ8Jhlo9s2f7Jj8Rb47LZ9VeFbu18y icECat80cjYfqhh1AqezYOPKTwlBTQWYcbTu6tVb5K5UduSg7cSdI4GYOYdXeu/4UIYY mhxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kempniu.pl header.s=google header.b=HxTgpmgx; 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 z8-v6si3071120plk.316.2018.02.11.13.10.29; Sun, 11 Feb 2018 13:10:44 -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=HxTgpmgx; 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 S932226AbeBKVJ3 (ORCPT + 99 others); Sun, 11 Feb 2018 16:09:29 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:38141 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932179AbeBKVHm (ORCPT ); Sun, 11 Feb 2018 16:07:42 -0500 Received: by mail-lf0-f66.google.com with SMTP id g72so17904214lfg.5 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=ZtZv002uupbCTpjCiQ42HdJYmF0JEjSvKPVdk2lQo9bNfS0iDZJWQiy2ujhUEKSmBb V0ID0w9pwMPZGUWEoJi3DZs2uRm056A6Bo3WAczEaengNlTOlQY4PcPBHH6AFi8mdiFG cThug78fE2rK+7JvRAXJ7/HXnEMsqEsrN3AShLZU8BkDBnSb00m0fau4njuzRD46e+t4 KZoMrI5Z4342V00w/XLppYsiBIvRtXdZPJ2t9+gIeccVm88C3Ud5xPDa0e3GRdtfQilv yoUGrJPAipu8iHQ+BExf3ru7sqmszG8f6PCk4WEPNucIf5nTpVWGytcfln4rjf0Es7xM 7Hcg== X-Gm-Message-State: APf1xPDhqTpxbmQFb9W6CcBF50OGns5rVdq2UDYuDpDALFFayn40hWX4 GQAVjM8Tsb6bmFOyb2IwtcROmQ== 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 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