All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandru Ardelean <aardelean@deviqon.com>
To: platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org
Cc: coproscefalo@gmail.com, hdegoede@redhat.com,
	mgross@linux.intel.com, jic23@kernel.org, linux@deviqon.com,
	Alexandru Ardelean <aardelean@deviqon.com>
Subject: [PATCH 06/10] platform/x86: toshiba_acpi: use devm_led_classdev_register() for LEDs
Date: Wed, 24 Mar 2021 14:55:44 +0200	[thread overview]
Message-ID: <20210324125548.45983-7-aardelean@deviqon.com> (raw)
In-Reply-To: <20210324125548.45983-1-aardelean@deviqon.com>

With this change the deregistration of the LED objects is made symmetrical
(and in reverse) with the registration. We also can get rid of the calls
to led_classdev_unregister(), because the LED objects will be cleaned up
when the reference to the parent device object goes to zero.

This change also unifies the reference to the parent object from
'&acpi_dev->dev' and '&dev->acpi_dev->dev' to 'parent', since it's the same
reference, and makes the code-lines a bit shorter.

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

diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index ada2a2d8c913..e787c140eec2 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -3001,10 +3001,6 @@ static int toshiba_acpi_remove(struct acpi_device *acpi_dev)
 		sysfs_remove_group(&dev->acpi_dev->dev.kobj,
 				   &toshiba_attr_group);
 
-	led_classdev_unregister(&dev->led_dev);
-	led_classdev_unregister(&dev->kbd_led);
-	led_classdev_unregister(&dev->eco_led);
-
 	if (dev->wwan_rfk) {
 		rfkill_unregister(dev->wwan_rfk);
 		rfkill_destroy(dev->wwan_rfk);
@@ -3114,7 +3110,9 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
 		dev->led_dev.max_brightness = 1;
 		dev->led_dev.brightness_set = toshiba_illumination_set;
 		dev->led_dev.brightness_get = toshiba_illumination_get;
-		led_classdev_register(&acpi_dev->dev, &dev->led_dev);
+		ret = devm_led_classdev_register(parent, &dev->led_dev);
+		if (ret)
+			return ret;
 	}
 
 	toshiba_eco_mode_available(dev);
@@ -3123,7 +3121,9 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
 		dev->eco_led.max_brightness = 1;
 		dev->eco_led.brightness_set = toshiba_eco_mode_set_status;
 		dev->eco_led.brightness_get = toshiba_eco_mode_get_status;
-		led_classdev_register(&dev->acpi_dev->dev, &dev->eco_led);
+		ret = devm_led_classdev_register(parent, &dev->eco_led);
+		if (ret)
+			return ret;
 	}
 
 	toshiba_kbd_illum_available(dev);
@@ -3139,7 +3139,9 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
 		dev->kbd_led.max_brightness = 1;
 		dev->kbd_led.brightness_set = toshiba_kbd_backlight_set;
 		dev->kbd_led.brightness_get = toshiba_kbd_backlight_get;
-		led_classdev_register(&dev->acpi_dev->dev, &dev->kbd_led);
+		ret = devm_led_classdev_register(parent, &dev->kbd_led);
+		if (ret)
+			return ret;
 	}
 
 	ret = toshiba_touchpad_get(dev, &dummy);
-- 
2.30.2


  parent reply	other threads:[~2021-03-24 12:57 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-24 12:55 [PATCH 00/10] platform/x86: toshiba_acpi: move acpi add/remove to device-managed routines Alexandru Ardelean
2021-03-24 12:55 ` [PATCH 01/10] platform/x86: toshiba_acpi: bind life-time of toshiba_acpi_dev to parent Alexandru Ardelean
2021-03-29 14:30   ` Jonathan Cameron
2021-03-30  6:49     ` Alexandru Ardelean
2021-03-24 12:55 ` [PATCH 02/10] platform/x86: toshiba_acpi: use devm_add_action_or_reset() for singleton clear Alexandru Ardelean
2021-03-29 14:27   ` Jonathan Cameron
2021-03-24 12:55 ` [PATCH 03/10] platform/x86: toshiba_acpi: bind registration of miscdev object to parent Alexandru Ardelean
2021-03-29 14:33   ` Jonathan Cameron
2021-03-24 12:55 ` [PATCH 04/10] platform/x86: toshiba_acpi: use device-managed functions for input device Alexandru Ardelean
2021-03-29 14:48   ` Jonathan Cameron
2021-03-24 12:55 ` [PATCH 05/10] platform/x86: toshiba_acpi: register backlight with device-managed variant Alexandru Ardelean
2021-03-29 14:50   ` Jonathan Cameron
2021-03-24 12:55 ` Alexandru Ardelean [this message]
2021-03-29 14:52   ` [PATCH 06/10] platform/x86: toshiba_acpi: use devm_led_classdev_register() for LEDs Jonathan Cameron
2021-03-24 12:55 ` [PATCH 07/10] platform/x86: toshiba_acpi: use device-managed functions for accelerometer Alexandru Ardelean
2021-03-29 14:54   ` Jonathan Cameron
2021-03-24 12:55 ` [PATCH 08/10] platform/x86: toshiba_acpi: use device-managed for wwan_rfkill management Alexandru Ardelean
2021-03-29 14:57   ` Jonathan Cameron
2021-03-24 12:55 ` [PATCH 09/10] platform/x86: toshiba_acpi: use device-managed for sysfs removal Alexandru Ardelean
2021-03-29 15:09   ` Jonathan Cameron
2021-03-24 12:55 ` [PATCH 10/10] platform/x86: toshiba_acpi: bind proc entries creation to parent Alexandru Ardelean
2021-03-29 15:10   ` Jonathan Cameron
2021-03-29 12:38 ` [PATCH 00/10] platform/x86: toshiba_acpi: move acpi add/remove to device-managed routines Jonathan Cameron
2021-03-29 14:01   ` Alexandru Ardelean
2021-03-30  8:20 ` Hans de Goede
2021-03-30  9:22   ` Alexandru Ardelean
2021-03-30  9:27     ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210324125548.45983-7-aardelean@deviqon.com \
    --to=aardelean@deviqon.com \
    --cc=coproscefalo@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@deviqon.com \
    --cc=mgross@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.