From patchwork Thu Feb 21 12:57:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 10824081 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9BE3413B5 for ; Thu, 21 Feb 2019 13:01:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8867C309F1 for ; Thu, 21 Feb 2019 13:01:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C0C730A1F; Thu, 21 Feb 2019 13:01:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0D2E2307F2 for ; Thu, 21 Feb 2019 13:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9NdPcwRAYHIwFekCH5zBROoYR+jgwHG24uVpz3Jh63E=; b=hEw9da2xSfGEVH x8FwXxTKloow3Twv8tJanr29P8l70hTHorImE4iWOMZQZpCrmhuEilh9vpMl7+ZfLZUzC8FpI6Kd0 de5WcmHUgF7fUbzJzA07nMYZTXytz1Rii0MVuEi5nRt/M17CTfCrC+fdisKxAa1cXBEg/ZfVuqi16 4uZeKHmnHQEOpRxiN872/XoBKCOImov4rQkTWJUHCoj2cvU/+YDKrxgd4WXnRm/2M8bw1AKOi0O1Z 2x443BsMWXkYPCyClV+VoZnT0u+KQbNSDeRrCriW+mPy6wCk0Nfz1aV8CM6eAT6ReDDOv2eq9h+K2 X+OVIURD/EAw565HuiQw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwnz8-0008Mv-Pn; Thu, 21 Feb 2019 13:01:54 +0000 Received: from relay6-d.mail.gandi.net ([217.70.183.198]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwnw1-00033d-72; Thu, 21 Feb 2019 12:58:49 +0000 X-Originating-IP: 90.88.23.190 Received: from localhost.localdomain (aaubervilliers-681-1-81-190.w90-88.abo.wanadoo.fr [90.88.23.190]) (Authenticated sender: miquel.raynal@bootlin.com) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 28617C000C; Thu, 21 Feb 2019 12:58:37 +0000 (UTC) From: Miquel Raynal To: Boris Brezillon , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Tudor Ambarus Subject: [RFC PATCH 20/27] mtd: nand: Let software ECC engines be retrieved from the NAND core Date: Thu, 21 Feb 2019 13:57:59 +0100 Message-Id: <20190221125806.28875-8-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190221125806.28875-1-miquel.raynal@bootlin.com> References: <20190221125806.28875-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190221_045842_264735_129A76F2 X-CRM114-Status: GOOD ( 10.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vignesh R , Tudor Ambarus , Julien Su , Schrempf Frieder , linux-mtd@lists.infradead.org, Thomas Petazzoni , Miquel Raynal , Mason Yang , 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-Virus-Scanned: ClamAV using ClamSMTP Before making use of the ECC engines, we must retrieve them. Add the boilerplate for the ones already available: software engines (Hamming and BCH). Signed-off-by: Miquel Raynal --- drivers/mtd/nand/ecc/engine.c | 14 ++++++++++++++ include/linux/mtd/nand-sw-bch-engine.h | 3 +++ include/linux/mtd/nand-sw-hamming-engine.h | 3 +++ include/linux/mtd/nand.h | 3 +++ 4 files changed, 23 insertions(+) diff --git a/drivers/mtd/nand/ecc/engine.c b/drivers/mtd/nand/ecc/engine.c index 7dd3f9772698..318dbb2d56a2 100644 --- a/drivers/mtd/nand/ecc/engine.c +++ b/drivers/mtd/nand/ecc/engine.c @@ -286,6 +286,20 @@ bool nand_ecc_correction_is_enough(struct nand_device *nand) return corr >= ds_corr && conf->strength >= reqs->strength; } +struct nand_ecc_engine *nand_ecc_sw_get_engine(struct nand_device *nand) +{ + switch (nand->ecc.user_conf.algo) { + case NAND_ECC_HAMMING: + return ecc_sw_hamming_get_engine(); + case NAND_ECC_BCH: + return ecc_sw_bch_get_engine(); + default: + break; + } + + return NULL; +} + MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Miquel Raynal "); MODULE_DESCRIPTION("Generic ECC engine"); diff --git a/include/linux/mtd/nand-sw-bch-engine.h b/include/linux/mtd/nand-sw-bch-engine.h index e406aa53ec4e..38cdad117fea 100644 --- a/include/linux/mtd/nand-sw-bch-engine.h +++ b/include/linux/mtd/nand-sw-bch-engine.h @@ -11,6 +11,9 @@ #include #include +/* Needed for cross inclusion with nand.h */ +struct nand_device; + /** * struct ecc_sw_bch_conf - private software BCH ECC engine structure * @reqooblen: Save the actual user OOB length requested before overwriting it diff --git a/include/linux/mtd/nand-sw-hamming-engine.h b/include/linux/mtd/nand-sw-hamming-engine.h index 8df36d189482..51c5a2acee42 100644 --- a/include/linux/mtd/nand-sw-hamming-engine.h +++ b/include/linux/mtd/nand-sw-hamming-engine.h @@ -12,6 +12,9 @@ #include +/* Needed for cross inclusion with nand.h */ +struct nand_device; + /** * struct ecc_sw_hamming_conf - private software Hamming ECC engine structure * @reqooblen: Save the actual user OOB length requested before overwriting it diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 4482eb2bbfd4..3abe113e4f06 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -11,6 +11,8 @@ #define __LINUX_MTD_NAND_H #include +#include +#include struct nand_device; @@ -253,6 +255,7 @@ struct nand_ecc_engine { }; void nand_ecc_read_user_conf(struct nand_device *nand); +struct nand_ecc_engine *nand_ecc_sw_get_engine(struct nand_device *nand); int nand_ecc_init_ctx(struct nand_device *nand); void nand_ecc_cleanup_ctx(struct nand_device *nand); int nand_ecc_prepare_io_req(struct nand_device *nand,