public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpc925_edac: Use module_platform_driver()
@ 2014-06-09 14:40 Kefeng Wang
  2014-06-10  1:57 ` [PATCH] cpc925_eadc: Use devm_ioremap_resource() Kefeng Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Kefeng Wang @ 2014-06-09 14:40 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Johannes Thumshirn, Doug Thompson
  Cc: linux-edac, linux-kernel

Move edac_op_state assignment operations to probe, then convert to
module_platform_drive() to eliminate boilerplate code, and use
cpc925_printk instead of printk.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/edac/cpc925_edac.c |   33 +++++++--------------------------
 1 files changed, 7 insertions(+), 26 deletions(-)

diff --git a/drivers/edac/cpc925_edac.c b/drivers/edac/cpc925_edac.c
index df6575f..8e3192a 100644
--- a/drivers/edac/cpc925_edac.c
+++ b/drivers/edac/cpc925_edac.c
@@ -944,6 +944,12 @@ static int cpc925_probe(struct platform_device *pdev)
 
 	edac_dbg(0, "%s platform device found!\n", pdev->name);
 
+	cpc925_printk(KERN_INFO, CPC925_EDAC_REVISION "\n");
+	cpc925_printk(KERN_INFO, "\t(c) 2008 Wind River Systems, Inc\n");
+
+	/* Only support POLL mode so far */
+	edac_op_state = EDAC_OPSTATE_POLL;
+
 	if (!devres_open_group(&pdev->dev, cpc925_probe, GFP_KERNEL)) {
 		res = -ENOMEM;
 		goto out;
@@ -1065,32 +1071,7 @@ static struct platform_driver cpc925_edac_driver = {
 	}
 };
 
-static int __init cpc925_edac_init(void)
-{
-	int ret = 0;
-
-	printk(KERN_INFO "IBM CPC925 EDAC driver " CPC925_EDAC_REVISION "\n");
-	printk(KERN_INFO "\t(c) 2008 Wind River Systems, Inc\n");
-
-	/* Only support POLL mode so far */
-	edac_op_state = EDAC_OPSTATE_POLL;
-
-	ret = platform_driver_register(&cpc925_edac_driver);
-	if (ret) {
-		printk(KERN_WARNING "Failed to register %s\n",
-			CPC925_EDAC_MOD_STR);
-	}
-
-	return ret;
-}
-
-static void __exit cpc925_edac_exit(void)
-{
-	platform_driver_unregister(&cpc925_edac_driver);
-}
-
-module_init(cpc925_edac_init);
-module_exit(cpc925_edac_exit);
+module_platform_driver(cpc925_edac_driver);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Cao Qingtao <qingtao.cao@windriver.com>");
-- 
1.7.1



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

* [PATCH] cpc925_eadc: Use devm_ioremap_resource()
  2014-06-09 14:40 [PATCH] cpc925_edac: Use module_platform_driver() Kefeng Wang
@ 2014-06-10  1:57 ` Kefeng Wang
  2014-07-03 13:22   ` Borislav Petkov
  2014-06-10  2:44 ` [PATCH] cpc925_edac: Use module_platform_driver() Xie XiuQi
  2014-07-03 11:49 ` Borislav Petkov
  2 siblings, 1 reply; 5+ messages in thread
From: Kefeng Wang @ 2014-06-10  1:57 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Johannes Thumshirn, Doug Thompson
  Cc: linux-edac, linux-kernel

Convert to devm_ioremap_resource() to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/edac/cpc925_edac.c |   30 ++++++------------------------
 1 files changed, 6 insertions(+), 24 deletions(-)

diff --git a/drivers/edac/cpc925_edac.c b/drivers/edac/cpc925_edac.c
index df6575f..b335c14 100644
--- a/drivers/edac/cpc925_edac.c
+++ b/drivers/edac/cpc925_edac.c
@@ -950,28 +950,12 @@ static int cpc925_probe(struct platform_device *pdev)
        }

        r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!r) {
-               cpc925_printk(KERN_ERR, "Unable to get resource\n");
-               res = -ENOENT;
+       vbase = devm_ioremap_resource(&pdev->dev, r);
+       if (IS_ERR(vbase)) {
+               res = PTR_ERR(vbase);
                goto err1;
        }

-       if (!devm_request_mem_region(&pdev->dev,
-                                    r->start,
-                                    resource_size(r),
-                                    pdev->name)) {
-               cpc925_printk(KERN_ERR, "Unable to request mem region\n");
-               res = -EBUSY;
-               goto err1;
-       }
-
-       vbase = devm_ioremap(&pdev->dev, r->start, resource_size(r));
-       if (!vbase) {
-               cpc925_printk(KERN_ERR, "Unable to ioremap device\n");
-               res = -ENOMEM;
-               goto err2;
-       }
-
        nr_channels = cpc925_mc_get_channels(vbase) + 1;

        layers[0].type = EDAC_MC_LAYER_CHIP_SELECT;
@@ -985,7 +969,7 @@ static int cpc925_probe(struct platform_device *pdev)
        if (!mci) {
                cpc925_printk(KERN_ERR, "No memory for mem_ctl_info\n");
                res = -ENOMEM;
-               goto err2;
+               goto err1;
        }

        pdata = mci->pvt_info;
@@ -1018,7 +1002,7 @@ static int cpc925_probe(struct platform_device *pdev)

        if (edac_mc_add_mc(mci) > 0) {
                cpc925_mc_printk(mci, KERN_ERR, "Failed edac_mc_add_mc()\n");
-               goto err3;
+               goto err2;
        }

        cpc925_add_edac_devices(vbase);
@@ -1029,11 +1013,9 @@ static int cpc925_probe(struct platform_device *pdev)
        res = 0;
        goto out;

-err3:
+err2:
        cpc925_mc_exit(mci);
        edac_mc_free(mci);
-err2:
-       devm_release_mem_region(&pdev->dev, r->start, resource_size(r));
 err1:
        devres_release_group(&pdev->dev, cpc925_probe);
 out:
-- 
1.7.1


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

* Re: [PATCH] cpc925_edac: Use module_platform_driver()
  2014-06-09 14:40 [PATCH] cpc925_edac: Use module_platform_driver() Kefeng Wang
  2014-06-10  1:57 ` [PATCH] cpc925_eadc: Use devm_ioremap_resource() Kefeng Wang
