From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHo4k-0004cd-Tm for linux-mtd@lists.infradead.org; Wed, 31 Oct 2018 10:50:16 +0000 Date: Wed, 31 Oct 2018 11:49:51 +0100 From: Boris Brezillon To: Yogesh Narayan Gaur Cc: Mark Brown , "linux-spi@vger.kernel.org" , David Woodhouse , Brian Norris , Marek Vasut , Richard Weinberger , "linux-mtd@lists.infradead.org" , Vignesh R , Cyrille Pitchen , Tudor Ambarus , Frieder Schrempf , Miquel Raynal Subject: Re: [PATCH v2 5/7] mtd: devices: m25p80: Use the spi-mem dirmap API Message-ID: <20181031114951.55f662cc@bbrezillon> In-Reply-To: References: <20181030133638.3322-1-boris.brezillon@bootlin.com> <20181030133638.3322-6-boris.brezillon@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Wed, 31 Oct 2018 10:28:04 +0000 Yogesh Narayan Gaur wrote: > > +static int m25p_create_read_dirmap(struct m25p *flash) { > > + struct spi_nor *nor = &flash->spi_nor; > > + struct spi_mem_dirmap_info info = { > > + .op_tmpl = SPI_MEM_OP(SPI_MEM_OP_CMD(nor- > > >read_opcode, 1), > > + SPI_MEM_OP_ADDR(nor->addr_width, 0, 1), > > + SPI_MEM_OP_DUMMY(nor->read_dummy, > > 1), > > + SPI_MEM_OP_DATA_IN(0, NULL, 1)), > > + .offset = 0, > > + .length = flash->spi_nor.mtd.size, > > I want to understand the sequence of calling up of this routine from drivers/mtd/spi-nor/spi-nor.c file. > Because till point of JedecID read and SFDP command read mtd.size is not being populated and having value as 0. This would make length as 0. When the dirmap is created mtd->size has been initialized already. But you're right, nor->read() might be called before the read dirmap has been created (SFDP read), which will lead to a NULL pointer exception. > > Did these read follow different path? Nope.