Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2899229pxm; Mon, 28 Feb 2022 08:09:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwVrCZRmqImM5ZtYDbVVZGscwyjriqRD3mADT1DqkMJIouom+nT19gQXa7hbcDhfyGiJucz X-Received: by 2002:a17:902:a98b:b0:14f:ae28:c660 with SMTP id bh11-20020a170902a98b00b0014fae28c660mr21453998plb.94.1646064578434; Mon, 28 Feb 2022 08:09:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646064578; cv=none; d=google.com; s=arc-20160816; b=X8nlaBoQi4UqJxXNcv+7YDeMvTDg19k8qAG8sIj2kBcIrPn65Y99fUCqTdz1z5lbeC KFvHpEtz8SkAHMq4C/Q8H8isIrAUZa2FlZTgqxXnb5R7q+WUgoDLCx6RRmNFlsyKyTDq ID7A1MVwi8/8xL+moVA4Qe4W1WSK97M/vg1S+Xy6AX1dEvzdJ7xMz/X9xqDsuR2T5zxE VN2qKdkpaGUAtZqal9HRzSt3NoYOYA4kluvZbz5hlT0XmD05Jz5isAx68QNSXMljCwDT P1F+26wHkZyR5t70RwLrUXWCUxlANY12XaR0qZGXziu1UCBg3eEba48mzdcI6yaxcf4i QAhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=d38OymjEnpY2Vl5hZ+FOH0JhAGTjeQ17DHm/sFqBaHc=; b=IAgQXsJvuCY61BTwX5gfiV4c1THwW1Nv7ztFKrSaNjEwBS4ov91w1yhp/CdV3gTFjt UFWaFLeXWpsVRTpZVN1mM6QvRz7LWomHXa9JHoG44R9tnd7Gj3O1gOGPK0pjKp8poSul 87p6v7KhRquz3KhPTZDovitUcpx3fY7SD1BMFxSeTT6pqoYAoqUpLLO/A3ZthDJrvi3c RzIuRragQfhFa1X/BRBYyjJv3nk76fXoMG2DBTC2kOTXBSF/QnYxjHoVwXIgj8GDARTM 1twasZKWvMm2SJ/y+tLu+qqMR6wmr9qd3PsQ+XLmJ0BoL3BxkK+wPNo+QsfJQS9RqJOG P5Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=kHta7B+7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ie11-20020a17090b400b00b001bc2bc71212si14663386pjb.121.2022.02.28.08.09.21; Mon, 28 Feb 2022 08:09:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=kHta7B+7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234079AbiB1LSZ (ORCPT + 99 others); Mon, 28 Feb 2022 06:18:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231856AbiB1LSN (ORCPT ); Mon, 28 Feb 2022 06:18:13 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E9F19FEE for ; Mon, 28 Feb 2022 03:17:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1646047054; x=1677583054; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=s9N00WUuaR+7M96AS0RHeuJkB2gYdo9QK+uWa+lBy+Q=; b=kHta7B+7f62d297MTEVUe5/qNVMfooBEsFGP3YiscmGYmZMkqP+gpfzZ rnUcM6aXcI0lfUeLkm6FFAQu7G4qX2vayODVfwuIKqRhiCStGaZ04wop6 8DTB70gy815G4kdvoh2ho3GxD47dUXWlmAMZ6aH6MvwbWnrCCfiwDGyFk xnMI1UUsKGk03ObHehUk40X1GcvLrv+85USHuAB3k1HF3KtMA6UI9zlY6 IkE0PREmI9NHOUY3HZux0wRGlFdXAtr0DO0H+3upqqCjpHeEQoZO+K7Iy RP1WhVYmuGY6Nl756Ysob9VnzwA3wNClDWz3JPPUgEaqDNo6P4YzBaw9X w==; X-IronPort-AV: E=Sophos;i="5.90,142,1643698800"; d="scan'208";a="155099351" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 28 Feb 2022 04:17:28 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Mon, 28 Feb 2022 04:17:28 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Mon, 28 Feb 2022 04:17:24 -0700 From: Tudor Ambarus To: , CC: , , , , , , Tudor Ambarus Subject: [PATCH v2 3/8] mtd: spi-nor: core: Use auto-detection only once Date: Mon, 28 Feb 2022 13:17:07 +0200 Message-ID: <20220228111712.111737-4-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228111712.111737-1-tudor.ambarus@microchip.com> References: <20220228111712.111737-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE, T_SPF_PERMERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case spi_nor_match_name() returned NULL, the auto detection was issued twice. There's no reason to try to detect the same chip twice, do the auto detection only once. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index f87cb7d3daab..b1d6fa65417d 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -2894,13 +2894,15 @@ static const struct flash_info *spi_nor_match_name(struct spi_nor *nor, static const struct flash_info *spi_nor_get_flash_info(struct spi_nor *nor, const char *name) { - const struct flash_info *info = NULL; + const struct flash_info *info = NULL, *detected_info = NULL; if (name) info = spi_nor_match_name(nor, name); /* Try to auto-detect if chip name wasn't specified or not found */ - if (!info) - info = spi_nor_read_id(nor); + if (!info) { + detected_info = spi_nor_read_id(nor); + info = detected_info; + } if (IS_ERR_OR_NULL(info)) return ERR_PTR(-ENOENT); @@ -2908,7 +2910,7 @@ static const struct flash_info *spi_nor_get_flash_info(struct spi_nor *nor, * If caller has specified name of flash model that can normally be * detected using JEDEC, let's verify it. */ - if (name && info->id_len) { + if (name && !detected_info && info->id_len) { const struct flash_info *jinfo; jinfo = spi_nor_read_id(nor); -- 2.25.1