From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752902AbcKQHwT (ORCPT ); Thu, 17 Nov 2016 02:52:19 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:34150 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751884AbcKQHwS (ORCPT ); Thu, 17 Nov 2016 02:52:18 -0500 Date: Thu, 17 Nov 2016 08:52:16 +0100 From: Boris Brezillon To: Peter Pan Cc: Richard Weinberger , linux-mtd@lists.infradead.org, David Woodhouse , Brian Norris , Ezequiel Garcia , linux-kernel@vger.kernel.org, "peterpandong@micron.com" Subject: Re: [PATCH v2 3/7] mtd: nand: add a nand.h file to expose basic NAND stuff Message-ID: <20161117085216.14c17813@bbrezillon> In-Reply-To: References: <1476628518-20450-1-git-send-email-boris.brezillon@free-electrons.com> <1476628518-20450-4-git-send-email-boris.brezillon@free-electrons.com> 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 On Thu, 17 Nov 2016 14:14:21 +0800 Peter Pan wrote: > Hi Boris, > > On Sun, Oct 16, 2016 at 10:35 PM, Boris Brezillon > wrote: > > Now that raw NAND header has been moved to rawnand.h, we can add a new > > nand.h file and define the common nand stuff in there. > > > > Signed-off-by: Boris Brezillon > > --- > > include/linux/mtd/nand.h | 480 +++++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 480 insertions(+) > > create mode 100644 include/linux/mtd/nand.h > > > > diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h > > new file mode 100644 > > index 000000000000..b9b5d3c1bdf9 > > --- /dev/null > > +++ b/include/linux/mtd/nand.h > [...] > > + > > +/** > > + * nand_offs_to_die - Convert an absolute offset to a die number > > + * @nand: NAND device > > + * @offs: absolute offset > > + * > > + * Returns the die number containing @offs. > > + */ > > +static inline int nand_offs_to_die(struct nand_device *nand, loff_t offs) > > +{ > > + u64 die = offs; > > + > > + do_div(die, nand->memorg.diesize); > > + > > + return die; > > Is it proper to use do_div here?. If I'm right, the divisor of do_div is 32bit. > It may cause division 0 exception when die size is larger than 4GB. > div64_u64 may be better. Nice catch! Indeed, div64_u64() should be used here. I'll fix that. Thanks, Boris