From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from down.free-electrons.com ([37.187.137.238] helo=mail.free-electrons.com) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bmcli-00017Q-Ry for linux-mtd@lists.infradead.org; Wed, 21 Sep 2016 08:20:42 +0000 Date: Wed, 21 Sep 2016 10:20:07 +0200 From: Boris Brezillon To: Ricardo Ribalda Delgado Cc: Cyrille Pitchen , David Woodhouse , Brian Norris , Javier Martinez Canillas , Stephen Warren , Jagan Teki , Vignesh R , Marek Vasut , Ezequiel =?UTF-8?B?R2Fy?= =?UTF-8?B?Y8OtYQ==?= , =?UTF-8?B?UmFmYcWC?= =?UTF-8?B?IE1pxYJlY2tp?= , Furquan Shaikh , "linux-mtd@lists.infradead.org" , LKML Subject: Re: [PATCH] mtd: spi-nor: Add support for S3AN spi-nor devices Message-ID: <20160921102007.47181440@bbrezillon> In-Reply-To: <20160921101420.7ea87f2d@bbrezillon> References: <20160920154551.3494-1-ricardo.ribalda@gmail.com> <20160921090704.2cfebfc8@bbrezillon> <20160921101420.7ea87f2d@bbrezillon> 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, 21 Sep 2016 10:14:20 +0200 Boris Brezillon wrote: > On Wed, 21 Sep 2016 09:57:23 +0200 > Ricardo Ribalda Delgado wrote: > > > Hi Boris > > > > On Wed, Sep 21, 2016 at 9:07 AM, Boris Brezillon > > wrote: > > > Hi Ricardo, > > > > > > Please try to pass the version in your subject prefix (pass > > > --subject-prefix="PATCH vX" to git format-patch). > > > > > > > Sorry about that. > > > > > > > On Tue, 20 Sep 2016 17:45:51 +0200 > > > Ricardo Ribalda Delgado wrote: > > > > >> /* > > >> + * This code converts an address to the Default Address Mode, that has non > > >> + * power of two page sizes. We must support this mode because it is the default > > >> + * mode supported by Xilinx tools, it can access the whole flash area and > > >> + * changing over to the Power-of-two mode is irreversible and corrupts the > > >> + * original data. > > >> + */ > > >> +static loff_t spi_nor_s3an_addr_convert(struct spi_nor *nor, unsigned int addr) > > >> +{ > > >> + unsigned int offset; > > >> + > > >> + offset = (nor->page_size == 264) ? (addr % 264) : (addr % 528); > > > > > > Can you send a new version with > > > > > > offset = addr % nor->page_size; > > > > > > to see if kbuild test robot still complains. > > > > > > > This code: > > > > static loff_t spi_nor_s3an_addr_convert(struct spi_nor *nor, loff_t addr) > > { > > unsigned int offset; > > > > offset = addr % nor->page_size; > > > > return ((addr - offset) << 1) | offset; > > } > > > > > > When built like: > > > > wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross > > -O ~/bin/make.cross > > chmod +x ~/bin/make.cross > > # save the attached .config to linux build tree > > make.cross ARCH=blackfin > > > > Produces this error: > > > > > > drivers/built-in.o: In function `spi_nor_write': > > drivers/mtd/spi-nor/spi-nor.c:(.text+0xfeb8): undefined reference to `__moddi3' > > drivers/built-in.o: In function `spi_nor_read': > > drivers/mtd/spi-nor/spi-nor.c:(.text+0x10248): undefined reference to `__moddi3' > > drivers/built-in.o: In function `spi_nor_erase': > > drivers/mtd/spi-nor/spi-nor.c:(.text+0x1034e): undefined reference to `__moddi3' > > Makefile:956: recipe for target 'vmlinux' failed > > > > > > But I think I found the right combination: > > > > > > static loff_t spi_nor_s3an_addr_convert(struct spi_nor *nor, loff_t addr) > > { > > unsigned int offset = addr; > > > > offset %= nor->page_size; > > > > return ((addr - offset) << 1) | offset; > > } > > > > > > This one works fine on x86 and blackfin > > > > Sending v7 > > Wait. If you really want to manipulate an loff_t variable, you can do > > offset = do_div(addr, nor->page_size); > > Actually, you should have an intermediate u64 var, or just turn addr into an u64 (loff_t is a long long not an unsigned long long).