Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752092AbdFMIa6 (ORCPT ); Tue, 13 Jun 2017 04:30:58 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:46232 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751753AbdFMIa4 (ORCPT ); Tue, 13 Jun 2017 04:30:56 -0400 Date: Tue, 13 Jun 2017 10:30:43 +0200 From: Boris Brezillon To: Masahiro Yamada Cc: Cyrille Pitchen , Richard Weinberger , Marek Vasut , David Woodhouse , Chuanxiao Dong , Linux Kernel Mailing List , Dinh Nguyen , linux-mtd@lists.infradead.org, Masami Hiramatsu , Artem Bityutskiy , Jassi Brar , Brian Norris , Enrico Jorns Subject: Re: [PATCH v6 00/18] mtd: nand: denali: Denali NAND IP patch bomb Message-ID: <20170613103043.622a2c98@bbrezillon> In-Reply-To: References: <1497330250-17348-1-git-send-email-yamada.masahiro@socionext.com> <20170613090249.6a247389@bbrezillon> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1166 Lines: 36 On Tue, 13 Jun 2017 17:17:41 +0900 Masahiro Yamada wrote: > Hi Boris, > > > 2017-06-13 16:02 GMT+09:00 Boris Brezillon : > > > > > BTW, I also implemented ->read/write_buf_word() since the core may one > > day call these functions, and the default implementations used by the > > core when these hooks are NULL are not appropriate in your case. > > > > BTW, why doesn't the default hook in the core do like this? > > > static uint8_t nand_read_byte(struct mtd_info *mtd) > { > struct nand_chip *chip = mtd_to_nand(mtd); > uint8_t byte; > > chip->read_buf(chip, &byte, 1); > return byte; > } > > > ->read_byte() is a special case of ->read_buf() with length==1, > so this should work. Not sure it works for all implementation. ->read_byte() is expected to return the lower 8 bits when interacting with a 16-bits bus. If we do what you suggest, and ->read_buf() appears to be caching data in an intermediate buffer if the amount of data is not aligned on 2 bytes, you might retrieve data you don't care about when ->read_byte() is called several times.