Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp841209pxb; Fri, 22 Apr 2022 12:19:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbrYkCK5sOWSD5YxtRqzoJJpWmk21h+27Ore5kau+nr5r+SAgJExvwmmw2tshL58ZfyDji X-Received: by 2002:a62:a504:0:b0:50a:ceee:5f4 with SMTP id v4-20020a62a504000000b0050aceee05f4mr6559010pfm.13.1650655173922; Fri, 22 Apr 2022 12:19:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650655173; cv=none; d=google.com; s=arc-20160816; b=Dy+vokQdXZgQgThin4PFRIShvKV+VLEganU/N7sYeCVbilCAf8SZr+TJEFEamch3Z/ HCJLLTdH8QiwTIkrpQU1chVy9ZSsm8oQOaFIb1GkEhIDBzZ2PNuAPbQthcbjF2k6eLGh 3aPtjC5OaNggc4AMfBX0uir9ik+JXHAVu/bdWEl/tqVwUclFfRiNnY6Ikhy7iEoeabN+ M038457Oju1fC9R4lP1FmgmiqrYBadj7xN54dfuirnstNNtGWz2bHIdFJAJ4L3nL1w4v 8lLVh+kEi2Nmj8ifXaN9T5tji2h/EU+PgDLkteozdkiSljMsSNeXlfMoeZUISlIioogv 83vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=mrEeMN9hF7GCeakXOW/eAFY+DlHb48AaOGpylclP/cU=; b=xKzYPp5qWCj8lOsX1Wlez5ZFpPLq/yWpiAIvGHBoHNDKUttEodaEbJYvS3AZU/ADjg jtuVhc1CzmJ9LPMD3zf9pCKwfDLcAqNQkcTqbN9XsnQcZ5IuBmf3W5hH4kDACfiBnz3d slyYz1IKqJDN6OFkOgyeF2alDQi1IgZGCIdG7OW8AkMDaN9jjW4Fj0Mh6jBpAfrevHPs T9sVuPl+6Arl/R6reTHIpENyX262s7gKp9AAQEHmuLG2Vu+7wtw4zvIcJA+6ss+JXy64 LbvzS53UAyEyT5VYM3UA+yKkWdBu5JNekQ4/j/puXnScRj5jugGluHZz4l+0wMjhWTDW aJrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=H4k0m1LY; 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 Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y2-20020a636402000000b003aaf01e4f5esi291773pgb.240.2022.04.22.12.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 12:19:33 -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=pass header.i=@walle.cc header.s=mail2016061301 header.b=H4k0m1LY; 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5A8171569C0; Fri, 22 Apr 2022 11:34:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350620AbiDSKV2 (ORCPT + 99 others); Tue, 19 Apr 2022 06:21:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240084AbiDSKV1 (ORCPT ); Tue, 19 Apr 2022 06:21:27 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 492A715FD7 for ; Tue, 19 Apr 2022 03:18:45 -0700 (PDT) Received: from ssl.serverraum.org (web.serverraum.org [172.16.0.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 0976C2223A; Tue, 19 Apr 2022 12:18:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1650363523; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mrEeMN9hF7GCeakXOW/eAFY+DlHb48AaOGpylclP/cU=; b=H4k0m1LY19571X2FaPU2N8jIeRtOGOovVkCIVDb2sDorgEJmNe7SBEcKhTOhrHux25ggwS 56lRUMJkEw0whQOA5rKr77p/fXFakpHdpPOWDP3VV7WbdYzFcRoOCymJkZtalTDG4xUa/m 7itzCKp+W2vxUxU7KJA1tOPFHmOF/OY= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 19 Apr 2022 12:18:42 +0200 From: Michael Walle To: Tudor Ambarus Cc: p.yadav@ti.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, nicolas.ferre@microchip.com Subject: Re: [PATCH v3 3/9] mtd: spi-nor: core: Use auto-detection only once In-Reply-To: <20220411091033.98754-4-tudor.ambarus@microchip.com> References: <20220411091033.98754-1-tudor.ambarus@microchip.com> <20220411091033.98754-4-tudor.ambarus@microchip.com> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <8a12e7d841827388d1f8839d8afdfe5c@walle.cc> X-Sender: michael@walle.cc X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE 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 Am 2022-04-11 11:10, schrieb Tudor Ambarus: > 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; > + } That is unnecessary, as spi_nor_match_name() doesn't return an error code, just NULL or a valid pointer. Apart from that: Reviewed-by: Michael Walle > /* 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;