From patchwork Tue Nov 21 17:38:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 119378 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5571403qgn; Tue, 21 Nov 2017 09:44:24 -0800 (PST) X-Google-Smtp-Source: AGs4zMYM1d2rBEvkjnbCZJtdyEPkcgQ56xzL0yXSnXJWe/VSaDbwn2ltAe0QBd0pLJ9zooS/7qtU X-Received: by 10.80.216.202 with SMTP id y10mr12867269edj.221.1511286264323; Tue, 21 Nov 2017 09:44:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511286264; cv=none; d=google.com; s=arc-20160816; b=lmQoXSFueJ2/cUVDCzX2phxCWOiV17UEBvD/7g1i707duLAXN9AM4ikFBYWZN5KCBU BFdITIbxBDHg29P/P5wCDpXSMOHh/eduaWL+RDQhaH+uIMdwKGltS6fUuQuaClDee3Z0 feIovYkT2E0NPcsmuIVi8AB2iUWSrzN6Rp6uzmqXhZvCOcoMJRS0eSglR5T6yUCK5K1u GXjyoeqc8Q1FXYflJYUOU1gGeBFk14hvAuxch9ImNGqozUgokKlTK02aQvPdMqdUfVb8 LydM8ExXM9kRiRQvC8Oyc48FX9Z6eSPYX3a+u2b9J7FGn1rMq7NjMSyuOinwmLmONBH6 uVUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=uQxC1SlxIWR0eYRUBrDUWZyWsEUeLqohzS4qQBwrJbU=; b=wRhqD1w7k8VF5AhoGz3T9+ck2/UARRyfwqR2wn4d2kKZlIWLxwgKi5f5jR7MVt+EVp ULj73jJRHGQRaIzT5XWBbDihhHr4YHe+tP7znv3txatW8DHVV8DCDs9CjN/3HebNz46+ Q1j7LAY92nSxBn3cgW/XkWGV++AZt61YQE4X0oiR9KkcoIen7x71Bx6zuoFfucEvL3JD ClMOXTFoTpFjeyw0sFiGWAqRnjA6jizmaToKjh7QLAQYCMaOTmxw3l00HUdN8W26DP0Y l9RtT3Fnff14cJGZLi66eGVyXATcCRQmB7M4fPIqYWNgcl1IPuBlbsEFxL8mPMCQo500 BpGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=1AjRprMn; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id h63si1390394edc.554.2017.11.21.09.44.23; Tue, 21 Nov 2017 09:44:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=1AjRprMn; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id B8565C21F6C; Tue, 21 Nov 2017 17:41:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 1404CC21F53; Tue, 21 Nov 2017 17:39:23 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 23A49C21F07; Tue, 21 Nov 2017 17:39:07 +0000 (UTC) Received: from conuserg-07.nifty.com (conuserg-07.nifty.com [210.131.2.74]) by lists.denx.de (Postfix) with ESMTPS id EEDE4C21F2B for ; Tue, 21 Nov 2017 17:39:03 +0000 (UTC) Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id vALHcbuA001225; Wed, 22 Nov 2017 02:38:46 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com vALHcbuA001225 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1511285926; bh=mrL6nEhsOfvfL7YxyGB1OxHyHCJ6XV1T7bnWigtuUcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1AjRprMn0K53asnEOwrg0G+cQt5/cgie6XI6xHwNn/uJt1iawykSImzeXS89XSdVl a+dlAJlilHMoP9kY1lG5tBewpz/iKUwJmG41mGZrDfRAMG8FJtzqan7dGDJpt2JJ2o V28TyZ+21A8i5RxtaWr3ikHKt9CHd98MKDr9h26U7nN/5Y/n0YzEzcMR1oN4iifywp ZuKdjs4BEnqbDY0Un4epYrz4M/YTrCwgNUHIQkxY/wQHPnF+iT4Veuie6aU5FXxcsc 090/p5kTpenVdVDq4w49OkC0b/NlfbN4moAd8vnsIeKQXaz43saOZrNH1q0og4nT2f Jduxyk8PzM/RQ== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Wed, 22 Nov 2017 02:38:30 +0900 Message-Id: <1511285912-12452-21-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511285912-12452-1-git-send-email-yamada.masahiro@socionext.com> References: <1511285912-12452-1-git-send-email-yamada.masahiro@socionext.com> Cc: Scott Wood Subject: [U-Boot] [PATCH 20/22] mtd: nand: add a shorthand to generate nand_ecc_caps structure X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" struct nand_ecc_caps was designed as flexible as possible to support multiple stepsizes (like sunxi_nand.c). So, we need to write multiple arrays even for the simplest case. I guess many controllers support a single stepsize, so here is a shorthand macro for the case. It allows to describe like ... NAND_ECC_CAPS_SINGLE(denali_pci_ecc_caps, denali_calc_ecc_bytes, 512, 8, 15); ... instead of static const int denali_pci_ecc_strengths[] = {8, 15}; static const struct nand_ecc_step_info denali_pci_ecc_stepinfo = { .stepsize = 512, .strengths = denali_pci_ecc_strengths, .nstrengths = ARRAY_SIZE(denali_pci_ecc_strengths), }; static const struct nand_ecc_caps denali_pci_ecc_caps = { .stepinfos = &denali_pci_ecc_stepinfo, .nstepinfos = 1, .calc_ecc_bytes = denali_calc_ecc_bytes, }; Signed-off-by: Masahiro Yamada Signed-off-by: Boris Brezillon [Linux commit: a03c60178c181767ecfb26fb311a88742d228118] --- include/linux/mtd/nand.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 2d5f9a4..150e3b8 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -511,6 +511,20 @@ struct nand_ecc_caps { int (*calc_ecc_bytes)(int step_size, int strength); }; +/* a shorthand to generate struct nand_ecc_caps with only one ECC stepsize */ +#define NAND_ECC_CAPS_SINGLE(__name, __calc, __step, ...) \ +static const int __name##_strengths[] = { __VA_ARGS__ }; \ +static const struct nand_ecc_step_info __name##_stepinfo = { \ + .stepsize = __step, \ + .strengths = __name##_strengths, \ + .nstrengths = ARRAY_SIZE(__name##_strengths), \ +}; \ +static const struct nand_ecc_caps __name = { \ + .stepinfos = &__name##_stepinfo, \ + .nstepinfos = 1, \ + .calc_ecc_bytes = __calc, \ +} + /** * struct nand_ecc_ctrl - Control structure for ECC * @mode: ECC mode