Received: by 10.192.165.156 with SMTP id m28csp217717imm; Sun, 15 Apr 2018 21:29:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx49nhkztIHDAbwbpFApUQtB4bIjYsaicDyww4u1aswH22Ym/cf/SeE+QTKNeZuZAXHGFhRpX X-Received: by 2002:a17:902:43e4:: with SMTP id j91-v6mr14185483pld.118.1523852982848; Sun, 15 Apr 2018 21:29:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523852982; cv=none; d=google.com; s=arc-20160816; b=alvxSyosRlaHhNSbybztRV7tb1Ctx9Fkvq5xQ7zssDP9sidy0/FwYjs860rV/qHVCa +gOMGIcN8dZkHWWiyN24gwv98i+3tzrgWuz8VDwvbAvP0woFoqKyWFI/XvZkADo9EIMx NJHZKi/dK1607qd5Uo5NpLEi2P3611WpqbuoFsAebzFjTsrcFyIwli94qikEb4uwR8YC wE+CbhtchqQnFUYp2Bqc1HGgvAO6Yziuj6z7bcfg23UW1ebeghs1tGkDfOJjALPxuPUA d1S9aCTsxcTyoo+b1qOvBaxw2tL9OaQdljKoZItFkWKX3lIDNvaiqaSidUB9rFXtINmX oHTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=s0j7Zl6piZc5EoV14Y5MyIRwUEVhc/9biErkFyZVGeI=; b=bl8RpfQCOI+GRD+95ZQjCS8tD4MVfCGCeFrjvwIZXsFHL9ErxhTHItAxxuMmNib6Us j8aII3lJFu/m6DMcLNQvLzB1/O+eQdOD9PsPCP7DCclPTShDUx3fefcVS50jXfN9PGnv 6w55pGB7Kmx5v5RhKMrj6nsDecpo2gF6i0NP4t/JHCz0hoAUbddk0BR+a6/B722So5sM JAKYR/HJfFg80BGmhv8Rff2e4NcvZMnCMdWKYRKcKHJ1Ag9UNUBdPXRTuw0KDuQ5sgF8 ty/u45rZi8OE+q4kW2SVn5AHyktdyaEXQKLs1BsYWrRoQo5aBYhbO4lAAIrdHUIj49N+ 27ig== 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 z188si5602359pgb.134.2018.04.15.21.29.28; Sun, 15 Apr 2018 21:29:42 -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 S1753300AbeDPE1z (ORCPT + 99 others); Mon, 16 Apr 2018 00:27:55 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:58678 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751113AbeDPE1y (ORCPT ); Mon, 16 Apr 2018 00:27:54 -0400 X-UUID: 12908bfa7aa54a27993f2282ef898600-20180416 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1148062046; Mon, 16 Apr 2018 12:27:46 +0800 Received: from MTKCAS36.mediatek.inc (172.27.4.186) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 16 Apr 2018 12:27:38 +0800 Received: from [10.17.3.153] (10.17.3.153) by MTKCAS36.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Mon, 16 Apr 2018 12:27:37 +0800 Message-ID: <1523852857.14673.30.camel@mhfsdcap03> Subject: Re: [PATCH] mtd: nand: mtk: use of_device_get_match_data() From: xiaolei li To: Ryder Lee CC: Boris Brezillon , , , , Date: Mon, 16 Apr 2018 12:27:37 +0800 In-Reply-To: References: <31f944ab8dfcc1d7b6f03b35657a2a34825b5246.1523347340.git.ryder.lee@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2018-04-16 at 10:33 +0800, Ryder Lee wrote: > 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); > Thanks. Reviewed-by: Xiaolei Li > 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);