diff mbox series

[05/10] platform/x86: toshiba_acpi: register backlight with device-managed variant

Message ID 20210324125548.45983-6-aardelean@deviqon.com (mailing list archive)
State New
Headers show
Series platform/x86: toshiba_acpi: move acpi add/remove to device-managed routines | expand

Commit Message

Alexandru Ardelean March 24, 2021, 12:55 p.m. UTC
This change converts the registration of the backlight data with the
devm_backlight_device_register() function.
This way, the backlight_device_unregister() call is no longer required, and
the order of deregistration is made to be more symmetrical with the
registration order.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
---
 drivers/platform/x86/toshiba_acpi.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

Comments

Jonathan Cameron March 29, 2021, 2:50 p.m. UTC | #1
On Wed, 24 Mar 2021 14:55:43 +0200
Alexandru Ardelean <aardelean@deviqon.com> wrote:

> This change converts the registration of the backlight data with the
> devm_backlight_device_register() function.
> This way, the backlight_device_unregister() call is no longer required, and
> the order of deregistration is made to be more symmetrical with the
> registration order.
> 

This one looks fine to me.

> Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/platform/x86/toshiba_acpi.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
> index 556f2cc99bad..ada2a2d8c913 100644
> --- a/drivers/platform/x86/toshiba_acpi.c
> +++ b/drivers/platform/x86/toshiba_acpi.c
> @@ -2876,7 +2876,8 @@ static int toshiba_acpi_setup_keyboard(struct device *parent,
>  	return error;
>  }
>  
> -static int toshiba_acpi_setup_backlight(struct toshiba_acpi_dev *dev)
> +static int toshiba_acpi_setup_backlight(struct device *parent,
> +					struct toshiba_acpi_dev *dev)
>  {
>  	struct backlight_properties props;
>  	int brightness;
> @@ -2924,11 +2925,12 @@ static int toshiba_acpi_setup_backlight(struct toshiba_acpi_dev *dev)
>  	if (dev->tr_backlight_supported)
>  		props.max_brightness++;
>  
> -	dev->backlight_dev = backlight_device_register("toshiba",
> -						       &dev->acpi_dev->dev,
> -						       dev,
> -						       &toshiba_backlight_data,
> -						       &props);
> +	dev->backlight_dev = devm_backlight_device_register(parent,
> +							    "toshiba",
> +							    &dev->acpi_dev->dev,
> +							    dev,
> +							    &toshiba_backlight_data,
> +							    &props);
>  	if (IS_ERR(dev->backlight_dev)) {
>  		ret = PTR_ERR(dev->backlight_dev);
>  		pr_err("Could not register toshiba backlight device\n");
> @@ -2999,8 +3001,6 @@ static int toshiba_acpi_remove(struct acpi_device *acpi_dev)
>  		sysfs_remove_group(&dev->acpi_dev->dev.kobj,
>  				   &toshiba_attr_group);
>  
> -	backlight_device_unregister(dev->backlight_dev);
> -
>  	led_classdev_unregister(&dev->led_dev);
>  	led_classdev_unregister(&dev->kbd_led);
>  	led_classdev_unregister(&dev->eco_led);
> @@ -3104,9 +3104,9 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
>  	ret = get_tr_backlight_status(dev, &dummy);
>  	dev->tr_backlight_supported = !ret;
>  
> -	ret = toshiba_acpi_setup_backlight(dev);
> +	ret = toshiba_acpi_setup_backlight(parent, dev);
>  	if (ret)
> -		goto error;
> +		return ret;
>  
>  	toshiba_illumination_available(dev);
>  	if (dev->illumination_supported) {
diff mbox series

Patch

diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 556f2cc99bad..ada2a2d8c913 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -2876,7 +2876,8 @@  static int toshiba_acpi_setup_keyboard(struct device *parent,
 	return error;
 }
 
-static int toshiba_acpi_setup_backlight(struct toshiba_acpi_dev *dev)
+static int toshiba_acpi_setup_backlight(struct device *parent,
+					struct toshiba_acpi_dev *dev)
 {
 	struct backlight_properties props;
 	int brightness;
@@ -2924,11 +2925,12 @@  static int toshiba_acpi_setup_backlight(struct toshiba_acpi_dev *dev)
 	if (dev->tr_backlight_supported)
 		props.max_brightness++;
 
-	dev->backlight_dev = backlight_device_register("toshiba",
-						       &dev->acpi_dev->dev,
-						       dev,
-						       &toshiba_backlight_data,
-						       &props);
+	dev->backlight_dev = devm_backlight_device_register(parent,
+							    "toshiba",
+							    &dev->acpi_dev->dev,
+							    dev,
+							    &toshiba_backlight_data,
+							    &props);
 	if (IS_ERR(dev->backlight_dev)) {
 		ret = PTR_ERR(dev->backlight_dev);
 		pr_err("Could not register toshiba backlight device\n");
@@ -2999,8 +3001,6 @@  static int toshiba_acpi_remove(struct acpi_device *acpi_dev)
 		sysfs_remove_group(&dev->acpi_dev->dev.kobj,
 				   &toshiba_attr_group);
 
-	backlight_device_unregister(dev->backlight_dev);
-
 	led_classdev_unregister(&dev->led_dev);
 	led_classdev_unregister(&dev->kbd_led);
 	led_classdev_unregister(&dev->eco_led);
@@ -3104,9 +3104,9 @@  static int toshiba_acpi_add(struct acpi_device *acpi_dev)
 	ret = get_tr_backlight_status(dev, &dummy);
 	dev->tr_backlight_supported = !ret;
 
-	ret = toshiba_acpi_setup_backlight(dev);
+	ret = toshiba_acpi_setup_backlight(parent, dev);
 	if (ret)
-		goto error;
+		return ret;
 
 	toshiba_illumination_available(dev);
 	if (dev->illumination_supported) {