Received: by 2002:a05:6512:3d0e:0:0:0:0 with SMTP id d14csp16753lfv; Tue, 12 Apr 2022 15:24:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4kuDJlbCb9R5fS+IyfOf6E/R3rR9jcZrdzgJF+wY8LU0FfwiomdUTbErAEw0mJFEYtTyT X-Received: by 2002:a63:f217:0:b0:39d:a9ed:2160 with SMTP id v23-20020a63f217000000b0039da9ed2160mr1988998pgh.111.1649802249195; Tue, 12 Apr 2022 15:24:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649802249; cv=none; d=google.com; s=arc-20160816; b=N4rLjrVsCDjJo+VVFlZxdxUuopk1gUiLbZphWka0aPb5DHnd46SzzsC0wytXyBxdlS Csv85HTgbuHKEyiSjJ/ZAoaQBZSQK7fhnLkxKW1I2R/K9aLn2N2F2ns9I1oVqXruafPT ENdzGfXPhc5yJG3xjcXCZt8lu1nFqQZSDzleRlt8zh23LphU1uqSTXlwy/oqehhP7Say wbasD8sml5mzHgm67HhZI2lPlAWqphluGufEcJMEELAoMveN4vLDvqsEfrwZdkTWWa+f kdSkzT/uW7LZUPvy/qM0O9MAiLXcteyhNWqCgulkW2RU/LFwBswZug0aDTAaRGQS4eWd AQjQ== 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=jFqc0zqXkPN02ImUBw3Qm6OCP7boYgkGpJiACpAseG4=; b=03K76xP/DqvFsEAQuaptoSDPaLhHch9tIb44gnYjGkS3RgphQpFNWkMJOW87ezdjwZ GIcHIX+8OCx997KVAOaZ2/KVuHGIbJGih/KUuIwGXHsQjfox1NiH4zRrQaVHI39w8N+5 d2aMA4Whf/4yowRHcWcMIS8ZK+g2LwfkKeGeqsz5mrQ5mIeV7n1po4vyST5Nnh/LFcx2 gR8hRMA7yXlm3hqsRFcCDcouXmxdxkuq68+/fcRD159JrwaFHP+rPyXKnv4MaeYnt2z0 YsGCcPbC4QoWEZDJbOKK/L+9vCpQFwkXyWmQmtGVoFqR7pKUlCwXwmm1UIbbY7FyQfzw Xp2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=e0mLrdJ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id lp17-20020a17090b4a9100b001ca56c5e70asi2544973pjb.177.2022.04.12.15.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 15:24:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=e0mLrdJ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 64D5F151D14; Tue, 12 Apr 2022 14:04:01 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344212AbiDKJNH (ORCPT + 99 others); Mon, 11 Apr 2022 05:13:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344205AbiDKJM7 (ORCPT ); Mon, 11 Apr 2022 05:12:59 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C689B19014 for ; Mon, 11 Apr 2022 02:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1649668247; x=1681204247; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AkkbZWjZRlH9312vjiduNujt5vMVxf/XLruKiXMySs0=; b=e0mLrdJ2gjKNFgIaAp1W6Rj6NISj/Sv70zJPjcSosC8db/AQp1cMCXut e2Ei2geyqm7VoO7lqKaBooTzwiHRLHeBfzKAJtfdpy48AX3kKl7IpWSkQ ffLfa/J2uPbxLXfOtx9RqFGwZhY9zAxM7P1yjRvHEGhcKe0I93pw1BqEo H+EjSSI7xcfzxkX3Mq+e9B+L4m5DCw8bh/1qN0f6Ev9QY67rrcbAWCG+t BZDMw3oKcYpvksasKPo2ROUEKrLQoCdG+3IE4Hu2Y0IHqCGQGO0DhDw+n 4X5NNNKqsaitLzFsS5iRmfTrRTz782/1WmSTq6rTxj7lFaX34gnVFdUiV A==; X-IronPort-AV: E=Sophos;i="5.90,251,1643698800"; d="scan'208";a="159624238" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 11 Apr 2022 02:10:47 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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, 11 Apr 2022 02:10:46 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Mon, 11 Apr 2022 02:10:43 -0700 From: Tudor Ambarus To: , CC: , , , , , , Tudor Ambarus Subject: [PATCH v3 3/9] mtd: spi-nor: core: Use auto-detection only once Date: Mon, 11 Apr 2022 12:10:27 +0300 Message-ID: <20220411091033.98754-4-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411091033.98754-1-tudor.ambarus@microchip.com> References: <20220411091033.98754-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 --- v3: - caller of spi_nor_get_flash_info now handles NULL and translates it to ENOENT. drivers/mtd/spi-nor/core.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index b9cc8bbf1f62..b55d922d46dd 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -2896,13 +2896,14 @@ static const struct flash_info *spi_nor_get_flash_info(struct spi_nor *nor, { const struct flash_info *info = NULL; - if (name) + if (name) { info = spi_nor_match_name(nor, name); + if (IS_ERR(info)) + return info; + } /* Try to auto-detect if chip name wasn't specified or not found */ if (!info) - info = spi_nor_read_id(nor); - if (IS_ERR_OR_NULL(info)) - return ERR_PTR(-ENOENT); + return spi_nor_read_id(nor); /* * If caller has specified name of flash model that can normally be @@ -2994,7 +2995,9 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, return -ENOMEM; info = spi_nor_get_flash_info(nor, name); - if (IS_ERR(info)) + if (!info) + return -ENOENT; + else if (IS_ERR(info)) return PTR_ERR(info); nor->info = info; -- 2.25.1