Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1281988 > unrolled thread

[PATCH] leds: sunfire: Use platform_register/unregister_drivers()

Started byThierry Reding <thierry.reding@gmail.com>
First post2015-12-02 17:30 +0100
Last post2015-12-03 11:50 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] leds: sunfire: Use platform_register/unregister_drivers() Thierry Reding <thierry.reding@gmail.com> - 2015-12-02 17:30 +0100
    Re: [PATCH] leds: sunfire: Use platform_register/unregister_drivers() Jacek Anaszewski <j.anaszewski@samsung.com> - 2015-12-03 11:50 +0100

#1281988 — [PATCH] leds: sunfire: Use platform_register/unregister_drivers()

FromThierry Reding <thierry.reding@gmail.com>
Date2015-12-02 17:30 +0100
Subject[PATCH] leds: sunfire: Use platform_register/unregister_drivers()
Message-ID<qBis7-19N-49@gated-at.bofh.it>
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/leds/leds-sunfire.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/drivers/leds/leds-sunfire.c b/drivers/leds/leds-sunfire.c
index c2553c54f2cf..7c09db8bd4e8 100644
--- a/drivers/leds/leds-sunfire.c
+++ b/drivers/leds/leds-sunfire.c
@@ -234,28 +234,19 @@ static struct platform_driver sunfire_fhc_led_driver = {
 	},
 };
 
+static struct platform_driver * const drivers[] = {
+	&sunfire_clockboard_led_driver,
+	&sunfire_fhc_led_driver,
+};
+
 static int __init sunfire_leds_init(void)
 {
-	int err = platform_driver_register(&sunfire_clockboard_led_driver);
-
-	if (err) {
-		pr_err("Could not register clock board LED driver\n");
-		return err;
-	}
-
-	err = platform_driver_register(&sunfire_fhc_led_driver);
-	if (err) {
-		pr_err("Could not register FHC LED driver\n");
-		platform_driver_unregister(&sunfire_clockboard_led_driver);
-	}
-
-	return err;
+	return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 static void __exit sunfire_leds_exit(void)
 {
-	platform_driver_unregister(&sunfire_clockboard_led_driver);
-	platform_driver_unregister(&sunfire_fhc_led_driver);
+	platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 module_init(sunfire_leds_init);
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1282933

FromJacek Anaszewski <j.anaszewski@samsung.com>
Date2015-12-03 11:50 +0100
Message-ID<qBzCz-3N9-29@gated-at.bofh.it>
In reply to#1281988
On 12/02/2015 05:27 PM, 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/leds/leds-sunfire.c | 23 +++++++----------------
>   1 file changed, 7 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/leds/leds-sunfire.c b/drivers/leds/leds-sunfire.c
> index c2553c54f2cf..7c09db8bd4e8 100644
> --- a/drivers/leds/leds-sunfire.c
> +++ b/drivers/leds/leds-sunfire.c
> @@ -234,28 +234,19 @@ static struct platform_driver sunfire_fhc_led_driver = {
>   	},
>   };
>
> +static struct platform_driver * const drivers[] = {
> +	&sunfire_clockboard_led_driver,
> +	&sunfire_fhc_led_driver,
> +};
> +
>   static int __init sunfire_leds_init(void)
>   {
> -	int err = platform_driver_register(&sunfire_clockboard_led_driver);
> -
> -	if (err) {
> -		pr_err("Could not register clock board LED driver\n");
> -		return err;
> -	}
> -
> -	err = platform_driver_register(&sunfire_fhc_led_driver);
> -	if (err) {
> -		pr_err("Could not register FHC LED driver\n");
> -		platform_driver_unregister(&sunfire_clockboard_led_driver);
> -	}
> -
> -	return err;
> +	return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
>   }
>
>   static void __exit sunfire_leds_exit(void)
>   {
> -	platform_driver_unregister(&sunfire_clockboard_led_driver);
> -	platform_driver_unregister(&sunfire_fhc_led_driver);
> +	platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
>   }
>
>   module_init(sunfire_leds_init);
>

Applied, thanks.

-- 
Best Regards,
Jacek Anaszewski
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web