2017-07-26 09:52:18

by Honghui Zhang

[permalink] [raw]
Subject: [PATCH] memory: mtk-smi: Use of_device_get_match_data helper

From: Honghui Zhang <[email protected]>

Replace custom code with generic helper to retrieve driver data.

Signed-off-by: Honghui Zhang <[email protected]>
---
drivers/memory/mtk-smi.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c
index 4afbc41..69249f5 100644
--- a/drivers/memory/mtk-smi.c
+++ b/drivers/memory/mtk-smi.c
@@ -240,20 +240,15 @@ static int mtk_smi_larb_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct device_node *smi_node;
struct platform_device *smi_pdev;
- const struct of_device_id *of_id;

if (!dev->pm_domain)
return -EPROBE_DEFER;

- of_id = of_match_node(mtk_smi_larb_of_ids, pdev->dev.of_node);
- if (!of_id)
- return -EINVAL;
-
larb = devm_kzalloc(dev, sizeof(*larb), GFP_KERNEL);
if (!larb)
return -ENOMEM;

- larb->larb_gen = of_id->data;
+ larb->larb_gen = of_device_get_match_data(dev);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
larb->base = devm_ioremap_resource(dev, res);
if (IS_ERR(larb->base))
@@ -319,7 +314,6 @@ static int mtk_smi_common_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct mtk_smi *common;
struct resource *res;
- const struct of_device_id *of_id;
enum mtk_smi_gen smi_gen;

if (!dev->pm_domain)
@@ -338,17 +332,13 @@ static int mtk_smi_common_probe(struct platform_device *pdev)
if (IS_ERR(common->clk_smi))
return PTR_ERR(common->clk_smi);

- of_id = of_match_node(mtk_smi_common_of_ids, pdev->dev.of_node);
- if (!of_id)
- return -EINVAL;
-
/*
* for mtk smi gen 1, we need to get the ao(always on) base to config
* m4u port, and we need to enable the aync clock for transform the smi
* clock into emi clock domain, but for mtk smi gen2, there's no smi ao
* base.
*/
- smi_gen = (enum mtk_smi_gen)of_id->data;
+ smi_gen = of_device_get_match_data(dev);
if (smi_gen == MTK_SMI_GEN1) {
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
common->smi_ao_base = devm_ioremap_resource(dev, res);
--
2.6.4


2017-07-30 00:36:33

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] memory: mtk-smi: Use of_device_get_match_data helper

Hi Honghui,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.13-rc2 next-20170728]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/honghui-zhang-mediatek-com/memory-mtk-smi-Use-of_device_get_match_data-helper/20170728-161812
config: arm64-allmodconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm64

All errors (new ones prefixed by >>):

drivers//memory/mtk-smi.c: In function 'mtk_smi_common_probe':
>> drivers//memory/mtk-smi.c:341:10: error: incompatible types when assigning to type 'enum mtk_smi_gen' from type 'const void *'
smi_gen = of_device_get_match_data(dev);
^

vim +341 drivers//memory/mtk-smi.c

311
312 static int mtk_smi_common_probe(struct platform_device *pdev)
313 {
314 struct device *dev = &pdev->dev;
315 struct mtk_smi *common;
316 struct resource *res;
317 enum mtk_smi_gen smi_gen;
318
319 if (!dev->pm_domain)
320 return -EPROBE_DEFER;
321
322 common = devm_kzalloc(dev, sizeof(*common), GFP_KERNEL);
323 if (!common)
324 return -ENOMEM;
325 common->dev = dev;
326
327 common->clk_apb = devm_clk_get(dev, "apb");
328 if (IS_ERR(common->clk_apb))
329 return PTR_ERR(common->clk_apb);
330
331 common->clk_smi = devm_clk_get(dev, "smi");
332 if (IS_ERR(common->clk_smi))
333 return PTR_ERR(common->clk_smi);
334
335 /*
336 * for mtk smi gen 1, we need to get the ao(always on) base to config
337 * m4u port, and we need to enable the aync clock for transform the smi
338 * clock into emi clock domain, but for mtk smi gen2, there's no smi ao
339 * base.
340 */
> 341 smi_gen = of_device_get_match_data(dev);
342 if (smi_gen == MTK_SMI_GEN1) {
343 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
344 common->smi_ao_base = devm_ioremap_resource(dev, res);
345 if (IS_ERR(common->smi_ao_base))
346 return PTR_ERR(common->smi_ao_base);
347
348 common->clk_async = devm_clk_get(dev, "async");
349 if (IS_ERR(common->clk_async))
350 return PTR_ERR(common->clk_async);
351
352 clk_prepare_enable(common->clk_async);
353 }
354 pm_runtime_enable(dev);
355 platform_set_drvdata(pdev, common);
356 return 0;
357 }
358

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (2.76 kB)
.config.gz (55.51 kB)
Download all attachments