Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp857912pxb; Fri, 22 Apr 2022 12:47:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRqu4ZKh+xGH/3cAfZAcd6B8XN+nXxPWVhG1yRedFfiTEu5yPKAXX77BP5VcSViISwUPE0 X-Received: by 2002:a05:6a00:21c8:b0:4c4:4bd:dc17 with SMTP id t8-20020a056a0021c800b004c404bddc17mr6530219pfj.57.1650656842155; Fri, 22 Apr 2022 12:47:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650656842; cv=none; d=google.com; s=arc-20160816; b=C8pO3VczSIO6SBTPXTY3+AwFFAO6xO1N/mMzfTIGewiuh4RAAkBA5cNhcYSM1RLKkn qFn/SzXm9GnxFslKHgE5mEReI6jW3sIf2gF1DPGRiW96cjjLL57WvivUwCHXR57IEs01 f1t+j4YlidVZZLkWoWEFPaQ0ZOxxZzlMX4s9Oc/lk5gUV0WXy0uh9O8ehKWBiQzJPBPD 2CYOzF+Tf9olNKQR/ofsfvy7H4j0JNQvsG7JiYdHrSCeTMJhssBW6yFVfLsfD7FzqIkS zAo4ogkiA4n+uDBUdQZ/3YpnV1LjVBwBlouWi/CGCAbeNoHll64IvdfxfdoAvWNHcB5M XYeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9gasxuhjKsknOjBQ7Lu0eRSpIFqA65jpKhr8t+Z92rs=; b=MCUvHoVwrLKgeUdSgzVfUmOMnoqewC/mNPKhvkctf9C4EoAKVrS85mZPLAbTy+pXHk cfao3O9FJbfLyWSz0R2CNVDP8usfqFkJ9Uv9doXUiMawouVPdHwF/GQ5Udi6LE2mSkNC gazQqlOi0abaNJxD70oTPZbOCMxHOi37k4vd9HBNQm/70JG0ePwzYve2urZdo8tq8Zc/ 2r2M4aSIY7aN3hzSeiAVnN2DUJduwSckErwvYr9Bphc9enCwUHbrXrEAXm6MJJLTCjxS RjTscypRUr2BQo6YDCvGbKjZjQ4EVk2R2xdb6pMg7xd4/fI5rol3Tvx0Rax3hxjEon0y blhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=wkCDCNWX; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u36-20020a634724000000b003982527600dsi9375326pga.185.2022.04.22.12.47.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 12:47:21 -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=@ti.com header.s=ti-com-17Q1 header.b=wkCDCNWX; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A7DB1C3E82; Fri, 22 Apr 2022 11:49:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231477AbiDUNUQ (ORCPT + 99 others); Thu, 21 Apr 2022 09:20:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231463AbiDUNUM (ORCPT ); Thu, 21 Apr 2022 09:20:12 -0400 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 580FB1F61F for ; Thu, 21 Apr 2022 06:17:21 -0700 (PDT) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 23LDGwnA039803; Thu, 21 Apr 2022 08:16:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1650547018; bh=9gasxuhjKsknOjBQ7Lu0eRSpIFqA65jpKhr8t+Z92rs=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=wkCDCNWX3QlDsP3307ZTUwvtFHweDdbWEHsJs2a72zcdNkLK07ekZ/vmh+5VuA2vY zJ1oKiXIhQ8Pv6Tq5WoxJo9v+6CezzjFyeLpd1WXt4YbTEC7aqjLj9AJzYFbLyAzHf 5j5c9ETuYBUxbOXQZiyXF/FG3unNOs57PD/It1TE= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 23LDGwH3064946 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 Apr 2022 08:16:58 -0500 Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 21 Apr 2022 08:16:58 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Thu, 21 Apr 2022 08:16:58 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 23LDGvQk073404; Thu, 21 Apr 2022 08:16:58 -0500 Date: Thu, 21 Apr 2022 18:46:57 +0530 From: Pratyush Yadav To: CC: , , , , , , Subject: Re: [PATCH v4 03/11] mtd: spi-nor: core: Use auto-detection only once Message-ID: <20220421131657.d6hm7rltyxcb24wo@ti.com> References: <20220420103427.47867-1-tudor.ambarus@microchip.com> <20220420103427.47867-4-tudor.ambarus@microchip.com> <7f570c32-d0be-97ba-0a1b-9aca93cfbbf1@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <7f570c32-d0be-97ba-0a1b-9aca93cfbbf1@microchip.com> X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 On 21/04/22 07:18AM, Tudor.Ambarus@microchip.com wrote: > Hi, Pratyush, > > I forgot to remove few checks, would you please remove them when applying? > See below. > > On 4/20/22 13:34, Tudor Ambarus wrote: > > 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 > > Reviewed-by: Michael Walle > > --- > > 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; > > As Michael suggested spi_nor_match_name() returns NULL or valid entry, so this > check is not necessary, let's remove them. > > > + } > > /* 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; > > also according to Michael, this change is not needed as spi_nor_get_flash_info() can't > return NULL. Here we can keep the code as it was. Let me know if you want me to respin. TBH I don't think a NULL check here hurts much since the behaviour might change later, and error paths don't get exercised as often. But I have made both changes when applying. You can double-check at [0] if you want. [0] https://github.com/prati0100/linux-0day/commit/67d913746833ee54bf4c661040f3ef13657dffd8 > > > + else if (IS_ERR(info)) > > return PTR_ERR(info); > > > > nor->info = info; > -- Regards, Pratyush Yadav Texas Instruments Inc.