@ 2014-06-10  2:44 ` Xie XiuQi
  2014-07-03 11:49 ` Borislav Petkov
  2 siblings, 0 replies; 5+ messages in thread
From: Xie XiuQi @ 2014-06-10  2:44 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: Mauro Carvalho Chehab, Johannes Thumshirn, Doug Thompson,
	linux-edac, linux-kernel

On 2014/6/9 22:40, Kefeng Wang wrote:
> Move edac_op_state assignment operations to probe, then convert to
> module_platform_drive() to eliminate boilerplate code, and use

module_platform_driver() ;-)

> cpc925_printk instead of printk.
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>  drivers/edac/cpc925_edac.c |   33 +++++++--------------------------
>  1 files changed, 7 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/edac/cpc925_edac.c b/drivers/edac/cpc925_edac.c
> index df6575f..8e3192a 100644
> --- a/drivers/edac/cpc925_edac.c
> +++ b/drivers/edac/cpc925_edac.c
> @@ -944,6 +944,12 @@ static int cpc925_probe(struct platform_device *pdev)
>  
>  	edac_dbg(0, "%s platform device found!\n", pdev->name);
>  
> +	cpc925_printk(KERN_INFO, CPC925_EDAC_REVISION "\n");
> +	cpc925_printk(KERN_INFO, "\t(c) 2008 Wind River Systems, Inc\n");
> +
> +	/* Only support POLL mode so far */
> +	edac_op_state = EDAC_OPSTATE_POLL;
> +
>  	if (!devres_open_group(&pdev->dev, cpc925_probe, GFP_KERNEL)) {
>  		res = -ENOMEM;
>  		goto out;
> @@ -1065,32 +1071,7 @@ static struct platform_driver cpc925_edac_driver = {
>  	}
>  };
>  
> -static int __init cpc925_edac_init(void)
> -{
> -	int ret = 0;
> -
> -	printk(KERN_INFO "IBM CPC925 EDAC driver " CPC925_EDAC_REVISION "\n");
> -	printk(KERN_INFO "\t(c) 2008 Wind River Systems, Inc\n");
> -
> -	/* Only support POLL mode so far */
> -	edac_op_state = EDAC_OPSTATE_POLL;
> -
> -	ret = platform_driver_register(&cpc925_edac_driver);
> -	if (ret) {
> -		printk(KERN_WARNING "Failed to register %s\n",
> -			CPC925_EDAC_MOD_STR);
> -	}
> -
> -	return ret;
> -}
> -
> -static void __exit cpc925_edac_exit(void)
> -{
> -	platform_driver_unregister(&cpc925_edac_driver);
> -}
> -
> -module_init(cpc925_edac_init);
> -module_exit(cpc925_edac_exit);
> +module_platform_driver(cpc925_edac_driver);
>  
>  MODULE_LICENSE("GPL");
>  MODULE_AUTHOR("Cao Qingtao <qingtao.cao@windriver.com>");
> 



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

