linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] edac: mpc52xx: Use platform_register/unregister_drivers()
@ 2015-12-02 16:18 Thierry Reding
  2015-12-02 16:18 ` [PATCH 2/2] edac: mv64x60: " Thierry Reding
  2015-12-02 19:09 ` [PATCH 1/2] edac: mpc52xx: " Johannes Thumshirn
  0 siblings, 2 replies; 4+ messages in thread
From: Thierry Reding @ 2015-12-02 16:18 UTC (permalink / raw)
  To: Johannes Thumshirn, Doug Thompson, Borislav Petkov,
	Mauro Carvalho Chehab
  Cc: linux-edac, linux-kernel

From: Thierry Reding <treding@nvidia.com>

These new helpers simplify implementing multi-driver modules and
properly handle failure to register one driver by unregistering all
previously registered drivers.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/edac/mpc85xx_edac.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
index 23ef8e9f2c9a..3eab06351089 100644
--- a/drivers/edac/mpc85xx_edac.c
+++ b/drivers/edac/mpc85xx_edac.c
@@ -1208,6 +1208,11 @@ static void __init mpc85xx_mc_clear_rfxe(void *data)
 }
 #endif
 
+static struct platform_driver * const drivers[] = {
+	&mpc85xx_mc_err_driver,
+	&mpc85xx_l2_err_driver,
+};
+
 static int __init mpc85xx_mc_init(void)
 {
 	int res = 0;
@@ -1226,13 +1231,9 @@ static int __init mpc85xx_mc_init(void)
 		break;
 	}
 
-	res = platform_driver_register(&mpc85xx_mc_err_driver);
-	if (res)
-		printk(KERN_WARNING EDAC_MOD_STR "MC fails to register\n");
-
-	res = platform_driver_register(&mpc85xx_l2_err_driver);
+	res = platform_register_drivers(drivers, ARRAY_SIZE(drivers));
 	if (res)
-		printk(KERN_WARNING EDAC_MOD_STR "L2 fails to register\n");
+		printk(KERN_WARNING EDAC_MOD_STR "drivers fail to register\n");
 
 #ifdef CONFIG_FSL_SOC_BOOKE
 	pvr = mfspr(SPRN_PVR);
@@ -1270,8 +1271,7 @@ static void __exit mpc85xx_mc_exit(void)
 		on_each_cpu(mpc85xx_mc_restore_hid1, NULL, 0);
 	}
 #endif
-	platform_driver_unregister(&mpc85xx_l2_err_driver);
-	platform_driver_unregister(&mpc85xx_mc_err_driver);
+	platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 module_exit(mpc85xx_mc_exit);
-- 
2.5.0


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

* [PATCH 2/2] edac: mv64x60: Use platform_register/unregister_drivers()
  2015-12-02 16:18 [PATCH 1/2] edac: mpc52xx: Use platform_register/unregister_drivers() Thierry Reding
@ 2015-12-02 16:18 ` Thierry Reding
  2015-12-03 11:06   ` Borislav Petkov
  2015-12-02 19:09 ` [PATCH 1/2] edac: mpc52xx: " Johannes Thumshirn
  1 sibling, 1 reply; 4+ messages in thread
From: Thierry Reding @ 2015-12-02 16:18 UTC (permalink / raw)
  To: Johannes Thumshirn, Doug Thompson, Borislav Petkov,
	Mauro Carvalho Chehab
  Cc: linux-edac, linux-kernel

From: Thierry Reding <treding@nvidia.com>

These new helpers simplify implementing multi-driver modules and
properly handle failure to register one driver by unregistering all
previously registered drivers.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/edac/mv64x60_edac.c | 39 +++++++++++----------------------------
 1 file changed, 11 insertions(+), 28 deletions(-)

diff --git a/drivers/edac/mv64x60_edac.c b/drivers/edac/mv64x60_edac.c
index 0574e1bbe45c..6c54127e6eae 100644
--- a/drivers/edac/mv64x60_edac.c
+++ b/drivers/edac/mv64x60_edac.c
@@ -847,6 +847,15 @@ static struct platform_driver mv64x60_mc_err_driver = {
 	}
 };
 
+static struct platform_driver * const drivers[] = {
+	&mv64x60_mc_err_driver,
+	&mv64x60_cpu_err_driver,
+	&mv64x60_sram_err_driver,
+#ifdef CONFIG_PCI
+	&mv64x60_pci_err_driver,
+#endif
+};
+
 static int __init mv64x60_edac_init(void)
 {
 	int ret = 0;
@@ -863,39 +872,13 @@ static int __init mv64x60_edac_init(void)
 		break;
 	}
 
-	ret = platform_driver_register(&mv64x60_mc_err_driver);
-	if (ret)
-		printk(KERN_WARNING EDAC_MOD_STR "MC err failed to register\n");
-
-	ret = platform_driver_register(&mv64x60_cpu_err_driver);
-	if (ret)
-		printk(KERN_WARNING EDAC_MOD_STR
-			"CPU err failed to register\n");
-
-	ret = platform_driver_register(&mv64x60_sram_err_driver);
-	if (ret)
-		printk(KERN_WARNING EDAC_MOD_STR
-			"SRAM err failed to register\n");
-
-#ifdef CONFIG_PCI
-	ret = platform_driver_register(&mv64x60_pci_err_driver);
-	if (ret)
-		printk(KERN_WARNING EDAC_MOD_STR
-			"PCI err failed to register\n");
-#endif
-
-	return ret;
+	return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
 }
 module_init(mv64x60_edac_init);
 
 static void __exit mv64x60_edac_exit(void)
 {
-#ifdef CONFIG_PCI
-	platform_driver_unregister(&mv64x60_pci_err_driver);
-#endif
-	platform_driver_unregister(&mv64x60_sram_err_driver);
-	platform_driver_unregister(&mv64x60_cpu_err_driver);
-	platform_driver_unregister(&mv64x60_mc_err_driver);
+	platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
 }
 module_exit(mv64x60_edac_exit);
 
-- 
2.5.0


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

* Re: [PATCH 1/2] edac: mpc52xx: Use platform_register/unregister_drivers()
  2015-12-02 16:18 [PATCH 1/2] edac: mpc52xx: Use platform_register/unregister_drivers() Thierry Reding
  2015-12-02 16:18 ` [PATCH 2/2] edac: mv64x60: " Thierry Reding
