Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2851354imu; Sun, 6 Jan 2019 11:33:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/VUF7hQhSZc2D8yoYOtw0xGngcqzwLv/SeRFHFyhxhD0ebuA7TkpR++J2JY30YMrlgoeutq X-Received: by 2002:a62:fc52:: with SMTP id e79mr61070321pfh.8.1546803187550; Sun, 06 Jan 2019 11:33:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546803187; cv=none; d=google.com; s=arc-20160816; b=d8WX578/zTYE+wiXnBNEhxjxhK4QJcNl/90BMnV7Z+MZ65N79eKyDXn/WrI2/+8+YT o8/wAhZihITmxmesSOK2WJicZRVF1+HDQXXJapzoYNM74Vf6thg398JjuPHfZs5bGvZd HV33A7EPPoTv/yDThd6i218SwIeZ6ixeg8jaKrxLnvF/oCwal8ZPDJpV5BofkTuj8gCr qn6KoMZeQ1QQUAfXtK9jsnqHDs/4aMGsz0DCVxRN8zx5E3XDXyZ1KwEDuA3d/y30O3au 7CyWyfE9+PsioVfzGILhsGd2jgZzjWWlOpI+H0B5YYtDcXwlr2MkrpqdzKnuleBlUsKn /+Kg== 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; bh=WwcDpo9PA6URGrBAqHueDDGl8z5tXAWd0+lBz6+Kk9k=; b=LTExE/LmcUBdIiFfEVJ6k33xsOvC/9TepQqDfjBovnSRQtoh4RcMIx1qvsXHkofNHX 2TzLia1mk0HVoEaTdZNGfpnMBi+l+ZyT5zz6bj3yZuMUIGuk1HIeZ2zcn+Wp/PqjlJAP 8KlDNNVyV4OUkDP60HYGTq1qs9z6JkBJ1jZZ1GM+aa5mbrmOxepHwv3QCrR0RFv36OHC h/WpMbaKz26aZ6XQ/sVAvyL6kMZkkmlDP1v10xS18fzozacSN4AnGwphYKuZvnpIsmOn gO8LC1T1I6ZtWC62o2wQfK1y5vOEt3kJLftyTMvUECVDqHE0IihOLB86qJJrEcV5SJZn bshw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d12si5228073pga.506.2019.01.06.11.32.52; Sun, 06 Jan 2019 11:33:07 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726492AbfAFT3Y (ORCPT + 99 others); Sun, 6 Jan 2019 14:29:24 -0500 Received: from smtp3-g21.free.fr ([212.27.42.3]:36443 "EHLO smtp3-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726050AbfAFT3Y (ORCPT ); Sun, 6 Jan 2019 14:29:24 -0500 Received: from localhost.localdomain (unknown [IPv6:2a02:8108:4840:8f74:143e:fcd5:beb7:2140]) (Authenticated sender: albeu) by smtp3-g21.free.fr (Postfix) with ESMTPA id 4D1F213F879; Sun, 6 Jan 2019 20:29:16 +0100 (CET) From: Alban Bedel To: Srinivas Kandagatla Cc: linux-kernel@vger.kernel.org, Alban Bedel Subject: [PATCH 8/8] nvmem: core: Avoid useless iterations in nvmem_cell_get_from_lookup() Date: Sun, 6 Jan 2019 20:28:20 +0100 Message-Id: <20190106192820.12558-9-albeu@free.fr> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190106192820.12558-1-albeu@free.fr> References: <20190106192820.12558-1-albeu@free.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Once the correct cell has been found there is no need to continue iterating, just stop there. While at it replace the goto used to leave the loop with simple break statements. Signed-off-by: Alban Bedel --- drivers/nvmem/core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 176fe72f4eb5..9334f074defb 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -977,7 +977,7 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id) if (IS_ERR(nvmem)) { /* Provider may not be registered yet. */ cell = ERR_CAST(nvmem); - goto out; + break; } cell = nvmem_find_cell_by_name(nvmem, @@ -985,12 +985,11 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id) if (!cell) { __nvmem_device_put(nvmem); cell = ERR_PTR(-ENOENT); - goto out; } + break; } } -out: mutex_unlock(&nvmem_lookup_mutex); return cell; } -- 2.19.1