From patchwork Sat Jan 23 02:57:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 8095391 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AB63C9F440 for ; Sat, 23 Jan 2016 03:00:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD36B205CD for ; Sat, 23 Jan 2016 03:00:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 119722057F for ; Sat, 23 Jan 2016 03:00:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aMoOZ-0003yl-Pa; Sat, 23 Jan 2016 02:57:47 +0000 Received: from mail-pa0-x22f.google.com ([2607:f8b0:400e:c03::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aMoOP-0003xK-QR; Sat, 23 Jan 2016 02:57:41 +0000 Received: by mail-pa0-x22f.google.com with SMTP id ho8so50725941pac.2; Fri, 22 Jan 2016 18:57:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=8HdvE9jRsZCdavjDdVI9ghx4rPavqNsxnftCkZz5YdE=; b=e3W/jNGnhLZTdm1IXCvY1wQ8+21IPr8jIP4R6U6Lz94MCH4DBaQX/W0s2GvisgL4lm 8U6pMMPsez6iFGankeqHEhDryhS0AKFmiWPrL3EogUzfSKc6SaJps+l/LY6ZDgDFblRE gCftmULGVCStFiaiQS3fTUvz+6Fynoa9nDhSXOccwwfPJWQ6PjmVaF0O54bzmrrTowse w5q5adOY1fMvfs2taJ5Kv9w3Ubdho4B/jM/aB8VNSnb8XNTNbuBDRYuxLzv48rcRXg7W BgymYDcSC+qXHofwl71k6kqhUbjfuY80I+066EMWOTElOEcGEam11fU1mxZMVClPS7bN 6q2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=8HdvE9jRsZCdavjDdVI9ghx4rPavqNsxnftCkZz5YdE=; b=f4Zd4v6AFhvU+EmKRGEKPaadwCLsAxdOjgP7Mn58G2Bo4Mws8p/M8jr3yo6CBBUOxp 0NFoCuF3SACHoPiEry1k1u+JusauPeEAD+spKsj+ANbSogBLu6NS1lfyS6KBlHh2isF/ uuIy5mgr05tdk4ZL5UHFRtiHFkm9blDSXw/IpUr4/3vE3zbkd0cHHQ7xnmaE0rrJZp5K QmGVruFdZCfP446DnR5iaCTbuBhNXVmR7RttDo5QUsOfN2YXMy5N7DIUVAuq92d7N0qm POTyevotd97azCQjr5l4laFDQV+iESHtsaM0Z1cq5NQJ9RBeoky7KzQZTBPQq5mejecV HUtg== X-Gm-Message-State: AG10YOQ/g/VMRphIxFGsWpyVC7jLcfiOCUUnV0ihJzDm+i9U7xLoWnSlRGVRJWVAbg3gOQ== X-Received: by 10.66.150.202 with SMTP id uk10mr9146825pab.73.1453517835916; Fri, 22 Jan 2016 18:57:15 -0800 (PST) Received: from google.com ([2620:0:1000:1301:490b:6023:2af4:2a81]) by smtp.gmail.com with ESMTPSA id ux2sm12542788pac.46.2016.01.22.18.57.15 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 22 Jan 2016 18:57:15 -0800 (PST) Date: Fri, 22 Jan 2016 18:57:13 -0800 From: Brian Norris To: Boris Brezillon Subject: Re: [PATCH v2 3/3] mtd: nand: sunxi: add randomizer support Message-ID: <20160123025713.GA90611@google.com> References: <1449054067-16751-1-git-send-email-boris.brezillon@free-electrons.com> <1449054067-16751-4-git-send-email-boris.brezillon@free-electrons.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1449054067-16751-4-git-send-email-boris.brezillon@free-electrons.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160122_185737_925830_FD73D030 X-CRM114-Status: GOOD ( 14.67 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Weinberger , Chen-Yu Tsai , linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, linux-mtd@lists.infradead.org, Maxime Ripard , David Woodhouse , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All three look good, so pushed to l2-mtd.git/next. One comment below: On Wed, Dec 02, 2015 at 12:01:07PM +0100, Boris Brezillon wrote: ... > +static u16 sunxi_nfc_randomizer_state(struct mtd_info *mtd, int page, bool ecc) > +{ > + const u16 *seeds = sunxi_nfc_randomizer_page_seeds; > + int mod = mtd->erasesize / mtd->writesize; Richard suggested you use the mtd.h helper here. Patch below. > + > + if (mod > ARRAY_SIZE(sunxi_nfc_randomizer_page_seeds)) > + mod = ARRAY_SIZE(sunxi_nfc_randomizer_page_seeds); > + > + if (ecc) { > + if (mtd->ecc_step_size == 512) > + seeds = sunxi_nfc_randomizer_ecc512_seeds; > + else > + seeds = sunxi_nfc_randomizer_ecc1024_seeds; > + } > + > + return seeds[page % mod]; > +} From: Brian Norris Date: Fri, 22 Jan 2016 18:54:02 -0800 Subject: [PATCH] mtd: nand: sunxi: use mtd_div_by_ws() helper Suggested-by: Richard Weinberger Signed-off-by: Brian Norris Acked-by: Boris Brezillon --- drivers/mtd/nand/sunxi_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c index 5f700719d5c2..b5ea6b312df0 100644 --- a/drivers/mtd/nand/sunxi_nand.c +++ b/drivers/mtd/nand/sunxi_nand.c @@ -624,7 +624,7 @@ static u16 sunxi_nfc_randomizer_step(u16 state, int count) static u16 sunxi_nfc_randomizer_state(struct mtd_info *mtd, int page, bool ecc) { const u16 *seeds = sunxi_nfc_randomizer_page_seeds; - int mod = mtd->erasesize / mtd->writesize; + int mod = mtd_div_by_ws(mtd->erasesize, mtd); if (mod > ARRAY_SIZE(sunxi_nfc_randomizer_page_seeds)) mod = ARRAY_SIZE(sunxi_nfc_randomizer_page_seeds);