From patchwork Thu Dec 10 08:00:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris BREZILLON X-Patchwork-Id: 7815721 Return-Path: X-Original-To: patchwork-linux-omap@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 CFA229F1C2 for ; Thu, 10 Dec 2015 08:08:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C252E2055D for ; Thu, 10 Dec 2015 08:08:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B77BA2053A for ; Thu, 10 Dec 2015 08:08:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755081AbbLJIH1 (ORCPT ); Thu, 10 Dec 2015 03:07:27 -0500 Received: from down.free-electrons.com ([37.187.137.238]:52238 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754087AbbLJIHW (ORCPT ); Thu, 10 Dec 2015 03:07:22 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id 57735426D; Thu, 10 Dec 2015 09:07:19 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost.localdomain (unknown [37.161.176.221]) by mail.free-electrons.com (Postfix) with ESMTPSA id E24E72616; Thu, 10 Dec 2015 09:03:09 +0100 (CET) From: Boris Brezillon To: David Woodhouse , Brian Norris , linux-mtd@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jonathan Corbet , linux-doc@vger.kernel.org, Hartley Sweeten , Ryan Mallon , Shawn Guo , Sascha Hauer , Imre Kaloz , Krzysztof Halasa , Tony Lindgren , linux-omap@vger.kernel.org, Alexander Clouter , Thomas Petazzoni , Gregory CLEMENT , Jason Cooper , Sebastian Hesselbarth , Andrew Lunn , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Marek Vasut , Steven Miao , adi-buildroot-devel@lists.sourceforge.net, Mikael Starvik , Jesper Nilsson , linux-cris-kernel@axis.com, Josh Wu , Wan ZongShun , Ezequiel Garcia , Maxim Levitsky , Kukjin Kim , Krzysztof Kozlowski , linux-samsung-soc@vger.kernel.org, Maxime Ripard , Chen-Yu Tsai , linux-sunxi@googlegroups.com, Stefan Agner , Greg Kroah-Hartman , devel@driverdev.osuosl.org, Boris Brezillon Subject: [PATCH v4 38/58] mtd: nand: s3c2410: use the mtd instance embedded in struct nand_chip Date: Thu, 10 Dec 2015 09:00:22 +0100 Message-Id: <1449734442-18672-39-git-send-email-boris.brezillon@free-electrons.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1449734442-18672-1-git-send-email-boris.brezillon@free-electrons.com> References: <1449734442-18672-1-git-send-email-boris.brezillon@free-electrons.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP struct nand_chip now embeds an mtd device. Make use of this mtd instance. Signed-off-by: Boris Brezillon Reviewed-by: Krzysztof Kozlowski --- Changes generated with the following coccinelle script --->8--- virtual patch @fix1@ identifier __chipfield, __mtdfield; type __type; @@ ( __type { ... struct nand_chip __chipfield; ... - struct mtd_info __mtdfield; ... }; | __type { ... - struct mtd_info __mtdfield; ... struct nand_chip __chipfield; ... }; ) @fix2 depends on fix1@ identifier fix1.__chipfield, fix1.__mtdfield; identifier __subfield; type fix1.__type; __type *__priv; @@ ( - __priv->__mtdfield.__subfield + nand_to_mtd(&__priv->__chipfield)->__subfield | - &(__priv->__mtdfield) + nand_to_mtd(&__priv->__chipfield) ) --->8--- --- drivers/mtd/nand/s3c2410.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c index e658b29..c074a49 100644 --- a/drivers/mtd/nand/s3c2410.c +++ b/drivers/mtd/nand/s3c2410.c @@ -104,7 +104,6 @@ struct s3c2410_nand_info; * @scan_res: The result from calling nand_scan_ident(). */ struct s3c2410_nand_mtd { - struct mtd_info mtd; struct nand_chip chip; struct s3c2410_nand_set *set; struct s3c2410_nand_info *info; @@ -168,7 +167,8 @@ struct s3c2410_nand_info { static struct s3c2410_nand_mtd *s3c2410_nand_mtd_toours(struct mtd_info *mtd) { - return container_of(mtd, struct s3c2410_nand_mtd, mtd); + return container_of(mtd_to_nand(mtd), struct s3c2410_nand_mtd, + chip); } static struct s3c2410_nand_info *s3c2410_nand_mtd_toinfo(struct mtd_info *mtd) @@ -745,7 +745,7 @@ static int s3c24xx_nand_remove(struct platform_device *pdev) for (mtdno = 0; mtdno < info->mtd_count; mtdno++, ptr++) { pr_debug("releasing mtd %d (%p)\n", mtdno, ptr); - nand_release(&ptr->mtd); + nand_release(nand_to_mtd(&ptr->chip)); } } @@ -762,9 +762,11 @@ static int s3c2410_nand_add_partition(struct s3c2410_nand_info *info, struct s3c2410_nand_set *set) { if (set) { - mtd->mtd.name = set->name; + struct mtd_info *mtdinfo = nand_to_mtd(&mtd->chip); - return mtd_device_parse_register(&mtd->mtd, NULL, NULL, + mtdinfo->name = set->name; + + return mtd_device_parse_register(mtdinfo, NULL, NULL, set->partitions, set->nr_partitions); } @@ -786,6 +788,7 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info, struct s3c2410_nand_set *set) { struct nand_chip *chip = &nmtd->chip; + struct mtd_info *mtd = nand_to_mtd(chip); void __iomem *regs = info->regs; chip->write_buf = s3c2410_nand_write_buf; @@ -831,7 +834,7 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info, chip->IO_ADDR_R = chip->IO_ADDR_W; nmtd->info = info; - nmtd->mtd.priv = chip; + mtd->priv = chip; nmtd->set = set; #ifdef CONFIG_MTD_NAND_S3C2410_HWECC @@ -1012,19 +1015,21 @@ static int s3c24xx_nand_probe(struct platform_device *pdev) nmtd = info->mtds; for (setno = 0; setno < nr_sets; setno++, nmtd++) { + struct mtd_info *mtd = nand_to_mtd(&nmtd->chip); + pr_debug("initialising set %d (%p, info %p)\n", setno, nmtd, info); - nmtd->mtd.dev.parent = &pdev->dev; + mtd->dev.parent = &pdev->dev; s3c2410_nand_init_chip(info, nmtd, sets); - nmtd->scan_res = nand_scan_ident(&nmtd->mtd, + nmtd->scan_res = nand_scan_ident(mtd, (sets) ? sets->nr_chips : 1, NULL); if (nmtd->scan_res == 0) { s3c2410_nand_update_chip(info, nmtd); - nand_scan_tail(&nmtd->mtd); + nand_scan_tail(mtd); s3c2410_nand_add_partition(info, nmtd, sets); }