linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memory: mtk-smi: Use of_device_get_match_data helper
@ 2017-07-26  9:52 honghui.zhang at mediatek.com
  2017-07-30  0:45 ` kbuild test robot
  0 siblings, 1 reply; 5+ messages in thread
From: honghui.zhang at mediatek.com @ 2017-07-26  9:52 UTC (permalink / raw)
  To: linux-arm-kernel

From: Honghui Zhang <honghui.zhang@mediatek.com>

Replace custom code with generic helper to retrieve driver data.

Signed-off-by: Honghui Zhang <honghui.zhang@mediatek.com>
---
 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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] memory: mtk-smi: Use of_device_get_match_data helper
@ 2017-07-26  9:59 honghui.zhang at mediatek.com
  2017-07-26 10:36 ` Robin Murphy
  0 siblings, 1 reply; 5+ messages in thread
From: honghui.zhang at mediatek.com @ 2017-07-26  9:59 UTC (permalink / raw)
  To: linux-arm-kernel

From: Honghui Zhang <honghui.zhang@mediatek.com>

Replace custom code with generic helper to retrieve driver data.

Signed-off-by: Honghui Zhang <honghui.zhang@mediatek.com>
---
 drivers/memory/mtk-smi.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c
index 4afbc41..fe8b81a 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,8 +314,7 @@ 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;
+	const enum mtk_smi_gen *smi_gen;
 
 	if (!dev->pm_domain)
 		return -EPROBE_DEFER;
@@ -338,18 +332,14 @@ 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;
-	if (smi_gen == MTK_SMI_GEN1) {
+	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);
 		if (IS_ERR(common->smi_ao_base))
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] memory: mtk-smi: Use of_device_get_match_data helper
  2017-07-26  9:59 honghui.zhang at mediatek.com
@ 2017-07-26 10:36 ` Robin Murphy
  2017-07-26 12:35   ` Honghui Zhang
  0 siblings, 1 reply; 5+ messages in thread
From: Robin Murphy @ 2017-07-26 10:36 UTC (permalink / raw)
  To: linux-arm-kernel

On 26/07/17 10:59, honghui.zhang at mediatek.com wrote:
> From: Honghui Zhang <honghui.zhang@mediatek.com>
> 
> Replace custom code with generic helper to retrieve driver data.
> 
> Signed-off-by: Honghui Zhang <honghui.zhang@mediatek.com>
> ---
>  drivers/memory/mtk-smi.c | 18 ++++--------------
>  1 file changed, 4 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c
> index 4afbc41..fe8b81a 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,8 +314,7 @@ 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;
> +	const enum mtk_smi_gen *smi_gen;
>  
>  	if (!dev->pm_domain)
>  		return -EPROBE_DEFER;
> @@ -338,18 +332,14 @@ 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;
> -	if (smi_gen == MTK_SMI_GEN1) {
> +	smi_gen = of_device_get_match_data(dev);

The data you're retrieving is the exact same thing as of_id->data was,
i.e. an enum mtk_smi_gen cast to void*, so dereferencing it is not a
good idea. The first patch was almost right; you just need to keep the
cast in the assignment to smi_gen.

Robin.

> +	if (*smi_gen == MTK_SMI_GEN1) {
>  		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  		common->smi_ao_base = devm_ioremap_resource(dev, res);
>  		if (IS_ERR(common->smi_ao_base))
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] memory: mtk-smi: Use of_device_get_match_data helper
  2017-07-26 10:36 ` Robin Murphy
@ 2017-07-26 12:35   ` Honghui Zhang
  0 siblings, 0 replies; 5+ messages in thread
From: Honghui Zhang @ 2017-07-26 12:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 2017-07-26 at 11:36 +0100, Robin Murphy wrote:
> On 26/07/17 10:59, honghui.zhang at mediatek.com wrote:
> > From: Honghui Zhang <honghui.zhang@mediatek.com>
> > 

> >  	 * 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;
> > -	if (smi_gen == MTK_SMI_GEN1) {
> > +	smi_gen = of_device_get_match_data(dev);
> 
> The data you're retrieving is the exact same thing as of_id->data was,
> i.e. an enum mtk_smi_gen cast to void*, so dereferencing it is not a
> good idea. The first patch was almost right; you just need to keep the
> cast in the assignment to smi_gen.
> 
> Robin.
> 
Hi, Robin, thanks very much.
I will send a new version.

> > +	if (*smi_gen == MTK_SMI_GEN1) {
> >  		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >  		common->smi_ao_base = devm_ioremap_resource(dev, res);
> >  		if (IS_ERR(common->smi_ao_base))
> > 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] memory: mtk-smi: Use of_device_get_match_data helper
  2017-07-26  9:52 [PATCH] memory: mtk-smi: Use of_device_get_match_data helper honghui.zhang at mediatek.com
@ 2017-07-30  0:45 ` kbuild test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2017-07-30  0:45 UTC (permalink / raw)
  To: linux-arm-kernel

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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 56840 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170730/8992a771/attachment-0001.gz>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-07-30  0:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-26  9:52 [PATCH] memory: mtk-smi: Use of_device_get_match_data helper honghui.zhang at mediatek.com
2017-07-30  0:45 ` kbuild test robot
  -- strict thread matches above, loose matches on Subject: below --
2017-07-26  9:59 honghui.zhang at mediatek.com
2017-07-26 10:36 ` Robin Murphy
2017-07-26 12:35   ` Honghui Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).