* Re: [PATCH] cpc925_edac: Use module_platform_driver()
  2014-06-09 14:40 [PATCH] cpc925_edac: Use module_platform_driver() Kefeng Wang
  2014-06-10  1:57 ` [PATCH] cpc925_eadc: Use devm_ioremap_resource() Kefeng Wang
  2014-06-10  2:44 ` [PATCH] cpc925_edac: Use module_platform_driver() Xie XiuQi
@ 2014-07-03 11:49 ` Borislav Petkov
  2 siblings, 0 replies; 5+ messages in thread
From: Borislav Petkov @ 2014-07-03 11:49 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: Mauro Carvalho Chehab, Johannes Thumshirn, Doug Thompson,
	linux-edac, linux-kernel

On Mon, Jun 09, 2014 at 10:40:18PM +0800, Kefeng Wang wrote:
> Move edac_op_state assignment operations to probe, then convert to
> module_platform_drive() to eliminate boilerplate code, and use
> cpc925_printk instead of printk.
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>  drivers/edac/cpc925_edac.c |   33 +++++++--------------------------
>  1 files changed, 7 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/edac/cpc925_edac.c b/drivers/edac/cpc925_edac.c
> index df6575f..8e3192a 100644
> --- a/drivers/edac/cpc925_edac.c
> +++ b/drivers/edac/cpc925_edac.c
> @@ -944,6 +944,12 @@ static int cpc925_probe(struct platform_device *pdev)
>  
>  	edac_dbg(0, "%s platform device found!\n", pdev->name);
>  
> +	cpc925_printk(KERN_INFO, CPC925_EDAC_REVISION "\n");
> +	cpc925_printk(KERN_INFO, "\t(c) 2008 Wind River Systems, Inc\n");

This will issue multiple times on a multi-node machine with several such
bridges.

The bit converting to cpc925_printk is ok and I'll take it if you create
a patch only for it.

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

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

* Re: [PATCH] cpc925_eadc: Use devm_ioremap_resource()
  2014-06-10  1:57 ` [PATCH] cpc925_eadc: Use devm_ioremap_resource() Kefeng Wang
@ 2014-07-03 13:22   ` Borislav Petkov
  0 siblings, 0 replies; 5+ messages in thread
From: Borislav Petkov @ 2014-07-03 13:22 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: Mauro Carvalho Chehab, Johannes Thumshirn, Doug Thompson,
	linux-edac, linux-kernel

On Tue, Jun 10, 2014 at 09:57:56AM +0800, Kefeng Wang wrote:
> Convert to devm_ioremap_resource() to simplify code.
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>  drivers/edac/cpc925_edac.c |   30 ++++++------------------------
>  1 files changed, 6 insertions(+), 24 deletions(-)

Has this one been tested on the actual hardware?

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

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

end of thread, other threads:[~2014-07-03 13:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-09 14:40 [PATCH] cpc925_edac: Use module_platform_driver() Kefeng Wang
2014-06-10  1:57 ` [PATCH] cpc925_eadc: Use devm_ioremap_resource() Kefeng Wang
2014-07-03 13:22   ` Borislav Petkov
2014-06-10  2:44 ` [PATCH] cpc925_edac: Use module_platform_driver() Xie XiuQi
2014-07-03 11:49 ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox