[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP245DVMJ59nBSwpsW5CTm5hiCNBrtUSxE0qwg9=B9TYv9c26Q@mail.gmail.com>
Date: Tue, 30 Jun 2020 17:24:31 +0530
From: Amit Kucheria <amit.kucheria@...aro.org>
To: Daniel Lezcano <daniel.lezcano@...aro.org>
Cc: Zhang Rui <rui.zhang@...el.com>,
Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
Ram Chandrasekar <rkumbako@...eaurora.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 2/5] thermal: core: Get thermal zone by id
On Thu, Jun 25, 2020 at 8:15 PM Daniel Lezcano
<daniel.lezcano@...aro.org> wrote:
>
> The next patch will introduce the generic netlink protocol to handle
> events, sampling and command from the thermal framework. In order to
> deal with the thermal zone, it uses its unique identifier to
> characterize it in the message. Passing an integer is more efficient
> than passing an entire string.
>
> This change provides a function returning back a thermal zone pointer
> corresponding to the identifier passed as parameter.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@...aro.org>
Reviewed-by: Amit Kucheria <amit.kucheria@...aro.org>
> ---
> drivers/thermal/thermal_core.c | 14 ++++++++++++++
> drivers/thermal/thermal_core.h | 2 ++
> 2 files changed, 16 insertions(+)
>
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index e2f8d2550ecd..58c95aeafb7f 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -662,6 +662,20 @@ int for_each_thermal_zone(int (*cb)(struct thermal_zone_device *, void *),
> return ret;
> }
>
> +struct thermal_zone_device *thermal_zone_get_by_id(int id)
> +{
> + struct thermal_zone_device *tz = NULL;
> +
> + mutex_lock(&thermal_list_lock);
> + list_for_each_entry(tz, &thermal_tz_list, node) {
> + if (tz->id == id)
> + break;
> + }
> + mutex_unlock(&thermal_list_lock);
> +
> + return tz;
> +}
> +
> void thermal_zone_device_unbind_exception(struct thermal_zone_device *tz,
> const char *cdev_type, size_t size)
> {
> diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
> index bb8f8aee79eb..7e8f45db6bbf 100644
> --- a/drivers/thermal/thermal_core.h
> +++ b/drivers/thermal/thermal_core.h
> @@ -50,6 +50,8 @@ int for_each_thermal_cooling_device(int (*cb)(struct thermal_cooling_device *,
> int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *),
> void *thermal_governor);
>
> +struct thermal_zone_device *thermal_zone_get_by_id(int id);
> +
> struct thermal_attr {
> struct device_attribute attr;
> char name[THERMAL_NAME_LENGTH];
> --
> 2.17.1
>
Powered by blists - more mailing lists