From patchwork Wed Jun 7 11:52:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 103255 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp1716887obh; Wed, 7 Jun 2017 05:00:43 -0700 (PDT) X-Received: by 10.84.229.6 with SMTP id b6mr28093299plk.4.1496836843628; Wed, 07 Jun 2017 05:00:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496836843; cv=none; d=google.com; s=arc-20160816; b=ixZf9o11kH0USnXC1DQdyt2WFmGYJf8sEsCM0MzcZ7GoCLl8KFQ3M/kBI91e6kqz2l WexFkKc46b1wdLE8uQzYrOzho7Z9D7sAjHQUP8jzOxjH7zIdGF3c1blPkZ87YPWUcxQi D/vl1L8Io6K85Gn+ZDhC/qR4NzqdV31VahmmCJ6NXgo6iGz0Y+ZjSlIMbqYY6uySWg6y bqu8BantF8PyoL76VSvM5nfiSpAzBzNo65Q8cQ39lekd9AKvmI7hKseInSIYT1wGbDil Q3Iiuet6E06fMfjLJHwYKyt3na1yQTQcD5ZaJDK5odIf5vSJ6/YAphez1sHJKvg/ipPz JA7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=8CP48yiUuqqsCTTnQfu6j5chAmIPWK2W22bnFQ5bzBw=; b=r1U/vZeOKJaN0lB3xmM87KAsILuQGnVPQ1H9M0H7mpP2F+A0duvJTM8wWg5VwV2j1C WdlOpWcUlT48QRTxh3F8OogIQ4FQDehGT6u5WlrZqY+Fp3+Gk6eym+mUnCc1MZj9xQCY n+SCWlIzHSow7WMovM0x3AGKARYwU953zaCU99c6MxgpEYdD9QiCwSByOxCxbABG0IWd SxCjrhJ5cwunkDJOgzCr5As5bUfsi2sBF1SgomU3SEGcF1WxNtz5UbTWOOBvIeoyGRlg MjBi0FTJC7mDx4OSqwULU6TdtNTuwsRWHGjrNdayT5cNCdnCfVr4TIKZ20o0wi/bgA6i vmEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j3si1624610pgs.370.2017.06.07.05.00.43; Wed, 07 Jun 2017 05:00:43 -0700 (PDT) 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=@nifty.com; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751932AbdFGMAU (ORCPT + 25 others); Wed, 7 Jun 2017 08:00:20 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:42393 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751502AbdFGLzU (ORCPT ); Wed, 7 Jun 2017 07:55:20 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id v57BqjZR014276; Wed, 7 Jun 2017 20:52:48 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v57BqjZR014276 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1496836369; bh=8CP48yiUuqqsCTTnQfu6j5chAmIPWK2W22bnFQ5bzBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0U7DjHSF+5ldD3R/5CNq/5upvQ3ktCQ3QhI4+NJg3/AUMGE9EmxyioIH538RQdUAH Nt6mo5IqhOvA2nRwUSC/GG6Fjj9Tvqd/+5/yUbkPIRmSyAERy2sq4xQexAzUfMwKYk dLyHKLcypwaGG7Bo9GXElds62Xc3qm+xuvc0l8NinQV/R0YxKHnNxpK8j4F5WTJx5e ZaR6cIiftD5CvqIKhi7vLCOd6NfqkzQSjYcvhSqEvfmTz5ADdiVWY+L5e7eybWrGBy IJYqnDdvDjodiV9HW8w9b9alnlygsiouIyyjsp+yXUdpJO0028U59LDze2X0nntEva rAl/fIXPPNjsg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Cc: Enrico Jorns , Artem Bityutskiy , Dinh Nguyen , Boris Brezillon , Marek Vasut , David Woodhouse , Masami Hiramatsu , Chuanxiao Dong , Jassi Brar , Masahiro Yamada , Cyrille Pitchen , linux-kernel@vger.kernel.org, Brian Norris , Richard Weinberger Subject: [PATCH v5 02/23] mtd: nand: add a shorthand to generate nand_ecc_caps structure Date: Wed, 7 Jun 2017 20:52:11 +0900 Message-Id: <1496836352-8016-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496836352-8016-1-git-send-email-yamada.masahiro@socionext.com> References: <1496836352-8016-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Changes in v5: - Newly added Changes in v4: None Changes in v3: None Changes in v2: None include/linux/mtd/nand.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.7.4 diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index c28a5792eed6..c08954a39657 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -500,6 +500,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