Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp978913imu; Thu, 20 Dec 2018 08:14:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/XBCpfbrKtK1lVvCkbzO0TKy0ZFxnb6DvcdrSekj+sC7wKjZgGNIw3072H2G7nTZ56GTDhy X-Received: by 2002:a62:7652:: with SMTP id r79mr25829492pfc.241.1545322443884; Thu, 20 Dec 2018 08:14:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545322443; cv=none; d=google.com; s=arc-20160816; b=SmS2mST+6DWaoudsyIcq4C7oiBNKGuHP4oEa3W6xxlt0JGmh23V692C5mZF7yjDemz +eJ1SlLi88HZMsZAwenkh/hU50Dx0SCvfciwY5Z3vQsWkd+54fFsH71s/baMNYUATxEj uYFlg1DLhhLYvSNP4xZwpfUn4zTJHrXux29h8uTZvcAj79paHS0ntLKWil6auKxJiSlE xzJ2xhsK9R2GXN5TQpGc7SDQJi6KbM4qipUO7qZGZFpJKVKfkRZMhzn7ZDi9JuNAf2qi 9QzJm8j20q5xeRjL9TIpuUaftR/CCBSzatgOIpc4xKQmnUlDmFXorJDzDu4Fi6yTPmox Gn+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=qpKP5NGkD+eYsPSFxQ+yYXHxmM57vATNhgK9xMnAPQs=; b=EJsmuyITsRhxRxGVmWju4GnsYMC5IhNxbNGe0eN+ywcFNquRqs6FYSJ9TwUm4h+99f RQvEJm0uAJczNvNwxnihpUAZVjpEBtTOMX9bSXOjRId/QwCxsG0NMFIt9aiRdGekmDJY 1IKUtVVQK/9DypUoLecVfggRZhdqQdyWqaBzWTzOfkuNsemsx5ABfrTe/bM0k9qdR4ty o5166RrZLFW+nqk/+4TDd43XJENPjXwFdHiFng+nGbD3eO0oa3VyNfUKiULS6cxm3E+a 6UtlDq4YYQTTv57o/O2/xo/dsbV3KX3sfoiesBaw88qGB1X8GUP/zyzWwLaMHTh/S3gA gOdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=j12sTpwB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v32si19505372plb.369.2018.12.20.08.13.48; Thu, 20 Dec 2018 08:14:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=j12sTpwB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733023AbeLTOHc (ORCPT + 99 others); Thu, 20 Dec 2018 09:07:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:47660 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731265AbeLTOHc (ORCPT ); Thu, 20 Dec 2018 09:07:32 -0500 Received: from bbrezillon (aaubervilliers-681-1-38-38.w90-88.abo.wanadoo.fr [90.88.157.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BEFF4217D8; Thu, 20 Dec 2018 14:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545314851; bh=1Zuy2GzBKlgz21F6tNh9wBJvufwSey8/K1T12KYOFyI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=j12sTpwB2mY9JX1cWWVmKWaCv9yY+xdVDVKeHh6pq6Mu/46KLHyZJo0KutFv/+GnQ te0r2iJ9ExlUoOQuY9CJ2Y9GN35XRBAymFYJdZNzLt4Mcb+4OLfokmF+A1Bhmy9cWv UPj2RGtzWBGxK/YyffosXr8YspOprJYEPw5Q+Bck= Date: Thu, 20 Dec 2018 15:07:26 +0100 From: Boris Brezillon To: Schrempf Frieder Cc: "richard@nod.at" , "linux-kernel@vger.kernel.org" , Marek Vasut , "linux-mtd@lists.infradead.org" , "miquel.raynal@bootlin.com" , Brian Norris , David Woodhouse Subject: Re: [PATCH 1/3] mtd: rawnand: Support bad block markers in first, second or last page Message-ID: <20181220150715.5b19f480@bbrezillon> In-Reply-To: <20181220145954.55ae36e9@bbrezillon> References: <1545061693-29216-1-git-send-email-frieder.schrempf@kontron.de> <1545061693-29216-2-git-send-email-frieder.schrempf@kontron.de> <20181220145954.55ae36e9@bbrezillon> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 20 Dec 2018 14:59:54 +0100 Boris Brezillon wrote: > > > > /** > > + * nand_bbm_page_offset - Get the page offsets for bad block markers > > + * @chip: NAND chip object > > + * @index: Index for the page offset > > Hm, the meaning of index is far from obvious. How about passing the > current page instead (and return 1 if there are more pages to scan 0 > otherwise)? > > Something like: > > static int nand_bbm_get_next_page(struct nand_chip *chip, int page) > { > struct mtd_info *mtd = nand_to_mtd(chip); > int last_page = ((mtd->erasesize - mtd->writesize) >> > chip->page_shift) & chip->pagemask; > > if (page < 0 && chip->bbt_options & NAND_BBT_SCANFIRSTPAGE) > return 0; > else if (page < 1 && chip->bbt_options & NAND_BBT_SCAN2NDPAGE) > return 1; > else if (page < last_page && > chip->bbt_options & NAND_BBT_SCANLASTPAGE) > return last_page; > > return -1; > } > > And yes, that means defining NAND_BBT_SCANFIRSTPAGE and setting it when > appropriate. > Oh, and you'll have to define NAND_BBT_SCANFIRST2PAGES like this #define NAND_BBT_SCANFIRST2PAGES NAND_BBT_SCAN1STPAGE | \ NAND_BBT_SCAN2NDPAGE and then patch all users of NAND_BBT_SCAN2NDPAGE to use NAND_BBT_SCANFIRST2PAGES instead.