From patchwork Wed Aug 16 07:29:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 801924 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="TsRp7I3z"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="AkMCBHY1"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xXLYv0VQPz9sNn for ; Wed, 16 Aug 2017 17:28:51 +1000 (AEST) 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: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:In-Reply-To:References: List-Owner; bh=sX+Q0u5PiaKE1K2bpNv7frvEVPZDTpfhtUHy+eVBqQc=; b=TsRp7I3zaGBVRd aZi3IhtAbx4JcbU/linp+2ya8t9Pj5F3bcmAM45hmMjyVLpCzWVHtqsOPDjqEea8b62JUSBJ+4PQf gQXVhnIBxT8RfFMqSNY61YCLjUHjcTTt0v8iGEaLOdKzpk9bt4rf0jyECFFDilSb4Gx7hC6C88AGj JdRWqRINr3t2Yz84yNjJj82e8BfLa5OagiVwZEJp7VCKnK94XO1hF5oYiMcshBN12b2ynx4i26MXu F7xSdLjZ5dycIAr2pdz+9Jd7Fif9ZEgDzM0NLRS0aENhsXmXI8lhbMs+r7xi7+I4GBBiwuVrtvvGu 7LZPB0NqMW721KQFNFbQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dhskr-0006Fx-V9; Wed, 16 Aug 2017 07:28:41 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dhskq-0006FH-LA for linux-mtd@bombadil.infradead.org; Wed, 16 Aug 2017 07:28:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:Message-ID: Date:Subject:CC:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=7HjCzFYb8Lk9Di7p6mcNIkrcpLmYmrmpznh8+jooS4w=; b=AkMCBHY1Z53wH+q6/j9EOKFZ+0 IMncZNoWJpdgtRAnSdkhzVXTjrdYkHREAaAhyeFj8hfU9A7vDy2OZPaGgb5yDGBbj6PttYPpPyqIc AAQqoX1Psmu//Sc0GPwRr3DTor0L2lzR8W05UJacdBAmmO265Qiew0D4bzlc+sC+IQ5pSBjJY4Jus xdtvOwyll1buL77wbSNtv0FSn0xcY4LDgqWu0jngdcrJPCPhZqIl8fFCt3LSR/ye/LpVplDZY52nq HXdXkbWPDA+XQNlpqunGBiSzfVGxCHHVzOKpouRuQ1M+eaTGlhcg3w6sr3Hlg+x77EC3Ncu7pM6tQ pNxHVZqw==; Received: from szxga05-in.huawei.com ([45.249.212.191]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dhskl-0007yy-Gq for linux-mtd@lists.infradead.org; Wed, 16 Aug 2017 07:28:38 +0000 Received: from 172.30.72.60 (EHLO DGGEMS403-HUB.china.huawei.com) ([172.30.72.60]) by dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DFI29358; Wed, 16 Aug 2017 15:27:16 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.301.0; Wed, 16 Aug 2017 15:27:05 +0800 From: Kefeng Wang To: Boris Brezillon Subject: [PATCH] mtd: nand: convert to unified device property interface Date: Wed, 16 Aug 2017 15:29:05 +0800 Message-ID: <1502868545-124616-1-git-send-email-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.5993F3D5.0037, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: b8a779f89d8373ac4310e2eec7b6fc83 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170816_082836_867115_A16F43EF X-CRM114-Status: GOOD ( 19.06 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (-1.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Weinberger , Kefeng Wang , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, guohanjun@huawei.com Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Changing from of_* to device_* interface, then we can also extract the properties from ACPI tables as well as from DT. Signed-off-by: Kefeng Wang --- - APCI will be supported in hisi504_nand.c, and it will use nand_scan_ident(). drivers/mtd/nand/nand_base.c | 54 ++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index c6c18b8..27a0947 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -46,7 +46,7 @@ #include #include #include -#include +#include static int nand_get_device(struct mtd_info *mtd, int new_state); @@ -4209,12 +4209,12 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type) [NAND_ECC_ON_DIE] = "on-die", }; -static int of_get_nand_ecc_mode(struct device_node *np) +static int device_get_nand_ecc_mode(struct device *dev) { const char *pm; int err, i; - err = of_property_read_string(np, "nand-ecc-mode", &pm); + err = device_property_read_string(dev, "nand-ecc-mode", &pm); if (err < 0) return err; @@ -4238,12 +4238,12 @@ static int of_get_nand_ecc_mode(struct device_node *np) [NAND_ECC_BCH] = "bch", }; -static int of_get_nand_ecc_algo(struct device_node *np) +static int device_get_nand_ecc_algo(struct device *dev) { const char *pm; int err, i; - err = of_property_read_string(np, "nand-ecc-algo", &pm); + err = device_property_read_string(dev, "nand-ecc-algo", &pm); if (!err) { for (i = NAND_ECC_HAMMING; i < ARRAY_SIZE(nand_ecc_algos); i++) if (!strcasecmp(pm, nand_ecc_algos[i])) @@ -4255,7 +4255,7 @@ static int of_get_nand_ecc_algo(struct device_node *np) * For backward compatibility we also read "nand-ecc-mode" checking * for some obsoleted values that were specifying ECC algorithm. */ - err = of_property_read_string(np, "nand-ecc-mode", &pm); + err = device_property_read_string(dev, "nand-ecc-mode", &pm); if (err < 0) return err; @@ -4267,29 +4267,29 @@ static int of_get_nand_ecc_algo(struct device_node *np) return -ENODEV; } -static int of_get_nand_ecc_step_size(struct device_node *np) +static int device_get_nand_ecc_step_size(struct device *dev) { int ret; u32 val; - ret = of_property_read_u32(np, "nand-ecc-step-size", &val); + ret = device_property_read_u32(dev, "nand-ecc-step-size", &val); return ret ? ret : val; } -static int of_get_nand_ecc_strength(struct device_node *np) +static int device_get_nand_ecc_strength(struct device *dev) { int ret; u32 val; - ret = of_property_read_u32(np, "nand-ecc-strength", &val); + ret = device_property_read_u32(dev, "nand-ecc-strength", &val); return ret ? ret : val; } -static int of_get_nand_bus_width(struct device_node *np) +static int device_get_nand_bus_width(struct device *dev) { u32 val; - if (of_property_read_u32(np, "nand-bus-width", &val)) + if (device_property_read_u32(dev, "nand-bus-width", &val)) return 8; switch (val) { @@ -4301,29 +4301,28 @@ static int of_get_nand_bus_width(struct device_node *np) } } -static bool of_get_nand_on_flash_bbt(struct device_node *np) +static bool device_get_nand_on_flash_bbt(struct device *dev) { - return of_property_read_bool(np, "nand-on-flash-bbt"); + return device_property_read_bool(dev, "nand-on-flash-bbt"); } -static int nand_dt_init(struct nand_chip *chip) +static int nand_chip_init(struct nand_chip *chip, struct device *dev) { - struct device_node *dn = nand_get_flash_node(chip); int ecc_mode, ecc_algo, ecc_strength, ecc_step; - if (!dn) + if (!dev) return 0; - if (of_get_nand_bus_width(dn) == 16) + if (device_get_nand_bus_width(dev) == 16) chip->options |= NAND_BUSWIDTH_16; - if (of_get_nand_on_flash_bbt(dn)) + if (device_get_nand_on_flash_bbt(dev)) chip->bbt_options |= NAND_BBT_USE_FLASH; - ecc_mode = of_get_nand_ecc_mode(dn); - ecc_algo = of_get_nand_ecc_algo(dn); - ecc_strength = of_get_nand_ecc_strength(dn); - ecc_step = of_get_nand_ecc_step_size(dn); + ecc_mode = device_get_nand_ecc_mode(dev); + ecc_algo = device_get_nand_ecc_algo(dev); + ecc_strength = device_get_nand_ecc_strength(dev); + ecc_step = device_get_nand_ecc_step_size(dev); if (ecc_mode >= 0) chip->ecc.mode = ecc_mode; @@ -4337,7 +4336,7 @@ static int nand_dt_init(struct nand_chip *chip) if (ecc_step > 0) chip->ecc.size = ecc_step; - if (of_property_read_bool(dn, "nand-ecc-maximize")) + if (device_property_read_bool(dev, "nand-ecc-maximize")) chip->ecc.options |= NAND_ECC_MAXIMIZE; return 0; @@ -4358,14 +4357,15 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips, { int i, nand_maf_id, nand_dev_id; struct nand_chip *chip = mtd_to_nand(mtd); + struct device *dev = mtd->dev.parent; int ret; - ret = nand_dt_init(chip); + ret = nand_chip_init(chip, dev); if (ret) return ret; - if (!mtd->name && mtd->dev.parent) - mtd->name = dev_name(mtd->dev.parent); + if (!mtd->name && dev) + mtd->name = dev_name(dev); if ((!chip->cmdfunc || !chip->select_chip) && !chip->cmd_ctrl) { /*