Received: by 10.192.165.156 with SMTP id m28csp153793imm; Sun, 15 Apr 2018 19:36:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx499NEC65euSqExQIQsr1KIu9RV0ZRyWsjZh0GUZc2jvua0J/rJYe1SbgZpk7Js/zM2FhVkG X-Received: by 2002:a17:902:6986:: with SMTP id l6-v6mr10966729plk.209.1523846218120; Sun, 15 Apr 2018 19:36:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523846218; cv=none; d=google.com; s=arc-20160816; b=sf0Mg7yRMrMvZWXTCgZQ+lmY9ZM27XdsHxgExNx+odZLPj5i0fP8Mu5DiQebGxAEi6 DwBE7gTMgUtZAi00keza2T6mD3GIWIJchcvSzybA6+tivX8cQ7j6qPjnomvP1UZSogV2 ytROtWw1RC7GTMy06q7XsU/e/k9DgahPbLqnHJUfp4F9csN0ZUSqM6wLqkLb54LsgUBu 3rL3Y+RPYkHDKAg6/vc6xG18z+DPXMMj1cZmeg4m62k8gVqS6x6Trzzrv7FbwycxWOfU VN6Vx1o144xYHBVvIWRgqNXL6GHkDX3fIRLGoZe95O+OFf5yuJTS5tOB2Z37Oey04qva QKGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=1VXxwusMybu/db+1OEL/oQMzfpjqoP9pdgqxR1DZGRU=; b=RfYQJ2ZVdKzyhG6KieAKutgZ7TiUcQGizdRHtnkdbTKnpxUpr+/8pplrTZmwHdwaFh VvnwIRRomm+bQzaj2IbFmjc3ZIOjoE01wo7Aw/iX56xTSetUDFcobTZqZgeO0+MtACgj qGxH7YNSFlGZc6OZdpL1QiWUgCQgdVqpLw0bItt8UDGiiae4IUFDZeyGruoGquCm1g/z b1wvaz9n1BPGjMQvKpFbqjyLCrMUFPaG0oG9o7IsxEFH/38lM/6IRGLXAT93wkbz+z1R XQSE9bVT5zLoSdvuRXC1gCU5f+/BP2Md3yXPnp+j2wY2sItov/7nstGnUSK2nLfBcnoA p27g== ARC-Authentication-Results: i=1; mx.google.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 g3si2085353pgs.396.2018.04.15.19.36.44; Sun, 15 Apr 2018 19:36:58 -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; 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 S1753210AbeDPCeC (ORCPT + 99 others); Sun, 15 Apr 2018 22:34:02 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:3490 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752965AbeDPCeB (ORCPT ); Sun, 15 Apr 2018 22:34:01 -0400 X-UUID: 527ab7cc19f846d196a829430d856b46-20180416 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1430837637; Mon, 16 Apr 2018 10:33:57 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 16 Apr 2018 10:33:55 +0800 Received: from mtkslt306.mediatek.inc (10.21.14.136) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Mon, 16 Apr 2018 10:33:55 +0800 From: Ryder Lee To: Boris Brezillon CC: Xiaolei Li , , , , , Ryder Lee Subject: [PATCH] mtd: nand: mtk: use of_device_get_match_data() Date: Mon, 16 Apr 2018 10:33:54 +0800 Message-ID: X-Mailer: git-send-email 1.9.1 In-Reply-To: <31f944ab8dfcc1d7b6f03b35657a2a34825b5246.1523347340.git.ryder.lee@mediatek.com> References: <31f944ab8dfcc1d7b6f03b35657a2a34825b5246.1523347340.git.ryder.lee@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The usage of of_device_get_match_data() reduce the code size a bit. Also, the only way to call .probe() is to match an entry in .of_match_table[], so of_device_id cannot be NULL. Signed-off-by: Ryder Lee --- drivers/mtd/nand/raw/mtk_ecc.c | 7 +------ drivers/mtd/nand/raw/mtk_nand.c | 10 +--------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/mtd/nand/mtk_ecc.c b/drivers/mtd/nand/mtk_ecc.c index 40d86a8..6432bd7 100644 --- a/drivers/mtd/nand/raw/mtk_ecc.c +++ b/drivers/mtd/nand/raw/mtk_ecc.c @@ -500,7 +500,6 @@ static int mtk_ecc_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct mtk_ecc *ecc; struct resource *res; - const struct of_device_id *of_ecc_id = NULL; u32 max_eccdata_size; int irq, ret; @@ -508,11 +507,7 @@ static int mtk_ecc_probe(struct platform_device *pdev) if (!ecc) return -ENOMEM; - of_ecc_id = of_match_device(mtk_ecc_dt_match, &pdev->dev); - if (!of_ecc_id) - return -ENODEV; - - ecc->caps = of_ecc_id->data; + ecc->caps = of_device_get_match_data(dev); max_eccdata_size = ecc->caps->num_ecc_strength - 1; max_eccdata_size = ecc->caps->ecc_strength[max_eccdata_size]; diff --git a/drivers/mtd/nand/mtk_nand.c b/drivers/mtd/nand/mtk_nand.c index 6977da3..75c845a 100644 --- a/drivers/mtd/nand/raw/mtk_nand.c +++ b/drivers/mtd/nand/raw/mtk_nand.c @@ -1434,7 +1434,6 @@ static int mtk_nfc_probe(struct platform_device *pdev) struct device_node *np = dev->of_node; struct mtk_nfc *nfc; struct resource *res; - const struct of_device_id *of_nfc_id = NULL; int ret, irq; nfc = devm_kzalloc(dev, sizeof(*nfc), GFP_KERNEL); @@ -1452,6 +1451,7 @@ static int mtk_nfc_probe(struct platform_device *pdev) else if (!nfc->ecc) return -ENODEV; + nfc->caps = of_device_get_match_data(dev); nfc->dev = dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -1498,14 +1498,6 @@ static int mtk_nfc_probe(struct platform_device *pdev) goto clk_disable; } - of_nfc_id = of_match_device(mtk_nfc_id_table, &pdev->dev); - if (!of_nfc_id) { - ret = -ENODEV; - goto clk_disable; - } - - nfc->caps = of_nfc_id->data; - platform_set_drvdata(pdev, nfc); ret = mtk_nfc_nand_chips_init(dev, nfc); -- 1.9.1