From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 540F9C433EF for ; Mon, 28 Feb 2022 11:17:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233592AbiB1LS0 (ORCPT ); Mon, 28 Feb 2022 06:18:26 -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 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