From patchwork Mon Jul 15 14:55:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pekon gupta X-Patchwork-Id: 2827568 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5E4FFC0AB2 for ; Mon, 15 Jul 2013 14:57:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB3BA201F7 for ; Mon, 15 Jul 2013 14:57:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D80AD20201 for ; Mon, 15 Jul 2013 14:57:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932244Ab3GOO5E (ORCPT ); Mon, 15 Jul 2013 10:57:04 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:38860 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932235Ab3GOO5D (ORCPT ); Mon, 15 Jul 2013 10:57:03 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id r6FEuETS011213; Mon, 15 Jul 2013 09:56:14 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r6FEuEJT014943; Mon, 15 Jul 2013 09:56:14 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Mon, 15 Jul 2013 09:56:14 -0500 Received: from psplinux064.india.ti.com (psplinux064.india.ti.com [10.24.100.118]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r6FEtsNx022991; Mon, 15 Jul 2013 09:56:11 -0500 From: Pekon Gupta To: , CC: , , , , , , , Pekon Gupta Subject: [PATCH v1 5/5] mtd: nand: omap: code clean-up and white-space fixes Date: Mon, 15 Jul 2013 20:25:52 +0530 Message-ID: <1373900152-26885-6-git-send-email-pekon@ti.com> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1373900152-26885-1-git-send-email-pekon@ti.com> References: <1373900152-26885-1-git-send-email-pekon@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 This patch just clean-up the code and fixes spaces in omap_nand_probe() s/info->nand./chip-> s/&info->mtd/mtd Signed-off-by: Pekon Gupta --- drivers/mtd/nand/omap2.c | 210 +++++++++++++++++++++++------------------------ 1 file changed, 102 insertions(+), 108 deletions(-) diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c index 7d786d9..c2c3c6bb 100644 --- a/drivers/mtd/nand/omap2.c +++ b/drivers/mtd/nand/omap2.c @@ -1462,9 +1462,9 @@ static int omap_nand_probe(struct platform_device *pdev) info->reg = pdata->reg; info->ecc_opt = pdata->ecc_opt; - info->nand.options = NAND_BUSWIDTH_AUTO; - info->nand.options |= NAND_SKIP_BBTSCAN; - info->nand.ecc.priv = NULL; + chip->options = NAND_BUSWIDTH_AUTO; + chip->options |= NAND_SKIP_BBTSCAN; + chip->ecc.priv = NULL; #ifdef CONFIG_MTD_NAND_OMAP_BCH info->of_node = pdata->of_node; #endif @@ -1485,16 +1485,16 @@ static int omap_nand_probe(struct platform_device *pdev) goto out_free_info; } - info->nand.IO_ADDR_R = ioremap(info->phys_base, info->mem_size); - if (!info->nand.IO_ADDR_R) { + chip->IO_ADDR_R = ioremap(info->phys_base, info->mem_size); + if (!chip->IO_ADDR_R) { err = -ENOMEM; goto out_release_mem_region; } - info->nand.controller = &info->controller; + chip->controller = &info->controller; - info->nand.IO_ADDR_W = info->nand.IO_ADDR_R; - info->nand.cmd_ctrl = omap_hwcontrol; + chip->IO_ADDR_W = chip->IO_ADDR_R; + chip->cmd_ctrl = omap_hwcontrol; /* * If RDY/BSY line is connected to OMAP then use the omap ready @@ -1504,11 +1504,11 @@ static int omap_nand_probe(struct platform_device *pdev) * device and read status register until you get a failure or success */ if (pdata->dev_ready) { - info->nand.dev_ready = omap_dev_ready; - info->nand.chip_delay = 0; + chip->dev_ready = omap_dev_ready; + chip->chip_delay = 0; } else { - info->nand.waitfunc = omap_wait; - info->nand.chip_delay = 50; + chip->waitfunc = omap_wait; + chip->chip_delay = 50; } /* scan NAND device conncted to controller */ @@ -1517,8 +1517,8 @@ static int omap_nand_probe(struct platform_device *pdev) goto out_release_mem_region; } pr_info("%s: detected %s NAND flash\n", DRIVER_NAME, - (info->nand.options & NAND_BUSWIDTH_16) ? "x16" : "x8"); - if ((info->nand.options & NAND_BUSWIDTH_16) != + (chip->options & NAND_BUSWIDTH_16) ? "x16" : "x8"); + if ((chip->options & NAND_BUSWIDTH_16) != (pdata->devsize & NAND_BUSWIDTH_16)) { pr_err("%s: but incorrectly configured as %s", DRIVER_NAME, (pdata->devsize & NAND_BUSWIDTH_16) ? "x16" : "x8"); @@ -1538,17 +1538,17 @@ static int omap_nand_probe(struct platform_device *pdev) /* populate read & write API based on xfer_type selected */ switch (pdata->xfer_type) { case NAND_OMAP_PREFETCH_POLLED: - info->nand.read_buf = omap_read_buf_pref; - info->nand.write_buf = omap_write_buf_pref; + chip->read_buf = omap_read_buf_pref; + chip->write_buf = omap_write_buf_pref; break; case NAND_OMAP_POLLED: - if (info->nand.options & NAND_BUSWIDTH_16) { - info->nand.read_buf = omap_read_buf16; - info->nand.write_buf = omap_write_buf16; + if (chip->options & NAND_BUSWIDTH_16) { + chip->read_buf = omap_read_buf16; + chip->write_buf = omap_write_buf16; } else { - info->nand.read_buf = omap_read_buf8; - info->nand.write_buf = omap_write_buf8; + chip->read_buf = omap_read_buf8; + chip->write_buf = omap_write_buf8; } break; @@ -1577,8 +1577,8 @@ static int omap_nand_probe(struct platform_device *pdev) err); goto out_release_mem_region; } - info->nand.read_buf = omap_read_buf_dma_pref; - info->nand.write_buf = omap_write_buf_dma_pref; + chip->read_buf = omap_read_buf_dma_pref; + chip->write_buf = omap_write_buf_dma_pref; } break; @@ -1613,8 +1613,8 @@ static int omap_nand_probe(struct platform_device *pdev) goto out_release_mem_region; } - info->nand.read_buf = omap_read_buf_irq_pref; - info->nand.write_buf = omap_write_buf_irq_pref; + chip->read_buf = omap_read_buf_irq_pref; + chip->write_buf = omap_write_buf_irq_pref; break; @@ -1629,34 +1629,33 @@ static int omap_nand_probe(struct platform_device *pdev) switch (pdata->ecc_opt) { case OMAP_ECC_HAMMING_CODE_DEFAULT: pr_info("using OMAP_ECC_HAMMING_CODE_DEFAULT ECC scheme\n"); - info->nand.ecc.mode = NAND_ECC_SOFT; + chip->ecc.mode = NAND_ECC_SOFT; goto generic_ecc_layout; case OMAP_ECC_HAMMING_CODE_HW: pr_info("using OMAP_ECC_HAMMING_CODE_HW ECC scheme\n"); - info->nand.ecc.mode = NAND_ECC_HW; - info->nand.ecc.bytes = 3; - info->nand.ecc.size = 512; - info->nand.ecc.strength = 1; - info->nand.ecc.calculate = omap_calculate_ecc; - info->nand.ecc.hwctl = omap_enable_hwecc; - info->nand.ecc.correct = omap_correct_data; + chip->ecc.mode = NAND_ECC_HW; + chip->ecc.bytes = 3; + chip->ecc.size = 512; + chip->ecc.strength = 1; + chip->ecc.calculate = omap_calculate_ecc; + chip->ecc.hwctl = omap_enable_hwecc; + chip->ecc.correct = omap_correct_data; goto generic_ecc_layout; case OMAP_ECC_HAMMING_CODE_HW_ROMCODE: pr_info("using OMAP_ECC_HAMMING_CODE_HW_ROMCODE ECC scheme\n"); - info->nand.ecc.mode = NAND_ECC_HW; - info->nand.ecc.bytes = 3; - info->nand.ecc.size = 512; - info->nand.ecc.strength = 1; - info->nand.ecc.calculate = omap_calculate_ecc; - info->nand.ecc.hwctl = omap_enable_hwecc; - info->nand.ecc.correct = omap_correct_data; + chip->ecc.mode = NAND_ECC_HW; + chip->ecc.bytes = 3; + chip->ecc.size = 512; + chip->ecc.strength = 1; + chip->ecc.calculate = omap_calculate_ecc; + chip->ecc.hwctl = omap_enable_hwecc; + chip->ecc.correct = omap_correct_data; /* define custom ECC layout */ - omap_oobinfo.eccbytes = info->nand.ecc.bytes * - (mtd->writesize / - info->nand.ecc.size); - if (info->nand.options & NAND_BUSWIDTH_16) + omap_oobinfo.eccbytes = chip->ecc.bytes * + (mtd->writesize / chip->ecc.size); + if (chip->options & NAND_BUSWIDTH_16) omap_oobinfo.eccpos[0] = BADBLOCK_MARKER_LENGTH; else omap_oobinfo.eccpos[0] = 1; @@ -1667,19 +1666,17 @@ static int omap_nand_probe(struct platform_device *pdev) #ifdef CONFIG_MTD_NAND_ECC_BCH case OMAP_ECC_BCH4_CODE_HW_DETECTION_SW: pr_info("using OMAP_ECC_BCH4_CODE_HW_DETECTION_SW ECC scheme"); - info->nand.ecc.mode = NAND_ECC_HW; - info->nand.ecc.size = 512; - info->nand.ecc.bytes = 7; - info->nand.ecc.strength = 4; - info->nand.ecc.hwctl = omap_enable_hwecc; - info->nand.ecc.correct = nand_bch_correct_data; - info->nand.ecc.calculate = omap_calculate_ecc_bch; + chip->ecc.mode = NAND_ECC_HW; + chip->ecc.size = 512; + chip->ecc.bytes = 7; + chip->ecc.strength = 4; + chip->ecc.hwctl = omap_enable_hwecc; + chip->ecc.correct = nand_bch_correct_data; + chip->ecc.calculate = omap_calculate_ecc_bch; /* software bch library is used for locating errors */ - info->nand.ecc.priv = nand_bch_init(mtd, - info->nand.ecc.size, - info->nand.ecc.bytes, - &info->nand.ecc.layout); - if (!info->nand.ecc.priv) { + chip->ecc.priv = nand_bch_init(mtd, chip->ecc.size, + chip->ecc.bytes, &chip->ecc.layout); + if (!chip->ecc.priv) { pr_err("unable initialize S/W BCH logic\n"); err = -EINVAL; goto out_release_mem_region; @@ -1689,16 +1686,16 @@ static int omap_nand_probe(struct platform_device *pdev) #ifdef CONFIG_MTD_NAND_OMAP_BCH case OMAP_ECC_BCH4_CODE_HW: pr_info("using OMAP_ECC_BCH4_CODE_HW ECC scheme\n"); - info->nand.ecc.mode = NAND_ECC_HW; - info->nand.ecc.size = 512; + chip->ecc.mode = NAND_ECC_HW; + chip->ecc.size = 512; /* 8th bit is kept reserved for ROM-code compatibility */ - info->nand.ecc.bytes = 7 + 1; - info->nand.ecc.strength = 4; - info->nand.ecc.hwctl = omap_enable_hwecc; - info->nand.ecc.correct = omap_elm_correct_data; - info->nand.ecc.calculate = omap_calculate_ecc_bch; - info->nand.ecc.read_page = omap_read_page_bch; - info->nand.ecc.write_page = omap_write_page_bch; + chip->ecc.bytes = 7 + 1; + chip->ecc.strength = 4; + chip->ecc.hwctl = omap_enable_hwecc; + chip->ecc.correct = omap_elm_correct_data; + chip->ecc.calculate = omap_calculate_ecc_bch; + chip->ecc.read_page = omap_read_page_bch; + chip->ecc.write_page = omap_write_page_bch; /* ELM H/W engine is used for locating errors */ if (is_elm_present(info, BCH4_ECC) < 0) { pr_err("ELM module not detected, required for ECC\n"); @@ -1706,30 +1703,27 @@ static int omap_nand_probe(struct platform_device *pdev) goto out_release_mem_region; } /* define custom ECC layout */ - omap_oobinfo.eccbytes = info->nand.ecc.bytes * - (mtd->writesize / - info->nand.ecc.size); - omap_oobinfo.eccpos[0] = BADBLOCK_MARKER_LENGTH; - omap_oobinfo.oobfree->offset = omap_oobinfo.eccpos[0] + - omap_oobinfo.eccbytes; + omap_oobinfo.eccbytes = chip->ecc.bytes * + (mtd->writesize / chip->ecc.size); + omap_oobinfo.eccpos[0] = BADBLOCK_MARKER_LENGTH; + omap_oobinfo.oobfree->offset = omap_oobinfo.eccpos[0] + + omap_oobinfo.eccbytes; goto custom_ecc_layout; #endif #ifdef CONFIG_MTD_NAND_ECC_BCH case OMAP_ECC_BCH8_CODE_HW_DETECTION_SW: pr_info("using OMAP_ECC_BCH8_CODE_HW_DETECTION_SW ECC\n"); - info->nand.ecc.mode = NAND_ECC_HW; - info->nand.ecc.size = 512; - info->nand.ecc.bytes = 13; - info->nand.ecc.strength = 8; - info->nand.ecc.hwctl = omap_enable_hwecc; - info->nand.ecc.correct = nand_bch_correct_data; - info->nand.ecc.calculate = omap_calculate_ecc_bch; + chip->ecc.mode = NAND_ECC_HW; + chip->ecc.size = 512; + chip->ecc.bytes = 13; + chip->ecc.strength = 8; + chip->ecc.hwctl = omap_enable_hwecc; + chip->ecc.correct = nand_bch_correct_data; + chip->ecc.calculate = omap_calculate_ecc_bch; /* software bch library is used for locating errors */ - info->nand.ecc.priv = nand_bch_init(mtd, - info->nand.ecc.size, - info->nand.ecc.bytes, - &info->nand.ecc.layout); - if (!info->nand.ecc.priv) { + chip->ecc.priv = nand_bch_init(mtd, chip->ecc.size, + chip->ecc.bytes, &chip->ecc.layout); + if (!chip->ecc.priv) { pr_err("unable initialize S/W BCH logic\n"); err = -EINVAL; goto out_release_mem_region; @@ -1739,16 +1733,16 @@ static int omap_nand_probe(struct platform_device *pdev) #ifdef CONFIG_MTD_NAND_OMAP_BCH case OMAP_ECC_BCH8_CODE_HW: pr_info("using OMAP_ECC_BCH8_CODE_HW ECC scheme\n"); - info->nand.ecc.mode = NAND_ECC_HW; - info->nand.ecc.size = 512; + chip->ecc.mode = NAND_ECC_HW; + chip->ecc.size = 512; /* 14th bit is kept reserved for ROM-code compatibility */ - info->nand.ecc.bytes = 13 + 1; - info->nand.ecc.strength = 8; - info->nand.ecc.hwctl = omap_enable_hwecc; - info->nand.ecc.correct = omap_elm_correct_data; - info->nand.ecc.calculate = omap_calculate_ecc_bch; - info->nand.ecc.read_page = omap_read_page_bch; - info->nand.ecc.write_page = omap_write_page_bch; + chip->ecc.bytes = 13 + 1; + chip->ecc.strength = 8; + chip->ecc.hwctl = omap_enable_hwecc; + chip->ecc.correct = omap_elm_correct_data; + chip->ecc.calculate = omap_calculate_ecc_bch; + chip->ecc.read_page = omap_read_page_bch; + chip->ecc.write_page = omap_write_page_bch; /* ELM H/W engine is used for locating errors */ if (is_elm_present(info, BCH8_ECC) < 0) { pr_err("ELM module not detected, required for ECC\n"); @@ -1756,16 +1750,16 @@ static int omap_nand_probe(struct platform_device *pdev) goto out_release_mem_region; } /* define custom ECC layout */ - omap_oobinfo.eccbytes = info->nand.ecc.bytes * - (mtd->writesize / - info->nand.ecc.size); - omap_oobinfo.eccpos[0] = BADBLOCK_MARKER_LENGTH; - omap_oobinfo.oobfree->offset = omap_oobinfo.eccpos[0] + - omap_oobinfo.eccbytes; + omap_oobinfo.eccbytes = chip->ecc.bytes * + (mtd->writesize / chip->ecc.size); + omap_oobinfo.eccpos[0] = BADBLOCK_MARKER_LENGTH; + omap_oobinfo.oobfree->offset = omap_oobinfo.eccpos[0] + + omap_oobinfo.eccbytes; goto custom_ecc_layout; #endif default: - pr_err("selected ECC scheme not supported or not enabled\n"); + pr_err("%s: selected ECC scheme not supported or not enabled", + DRIVER_NAME); err = -EINVAL; goto out_release_mem_region; } @@ -1775,8 +1769,8 @@ custom_ecc_layout: pr_info("%s: using custom ecc layout\n", DRIVER_NAME); omap_oobinfo.oobfree->length = mtd->oobsize - BADBLOCK_MARKER_LENGTH - omap_oobinfo.eccbytes; - if (!(info->nand.options & NAND_BUSWIDTH_16)) - info->nand.badblock_pattern = &bb_descrip_flashbased; + if (!(chip->options & NAND_BUSWIDTH_16)) + chip->badblock_pattern = &bb_descrip_flashbased; for (i = 1; i < omap_oobinfo.eccbytes; i++) omap_oobinfo.eccpos[i] = omap_oobinfo.eccpos[0] + i; @@ -1788,20 +1782,20 @@ custom_ecc_layout: err = -EINVAL; goto out_release_mem_region; } - info->nand.ecc.layout = &omap_oobinfo; + chip->ecc.layout = &omap_oobinfo; generic_ecc_layout: /* second phase scan */ - if (nand_scan_tail(&info->mtd)) { + if (nand_scan_tail(mtd)) { err = -ENXIO; goto out_release_mem_region; } ppdata.of_node = pdata->of_node; - mtd_device_parse_register(&info->mtd, NULL, &ppdata, pdata->parts, + mtd_device_parse_register(mtd, NULL, &ppdata, pdata->parts, pdata->nr_parts); - platform_set_drvdata(pdev, &info->mtd); + platform_set_drvdata(pdev, mtd); return 0; @@ -1816,9 +1810,9 @@ out_release_mem_region: out_free_info: #ifdef CONFIG_MTD_NAND_ECC_BCH - if (info->nand.ecc.priv) { - nand_bch_free(info->nand.ecc.priv); - info->nand.ecc.priv = NULL; + if (chip->ecc.priv) { + nand_bch_free(chip->ecc.priv); + chip->ecc.priv = NULL; } #endif kfree(info);