From patchwork Mon Jan 28 15:55:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 156798 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3690976jaa; Mon, 28 Jan 2019 09:35:12 -0800 (PST) X-Google-Smtp-Source: ALg8bN5+Vci9qMh4LfDS8YRBVTbOY9U+26fHHhVam5bkKz1/tRdGWTOz/znxDD/MFjLA7WVDdDAS X-Received: by 2002:a17:902:24a2:: with SMTP id w31mr22210233pla.216.1548696912161; Mon, 28 Jan 2019 09:35:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548696912; cv=none; d=google.com; s=arc-20160816; b=VxV4yZNNHlkA2P8o8S5OdP/+s78/SEwFJd4O1OIQrJ8ktyu7tFGqa9x/Z+xoWqnpgk uAuq1dYqEKQajc6UEexQ+OfPdqAfihyUI/GwDfTjXq9nRMonLRxK78aqx4kgxWyoO9Up dpJMZ85ZF+bkeOxm5bv/ggDzqY3XIwahM/MAc7AZNI+lUDGRzLKpQusN8AUZ/8IigmRn q5/3WhLAkPy8aZ3OYHIG1U2QnSyw3qLyUR5DKgp6tPzyyrA1uja+eJzzqq/hV5q8azrE QbiGYg6nIZiJ2PxsQdkNIkUGfZfHAYrtcMBD8crVrL6LYtse9NU87/E6FA4tFk/zzbXo Jgtg== 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; bh=slmqeLOsa8d5rsqPApJzFEU02ClYEPT68CCNN/PckQ4=; b=fDWGOXCSrb+51KaCwF6MmBFm+tDhO/WDGy/4yKKKABgSYx/j6M6z9nuc1k71AvnU/3 i0dtKKVGdT0E16bng6cKSzdRLi7ntbAkKzuVZK9j08ssSoO+EBIFjbvjBNmwyJcaxLdK swogJxCTuSGyPfwcb7VypEcyuQkHGwlhLXDEEEXrRdPOjoKG8cGUEU4p32odjGeBd1c5 13X3BvU+jtncmSA/q37wrRUTY3X4N0SAen7iAu829ceIYkSieWLBCp/RSURzila1XweE XU+Ex/70KFLUnkxG1G5C8NbgDhYGJUHvMKc5gG02XG0lHK65jeHJX2cbGKDE0HCEvTiy gjdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VF77ai8z; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 35si19157045plf.177.2019.01.28.09.35.11; Mon, 28 Jan 2019 09:35: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=@linaro.org header.s=google header.b=VF77ai8z; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729910AbfA1Pzb (ORCPT + 31 others); Mon, 28 Jan 2019 10:55:31 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36371 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729434AbfA1PzZ (ORCPT ); Mon, 28 Jan 2019 10:55:25 -0500 Received: by mail-wr1-f65.google.com with SMTP id u4so18632232wrp.3 for ; Mon, 28 Jan 2019 07:55:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=slmqeLOsa8d5rsqPApJzFEU02ClYEPT68CCNN/PckQ4=; b=VF77ai8zHtPKwML6aprf3N7NLb5YqyWZv6bQ/tnh93JpldM6Zrmc67BYxkg5nWwt6O t+IDXf39LvwmLE5l26SuQ48Gcf+C2NHUNboRbelNGTjQPdNPLsICqCsmqZC2wBFOjjy7 Vla2rE2ojk0JDI6juZ7osloJP2gnADIrWd/Ik= 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=slmqeLOsa8d5rsqPApJzFEU02ClYEPT68CCNN/PckQ4=; b=l6k1t7gnCbM+jEqNyeR+514C8/maC3edo0NXjD2zn4lQHYeP2fWp13Cq8D+gu1k3oe FEKRldpq3IE3njZASEqlhtp0GHbrIJUV9Jf3H0p145KY6H6VsoUNwiznH5bC7nVjGgsz TVCJxTtVE3qDiz78RwKuhtZ0k1Q9CwyIrHxVXuiX9DCtX2RryRmnt6Ee291oPF9o4ul1 fCxOL3bcFzjn1E/WW3PPUg88Pd9pV48BZDgt6qEkwHsKXTWscP8795Ihz2ZB1g+vzz49 nF/odAqqMXjFdbmoIc7/SuVAIlDitkzYz6VhmXNPi3qY03i1j8UG17ARKOEdx6+u0TfX xH8w== X-Gm-Message-State: AJcUukcRYwTxjWpS+B9uYBYM04IcJkUpU7uw9F2xIaNEPJ+7lUF60pqB cBcnNHFu9KvmTPFgaiwpRuIJeQ== X-Received: by 2002:a5d:678b:: with SMTP id v11mr23905340wru.245.1548690923025; Mon, 28 Jan 2019 07:55:23 -0800 (PST) Received: from srini-hackbox.lan (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.gmail.com with ESMTPSA id p6sm145140485wrx.50.2019.01.28.07.55.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Jan 2019 07:55:22 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 13/13] nvmem: core: Avoid useless iterations in nvmem_cell_get_from_lookup() Date: Mon, 28 Jan 2019 15:55:06 +0000 Message-Id: <20190128155506.25566-14-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190128155506.25566-1-srinivas.kandagatla@linaro.org> References: <20190128155506.25566-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alban Bedel 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 Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 5400017ef616..9dd07eae1f3e 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; }