mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Armin Wolf <W_Armin@gmx.de>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	Linux ACPI <linux-acpi@vger.kernel.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Daniel Lezcano <daniel.lezcano@kernel.org>,
	Hans de Goede <hansg@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	Lukasz Luba <lukasz.luba@arm.com>
Subject: Re: [PATCH v1 05/10] ACPI: video: Use thermal_cooling_device_create()
Date: Fri, 11 Sep 2026 23:16:05 +0200	[thread overview]
Message-ID: <346b9665-c034-49d4-a6fe-7c27b05e84e8@gmx.de> (raw)
In-Reply-To: <23237491.EfDdHjke4D@rafael.j.wysocki>

Am 11.09.26 um 15:03 schrieb Rafael J. Wysocki:

> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
>
> Instead of using thermal_cooling_device_register() for registering a
> backlight cooling device in the ACPI video bus driver, make it use
> thermal_cooling_device_create() and pass a pointer to the LCD device
> to that function as the cooling class device's parent.  That will
> cause the cooling device's sysfs directory to be created under
> the parent's sysfs directory (among other things).
>
> Since creating a class device under a parent causes a "device" symbolic
> link from the sysfs directory of the class device to the sysfs directory
> of the parent to appear automatically, remove the code creating the
> "device" symbolic link from the sysfs directory of the cooling device
> in question to the sysfs directory of the parent's ACPI companion
> device.  That companion device is reachable through the "firmware_node"
> symbolic link in the parent's sysfs directory regardless.
>
> Moreover, since the cooling class device is now located in sysfs under
> its parent and it can be easily identified as a cooling device, there is
> no need to create a "thermal_cooling" symbolic link from its parent's
> ACPI companion to it.  Accordingly, also remove the code creating that
> symbolic link.

Reviewed-by: Armin Wolf <W_Armin@gmx.de>

> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>   drivers/acpi/acpi_video.c | 35 ++++++++++++++++-------------------
>   1 file changed, 16 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
> index 6cfe390411c1..2a2822516665 100644
> --- a/drivers/acpi/acpi_video.c
> +++ b/drivers/acpi/acpi_video.c
> @@ -1700,9 +1700,9 @@ static int acpi_video_resume(struct notifier_block *nb,
>   
>   static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
>   {
> +	struct device *phys_dev, *parent = NULL;
>   	struct backlight_properties props;
>   	struct pci_dev *pdev;
> -	struct device *parent = NULL;
>   	int result;
>   	static int count;
>   	char *name;
> @@ -1729,11 +1729,10 @@ static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
>   						      device,
>   						      &acpi_backlight_ops,
>   						      &props);
> -	put_device(parent);
>   	kfree(name);
>   	if (IS_ERR(device->backlight)) {
>   		device->backlight = NULL;
> -		return;
> +		goto put_parent;
>   	}
>   
>   	/*
> @@ -1743,8 +1742,12 @@ static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
>   	device->backlight->props.brightness =
>   			acpi_video_get_brightness(device->backlight);
>   
> -	device->cooling_dev = thermal_cooling_device_register("LCD", device,
> -							      &video_cooling_ops);
> +	phys_dev = acpi_bus_get_primary_device(device->dev);
> +	if (!phys_dev)
> +		phys_dev = get_device(parent);
> +
> +	device->cooling_dev = thermal_cooling_device_create(phys_dev, "LCD", device,
> +							    &video_cooling_ops);
>   	if (IS_ERR(device->cooling_dev)) {
>   		/*
>   		 * Set cooling_dev to NULL so we don't crash trying to free it.
> @@ -1753,21 +1756,17 @@ static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
>   		 * -- dtor
>   		 */
>   		device->cooling_dev = NULL;
> -		return;
> +		goto put_phys_dev;
>   	}
>   
> -	dev_info(&device->dev->dev, "registered as cooling_device%d\n",
> -		 device->cooling_dev->id);
> -	result = sysfs_create_link(&device->dev->dev.kobj,
> -			&device->cooling_dev->device.kobj,
> -			"thermal_cooling");
> -	if (result)
> -		pr_info("sysfs link creation failed\n");
> +	dev_info(&device->cooling_dev->device, "Using ACPI device %s\n",
> +		acpi_dev_name(device->dev));
>   
> -	result = sysfs_create_link(&device->cooling_dev->device.kobj,
> -			&device->dev->dev.kobj, "device");
> -	if (result)
> -		pr_info("Reverse sysfs link creation failed\n");
> +put_phys_dev:
> +	put_device(phys_dev);
> +
> +put_parent:
> +	put_device(parent);
>   }
>   
>   static void acpi_video_run_bcl_for_osi(struct acpi_video_bus *video)
> @@ -1826,8 +1825,6 @@ static int acpi_video_bus_register_backlight(struct acpi_video_bus *video)
>   static void acpi_video_dev_unregister_backlight(struct acpi_video_device *device)
>   {
>   	if (device->cooling_dev) {
> -		sysfs_remove_link(&device->dev->dev.kobj, "thermal_cooling");
> -		sysfs_remove_link(&device->cooling_dev->device.kobj, "device");
>   		thermal_cooling_device_unregister(device->cooling_dev);
>   		device->cooling_dev = NULL;
>   	}

  reply	other threads:[~2026-09-11 21:16 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11 13:00 [PATCH v1 00/10] ACPI: thermal: Register thermal class cooling devices under parents Rafael J. Wysocki
2026-09-11 13:00 ` [PATCH v1 01/10] ACPI: fan: Fix memory leak due to leftover devm_kcalloc() argument Rafael J. Wysocki
2026-09-11 16:29   ` Andy Shevchenko
2026-09-12 13:48     ` Rafael J. Wysocki (Intel)
2026-09-11 21:01   ` Armin Wolf
2026-09-11 13:01 ` [PATCH v1 02/10] ACPI: video: Fix backlight unregistration ordering Rafael J. Wysocki
2026-09-11 16:27   ` Andy Shevchenko
2026-09-11 16:35     ` Rafael J. Wysocki (Intel)
2026-09-11 21:02   ` Armin Wolf
2026-09-11 13:02 ` [PATCH v1 03/10] thermal: core: Introduce thermal_cooling_device_create() Rafael J. Wysocki
2026-09-11 21:04   ` Armin Wolf
2026-09-14 10:18     ` Rafael J. Wysocki (Intel)
2026-09-15 19:25       ` Armin Wolf
2026-09-11 13:02 ` [PATCH v1 04/10] ACPI: processor: thermal: Use thermal_cooling_device_create() Rafael J. Wysocki
2026-09-11 16:32   ` Andy Shevchenko
2026-09-11 16:36     ` Rafael J. Wysocki (Intel)
2026-09-11 16:46       ` Andy Shevchenko
2026-09-11 17:01         ` Rafael J. Wysocki (Intel)
2026-09-11 18:06           ` Andy Shevchenko
2026-09-11 21:14             ` Armin Wolf
2026-09-13  8:15               ` Andy Shevchenko
2026-09-13 10:28                 ` Rafael J. Wysocki (Intel)
2026-09-14  4:35                   ` Andy Shevchenko
2026-09-11 21:11   ` Armin Wolf
2026-09-11 13:03 ` [PATCH v1 05/10] ACPI: video: " Rafael J. Wysocki
2026-09-11 21:16   ` Armin Wolf [this message]
2026-09-11 13:04 ` [PATCH v1 06/10] ACPI: fan: " Rafael J. Wysocki
2026-09-11 21:17   ` Armin Wolf
2026-09-11 13:05 ` [PATCH v1 07/10] ACPI: thermal: Use cooling device parent for thermal zone binding Rafael J. Wysocki
2026-09-11 16:36   ` Andy Shevchenko
2026-09-11 16:41     ` Rafael J. Wysocki (Intel)
2026-09-11 21:20   ` Armin Wolf
2026-09-11 13:05 ` [PATCH v1 08/10] ACPI: processor: thermal: Use more suitable cooling device data Rafael J. Wysocki
2026-09-11 21:22   ` Armin Wolf
2026-09-11 13:06 ` [PATCH v1 09/10] ACPI: fan: Store ACPI device pointer in struct acpi_fan Rafael J. Wysocki
2026-09-11 21:25   ` Armin Wolf
2026-09-11 13:07 ` [PATCH v1 10/10] ACPI: fan: Use more suitable cooling device data Rafael J. Wysocki
2026-09-11 21:26   ` Armin Wolf
2026-09-11 21:35 ` [PATCH v1 00/10] ACPI: thermal: Register thermal class cooling devices under parents Armin Wolf
2026-09-12 13:34   ` Rafael J. Wysocki (Intel)
2026-09-15 19:20     ` Armin Wolf

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=346b9665-c034-49d4-a6fe-7c27b05e84e8@gmx.de \
    --to=w_armin@gmx.de \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=daniel.lezcano@kernel.org \
    --cc=hansg@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=rafael@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®