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 X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E131C433F5 for ; Fri, 17 Sep 2021 13:06:51 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E1E4D60E97 for ; Fri, 17 Sep 2021 13:06:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E1E4D60E97 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=foss.st.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3E5598319C; Fri, 17 Sep 2021 15:06:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=foss.st.com header.i=@foss.st.com header.b="UbKHdwvX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7A9D282DA1; Fri, 17 Sep 2021 15:06:45 +0200 (CEST) Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 774E083217 for ; Fri, 17 Sep 2021 15:06:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=prvs=3894b146a8=patrick.delaunay@foss.st.com Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18HAX6Rw022052; Fri, 17 Sep 2021 15:06:36 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=selector1; bh=MIuUCtHyJZIFdGSzeLawigZRSO1DOiP7rQrL0x8bt+4=; b=UbKHdwvXnG5XAa0Z5Ta0X+bAWdI3jmx62yXg4tS8PANHm7KaB5M5xKJkYZYT+Rk5hwEB 703bl8ydHa1iSvkoyUE7NdzvWHkOL6mXuRiOVOy1kS7jUlk/V7NGef0bmCN3E+xeuFmY VHixq9L/LWzMf/QWxsdwhKicL/U6YGxV7k6ap0hyEjDwQHK2WGe6m0bzTfx8J6yRzjkQ IjB/D7sGATIZDP+UZ0/hseOx+7Pq3MOCIzFiLjfMIAw2d9JAFx2oIa9mqiD5cwmsMN5c 7KW0KY/NBxRWeyIXaO1S4yv92vnMrV7XEutlQgF3MBXkFXFSCdlhPr20zNmxFWcdSNCu Yg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 3b4msyafsa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Sep 2021 15:06:36 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id EF8E910002A; Fri, 17 Sep 2021 15:06:35 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 74B822C38B9; Fri, 17 Sep 2021 15:06:35 +0200 (CEST) Received: from lmecxl0994.lme.st.com (10.75.127.50) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 17 Sep 2021 15:06:34 +0200 Subject: Re: [PATCH v3 2/2] mtd: spi: nor: force mtd name to "nor%d" To: CC: Priyanka Jain , Heiko Schocher , Marek Vasut , Jagan Teki , Miquel Raynal , Christophe KERELLO , Patrice Chotard , =?UTF-8?Q?Pali_Roh=c3=a1r?= , =?UTF-8?Q?Marek_Beh=c3=ban?= , Vignesh R , U-Boot STM32 References: <20210916140118.874028-1-patrick.delaunay@foss.st.com> <20210916155040.v3.2.Ia461e670c7438478aa8f8939209d45c818ccd284@changeid> From: Patrick DELAUNAY Message-ID: <5dfd98da-2efd-23e2-64db-ec41dc9b6c6a@foss.st.com> Date: Fri, 17 Sep 2021 15:06:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210916155040.v3.2.Ia461e670c7438478aa8f8939209d45c818ccd284@changeid> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG1NODE2.st.com (10.75.127.2) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-17_05,2021-09-17_02,2020-04-07_01 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hi Marek, > Marek VasutSept. 16, 2021, 5:27 p.m. UTC | #3 > On 9/16/21 4:01 PM, Patrick Delaunay wrote: > [...] > > @@ -3664,6 +3666,11 @@ int spi_nor_scan(struct spi_nor *nor) > >       struct mtd_info *mtd = &nor->mtd; > >       struct spi_slave *spi = nor->spi; > >       int ret; > > +    int cfi_mtd_nb = 0; > > + > > +#ifdef CONFIG_SYS_MAX_FLASH_BANKS > > +    cfi_mtd_nb = CONFIG_SYS_MAX_FLASH_BANKS; > > +#endif > Are we covering all the NORs (HF and co.) with this ? Yes, except if I miss something any NOR (including hyperflash) wich use the CFI interface / CONFIG_FLASH_CFI_MTD define the the 'nor%d' name with the calling stack: initr_flash() => flash_init() ==> cfi_flash_init_dm() ==> cfi_mtd_init()   "nor%d" wich use loop on CONFIG_SYS_MAX_FLASH_BANKS I have only one concern today... if one cfi bank is missing (not activated in DT by example) and CONFIG_SYS_MAX_FLASH_BANKS_DETECT is not activated some holes can be done in index example: with CONFIG_SYS_MAX_FLASH_BANKS = 2 but with only one NOR on the board => "nor1" is absent and we have only 2 MTD device named "nor" - "nor0" => NOR or HF, first CFI bank - "nor2" => SPI-NOR (first) but I don't think that it is blocking > >       /* Reset SPI protocol for all commands. */ > >       nor->reg_proto = SNOR_PROTO_1_1_1; > > @@ -3715,8 +3722,10 @@ int spi_nor_scan(struct spi_nor *nor) > >       if (ret) > >           return ret; > > > > -    if (!mtd->name) > > -        mtd->name = info->name; > > +    if (!mtd->name) { > > +        sprintf(nor->mtd_name, "nor%d",  cfi_mtd_nb + dev_seq(nor->dev)); > > +        mtd->name = nor->mtd_name; > > +    } > >       mtd->dev = nor->dev; > >       mtd->priv = nor; > >       mtd->type = MTD_NORFLASH; > > @@ -3821,7 +3830,7 @@ int spi_nor_scan(struct spi_nor *nor) > > > >       nor->rdsr_dummy = params.rdsr_dummy; > >       nor->rdsr_addr_nbytes = params.rdsr_addr_nbytes; > > -    nor->name = mtd->name; > > +    nor->name = info->name; > >       nor->size = mtd->size; > >       nor->erase_size = mtd->erasesize; > >       nor->sector_size = mtd->erasesize; > > diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h > > index 7ddc4ba2bf..8c3d5032e3 100644 > > --- a/include/linux/mtd/spi-nor.h > > +++ b/include/linux/mtd/spi-nor.h > > @@ -561,6 +561,7 @@ struct spi_nor { > >       int (*ready)(struct spi_nor *nor); > > > >       void *priv; > > +    char mtd_name[10]; > should be 14, because nor%d\0 can be up to 14 bytes long. normally DM_MAX_SEQ = 999 (but never used) but Ok with you for 14 with "nor" = 3 + "%d" = 10 for max u32 value + "/0" = 1 for cfi_mtd_names => 16 byte used with "nor%d"     static char cfi_mtd_names[CFI_MAX_FLASH_BANKS][16]; for nand => 8 bytes (./drivers/mtd/nand/raw/nand.c:59)     static char dev_name[CONFIG_SYS_MAX_NAND_DEVICE][8]; for spi-nand => 20 bytes (drivers/mtd/nand/spi/core.c:1169)     mtd->name = malloc(20); Patrick