Linux Power Management development
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
To: Lukasz Luba <lukasz.luba@arm.com>
Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, rafael@kernel.org
Subject: Re: [PATCH] thermal/core: Split __thermal_cooling_device_register() into two functions
Date: Fri, 8 May 2026 13:25:47 +0200	[thread overview]
Message-ID: <b120e546-2a41-4efd-b0c6-8a63eb5bbd93@oss.qualcomm.com> (raw)
In-Reply-To: <70f2b2b4-6066-4c48-8834-b907b5146a08@arm.com>

On 5/8/26 12:35, Lukasz Luba wrote:
> 
> 
> On 5/7/26 19:26, Daniel Lezcano wrote:
>> On 5/7/26 12:02, Lukasz Luba wrote:

[ ... ]

> I would call them explicitly in case of 'if(ret)'
> error from dev_set_name()...
> Then the rest could end in case of error with that new
> 'put_device()' logic at the bottom.
> Would you agree?
> 
> A different option would be to refactor thermal_release()
> and somehow recognize the cooling device not based on name.

This mechanism is not adequate.

thermal_release should not be used this way, neither it should be needed.

We should have:

	thermal_class = class_create("thermal");
	if (IS_ERR(thermal_class))
		...

No thermal_release needed.


But,

static void cooling_dev_release(struct device *dev)
{
	thermal_cooling_device *cdev;

	cdev = to_cooling_device(dev);
	thermal_cooling_device_destroy_sysfs(cdev);
	kfree_const(cdev->type);
	ida_free(&thermal_cdev_ida, cdev->id);
	kfree(cdev);
}

static void tz_dev_release(struct device *dev)
{
	thermal_zone_device *tz;

	tz = to_thermal_zone(dev);
	thermal_zone_destroy_device_groups(tz);
	thermal_set_governor(tz, NULL);
	ida_destroy(&tz->ida);
	mutex_destroy(&tz->lock);
	complete(&tz->removal);
}

In thermal_cooling_device_add()
{
	...
	cdev->device.release = cooling_dev_release
	...
}


In thermal_zone_device_register_with_trips()
{
	...
	tz->device.release = tz_dev_release
	...
}


  reply	other threads:[~2026-05-08 11:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-05 14:44 [PATCH] thermal/core: Split __thermal_cooling_device_register() into two functions Daniel Lezcano
2026-05-07  8:29 ` Daniel Lezcano
2026-05-07 10:02 ` Lukasz Luba
2026-05-07 18:26   ` Daniel Lezcano
2026-05-08 10:35     ` Lukasz Luba
2026-05-08 11:25       ` Daniel Lezcano [this message]
2026-05-08 12:08         ` Rafael J. Wysocki
2026-05-08 12:40           ` Daniel Lezcano

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=b120e546-2a41-4efd-b0c6-8a63eb5bbd93@oss.qualcomm.com \
    --to=daniel.lezcano@oss.qualcomm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    /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