@ 2015-12-02 19:09 ` Johannes Thumshirn
  1 sibling, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2015-12-02 19:09 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Johannes Thumshirn, Doug Thompson, Borislav Petkov,
	Mauro Carvalho Chehab, linux-edac, linux-kernel

The subject is reading mpc52xx instead of mpc85xx but other than that

Reviewed-by: Johannes Thumshirn <jthumshirn@suse>

Zitat von Thierry Reding <thierry.reding@gmail.com>:

> From: Thierry Reding <treding@nvidia.com>
>
> These new helpers simplify implementing multi-driver modules and
> properly handle failure to register one driver by unregistering all
> previously registered drivers.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/edac/mpc85xx_edac.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
> index 23ef8e9f2c9a..3eab06351089 100644
> --- a/drivers/edac/mpc85xx_edac.c
> +++ b/drivers/edac/mpc85xx_edac.c
> @@ -1208,6 +1208,11 @@ static void __init mpc85xx_mc_clear_rfxe(void *data)
>  }
>  #endif
>
> +static struct platform_driver * const drivers[] = {
> +	&mpc85xx_mc_err_driver,
> +	&mpc85xx_l2_err_driver,
> +};
> +
>  static int __init mpc85xx_mc_init(void)
>  {
>  	int res = 0;
> @@ -1226,13 +1231,9 @@ static int __init mpc85xx_mc_init(void)
>  		break;
>  	}
>
> -	res = platform_driver_register(&mpc85xx_mc_err_driver);
> -	if (res)
> -		printk(KERN_WARNING EDAC_MOD_STR "MC fails to register\n");
> -
> -	res = platform_driver_register(&mpc85xx_l2_err_driver);
> +	res = platform_register_drivers(drivers, ARRAY_SIZE(drivers));
>  	if (res)
> -		printk(KERN_WARNING EDAC_MOD_STR "L2 fails to register\n");
> +		printk(KERN_WARNING EDAC_MOD_STR "drivers fail to register\n");
>
>  #ifdef CONFIG_FSL_SOC_BOOKE
>  	pvr = mfspr(SPRN_PVR);
> @@ -1270,8 +1271,7 @@ static void __exit mpc85xx_mc_exit(void)
>  		on_each_cpu(mpc85xx_mc_restore_hid1, NULL, 0);
>  	}
>  #endif
> -	platform_driver_unregister(&mpc85xx_l2_err_driver);
> -	platform_driver_unregister(&mpc85xx_mc_err_driver);
> +	platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
>  }
>
>  module_exit(mpc85xx_mc_exit);
> --
> 2.5.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-edac" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>




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

* Re: [PATCH 2/2] edac: mv64x60: Use platform_register/unregister_drivers()
  2015-12-02 16:18 ` [PATCH 2/2] edac: mv64x60: " Thierry Reding
@ 2015-12-03 11:06   ` Borislav Petkov
  0 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2015-12-03 11:06 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Johannes Thumshirn, Doug Thompson, Mauro Carvalho Chehab,
	linux-edac, linux-kernel

On Wed, Dec 02, 2015 at 05:18:58PM +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> These new helpers simplify implementing multi-driver modules and
> properly handle failure to register one driver by unregistering all
> previously registered drivers.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/edac/mv64x60_edac.c | 39 +++++++++++----------------------------
>  1 file changed, 11 insertions(+), 28 deletions(-)

Applied, thanks.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

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

end of thread, other threads:[~2015-12-03 11:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-02 16:18 [PATCH 1/2] edac: mpc52xx: Use platform_register/unregister_drivers() Thierry Reding
2015-12-02 16:18 ` [PATCH 2/2] edac: mv64x60: " Thierry Reding
2015-12-03 11:06   ` Borislav Petkov
2015-12-02 19:09 ` [PATCH 1/2] edac: mpc52xx: " Johannes Thumshirn

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).