Message ID | 1967710.PYKUYFuaPT@kreacher |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp118408vqr; Fri, 4 Aug 2023 14:50:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEYCbqzeRoCwawp2aT0uu5NIDmWLxbIH2Sdt5aNsA6/84Ei8rP2H9ProO0/kOL6qeof+Tt X-Received: by 2002:a17:907:75f5:b0:997:eae6:9350 with SMTP id jz21-20020a17090775f500b00997eae69350mr2318999ejc.51.1691185809424; Fri, 04 Aug 2023 14:50:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691185809; cv=none; d=google.com; s=arc-20160816; b=DNJAv9kFGBilQxRk/o4a2zJNu5CBKFCPmuV/nAXznXeYr/C59vlALb4SWYpyiigjU4 90y/ydiOKGUHQ7dzvKH5oOk5DWBQ+95dVw8nlIMDMLKebgzVVnsGLjbClBSgzUXKvI04 2bu/pwTqbzq+89/9MWq4C9AB/U8ZUf64VYkNy3/UFptCMXG9DDCM9SCPaYCXty7BbpnN 6hfpOLnlFEcYcqjMzqxCKR9n//+NccKwx1Fcx6Yq3qf5s9dYjsqBdfo5hlUuPKpy7Euf ugMGQEpfVgpI61GyWUmg2ADmQi/B4iq+TKdKzPwZ1/r6GjOA+Eg9+ggfX8SK+QhRm8UV zu0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=QdM/khr6HnLK0AdU6MnTD2VJG7D4tGKXoR/zpyL6EVc=; fh=jABj5v2rHKw019HO9Ag6891M+lPZ6d+O4eAkd8el8mQ=; b=1HpHB3cGnD4zpAbL4r6sO67P+ByBkoE54hCS5lcSgoZvMc+oOo5Csidg3SZBPhhu9d /2lE/oyK6yGQ+PdhQo4+zdQoTYos5LLIWNofWxXvNGv1tQjAMJ66AYe0Ap84EwRWHaNB 2evPizZ5uyJ01w9riHlOeQZrz7t8b2bXurIsQlASAoj0AhwtjCxLM01z9CHxV00QGati IP9VE39S3yjTRNQ/Hoioy3oOidEgmzPi+/GHCcvoRuYOSwKjJPk4bTzvZHoATYm870+y 9ZuoFywjixzxwynYWfTnBcmH1RTnuBuSB2ncmTXZ81sOJsmc/NvtTKF0XteB0VE3TEMj EA4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jt18-20020a170906dfd200b0099c9e68e3b4si963263ejc.325.2023.08.04.14.49.45; Fri, 04 Aug 2023 14:50:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229615AbjHDV03 (ORCPT <rfc822;wenzhi022@gmail.com> + 99 others); Fri, 4 Aug 2023 17:26:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231140AbjHDV0M (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 4 Aug 2023 17:26:12 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AED66E46; Fri, 4 Aug 2023 14:26:10 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.2.0) id cae361074099a2a1; Fri, 4 Aug 2023 23:26:09 +0200 Authentication-Results: v370.home.net.pl; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=rjwysocki.net (client-ip=195.136.19.94; helo=[195.136.19.94]; envelope-from=rjw@rjwysocki.net; receiver=<UNKNOWN>) Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 7A7AB661680; Fri, 4 Aug 2023 23:26:08 +0200 (CEST) From: "Rafael J. Wysocki" <rjw@rjwysocki.net> To: Linux ACPI <linux-acpi@vger.kernel.org>, Daniel Lezcano <daniel.lezcano@linaro.org> Cc: LKML <linux-kernel@vger.kernel.org>, Linux PM <linux-pm@vger.kernel.org>, Michal Wilczynski <michal.wilczynski@intel.com>, Zhang Rui <rui.zhang@intel.com>, Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Subject: [PATCH v4 04/10] thermal: core: Add thermal_zone_update_trip_temp() helper routine Date: Fri, 04 Aug 2023 23:05:40 +0200 Message-ID: <1967710.PYKUYFuaPT@kreacher> In-Reply-To: <4878513.31r3eYUQgx@kreacher> References: <13318886.uLZWGnKmhe@kreacher> <4878513.31r3eYUQgx@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedviedrkeeggdduheelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepjedprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghp thhtohepmhhitghhrghlrdifihhltgiihihnshhkihesihhnthgvlhdrtghomhdprhgtphhtthhopehruhhirdiihhgrnhhgsehinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=7 Fuz1=7 Fuz2=7 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773336851811481558 X-GMAIL-MSGID: 1773336851811481558 |
Series |
ACPI: thermal: Use trip point table to register thermal zones
|
|
Commit Message
Rafael J. Wysocki
Aug. 4, 2023, 9:05 p.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Introduce a helper routine called thermal_zone_update_trip_temp() that can be used to update a trip point's temperature with the help of a pointer to local data associated with that trip point provided by the thermal driver that created it. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> --- New patch in v4. --- drivers/thermal/thermal_trip.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/thermal.h | 4 ++++ 2 files changed, 41 insertions(+)
Comments
On 04/08/2023 23:05, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > Introduce a helper routine called thermal_zone_update_trip_temp() that > can be used to update a trip point's temperature with the help of a > pointer to local data associated with that trip point provided by > the thermal driver that created it. > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > > New patch in v4. > > --- > drivers/thermal/thermal_trip.c | 37 +++++++++++++++++++++++++++++++++++++ > include/linux/thermal.h | 4 ++++ > 2 files changed, 41 insertions(+) > > Index: linux-pm/drivers/thermal/thermal_trip.c > =================================================================== > --- linux-pm.orig/drivers/thermal/thermal_trip.c > +++ linux-pm/drivers/thermal/thermal_trip.c > @@ -180,3 +180,40 @@ int thermal_zone_set_trip(struct thermal > > return 0; > } > + > +/** > + * thermal_zone_update_trip_temp - Update the trip point temperature. > + * @tz: Thermal zone. > + * @trip_priv: Trip tag. > + * @temp: New trip temperature. > + * > + * This only works for thermal zones using trip tables and its caller must > + * ensure that the zone lock is held before using it. > + * > + * @trip_priv is expected to be the value that has been stored by the driver > + * in the struct thermal_trip representing the trip point in question, so it > + * can be matched against the value of the priv field in that structure. > + * > + * If @trip_priv does not match any trip point in the trip table of @tz, > + * nothing happens. > + */ > +void thermal_zone_update_trip_temp(struct thermal_zone_device *tz, > + void *trip_priv, int temperature) > +{ > + int i; > + > + lockdep_assert_held(&tz->lock); > + > + if (!tz->trips || !trip_priv) > + return; > + > + for (i = 0; i < tz->num_trips; i++) { > + struct thermal_trip *trip = &tz->trips[i]; > + > + if (trip->priv == trip_priv) { > + trip->temperature = temperature; > + return; > + } > + } > +} > +EXPORT_SYMBOL_GPL(thermal_zone_update_trip_temp); This function would imply the comparator is always trip->priv but if we want another comparison eg. trip->priv->id, that won't be possible. Actually, I think you can reuse an existing function with a simple change, for_each_thermal_trip() located in thermal_core.h. The changes would be renaming it without the '__' prefix and moving it in include/linux/thermal.h. Then the comparison function and the temperature change can be an ACPI driver specific callback passed as parameter to for_each_thermal_zone > Index: linux-pm/include/linux/thermal.h > =================================================================== > --- linux-pm.orig/include/linux/thermal.h > +++ linux-pm/include/linux/thermal.h > @@ -286,9 +286,13 @@ int __thermal_zone_get_trip(struct therm > struct thermal_trip *trip); > int thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id, > struct thermal_trip *trip); > +void thermal_zone_update_trip_temp(struct thermal_zone_device *tz, > + void *trip_priv, int temperature); > > int thermal_zone_set_trip(struct thermal_zone_device *tz, int trip_id, > const struct thermal_trip *trip); > +void thermal_zone_update_trip_temp(struct thermal_zone_device *tz, > + void *trip_priv, int temperature); > > int thermal_zone_get_num_trips(struct thermal_zone_device *tz); > > > >
On Mon, Aug 7, 2023 at 1:34 PM Daniel Lezcano <daniel.lezcano@linaro.org> wrote: > > On 04/08/2023 23:05, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > > > Introduce a helper routine called thermal_zone_update_trip_temp() that > > can be used to update a trip point's temperature with the help of a > > pointer to local data associated with that trip point provided by > > the thermal driver that created it. > > > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > --- > > > > New patch in v4. > > > > --- > > drivers/thermal/thermal_trip.c | 37 +++++++++++++++++++++++++++++++++++++ > > include/linux/thermal.h | 4 ++++ > > 2 files changed, 41 insertions(+) > > > > Index: linux-pm/drivers/thermal/thermal_trip.c > > =================================================================== > > --- linux-pm.orig/drivers/thermal/thermal_trip.c > > +++ linux-pm/drivers/thermal/thermal_trip.c > > @@ -180,3 +180,40 @@ int thermal_zone_set_trip(struct thermal > > > > return 0; > > } > > + > > +/** > > + * thermal_zone_update_trip_temp - Update the trip point temperature. > > + * @tz: Thermal zone. > > + * @trip_priv: Trip tag. > > + * @temp: New trip temperature. > > + * > > + * This only works for thermal zones using trip tables and its caller must > > + * ensure that the zone lock is held before using it. > > + * > > + * @trip_priv is expected to be the value that has been stored by the driver > > + * in the struct thermal_trip representing the trip point in question, so it > > + * can be matched against the value of the priv field in that structure. > > + * > > + * If @trip_priv does not match any trip point in the trip table of @tz, > > + * nothing happens. > > + */ > > +void thermal_zone_update_trip_temp(struct thermal_zone_device *tz, > > + void *trip_priv, int temperature) > > +{ > > + int i; > > + > > + lockdep_assert_held(&tz->lock); > > + > > + if (!tz->trips || !trip_priv) > > + return; > > + > > + for (i = 0; i < tz->num_trips; i++) { > > + struct thermal_trip *trip = &tz->trips[i]; > > + > > + if (trip->priv == trip_priv) { > > + trip->temperature = temperature; > > + return; > > + } > > + } > > +} > > +EXPORT_SYMBOL_GPL(thermal_zone_update_trip_temp); > > This function would imply the comparator is always trip->priv but if we > want another comparison eg. trip->priv->id, that won't be possible. > > Actually, I think you can reuse an existing function with a simple > change, for_each_thermal_trip() located in thermal_core.h. for_each_thermal_trip() is only defined in tools/lib/thermal/thermal.c AFAICS, but this one could actually work, so I can copy that definition to somewhere else. But I suppose that you mean __for_each_thermal_trip() which won't work, because it makes a copy of the trip and passes that to the callback, but the callback would need to update the temperature of the original trip. It would work if it passed the original trip to the caller, so I can add something like that. > The changes would be renaming it without the '__' prefix and moving it > in include/linux/thermal.h. > > Then the comparison function and the temperature change can be an ACPI > driver specific callback passed as parameter to for_each_thermal_zone I guess you mean for_each_thermal_trip(). As per the above, not really, but I can do something along these lines.
On 07/08/2023 17:40, Rafael J. Wysocki wrote: > On Mon, Aug 7, 2023 at 1:34 PM Daniel Lezcano <daniel.lezcano@linaro.org> wrote: >> >> On 04/08/2023 23:05, Rafael J. Wysocki wrote: >>> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> >>> >>> Introduce a helper routine called thermal_zone_update_trip_temp() that >>> can be used to update a trip point's temperature with the help of a >>> pointer to local data associated with that trip point provided by >>> the thermal driver that created it. >>> >>> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> >>> --- >>> >>> New patch in v4. >>> >>> --- >>> drivers/thermal/thermal_trip.c | 37 +++++++++++++++++++++++++++++++++++++ >>> include/linux/thermal.h | 4 ++++ >>> 2 files changed, 41 insertions(+) >>> >>> Index: linux-pm/drivers/thermal/thermal_trip.c >>> =================================================================== >>> --- linux-pm.orig/drivers/thermal/thermal_trip.c >>> +++ linux-pm/drivers/thermal/thermal_trip.c >>> @@ -180,3 +180,40 @@ int thermal_zone_set_trip(struct thermal >>> >>> return 0; >>> } >>> + >>> +/** >>> + * thermal_zone_update_trip_temp - Update the trip point temperature. >>> + * @tz: Thermal zone. >>> + * @trip_priv: Trip tag. >>> + * @temp: New trip temperature. >>> + * >>> + * This only works for thermal zones using trip tables and its caller must >>> + * ensure that the zone lock is held before using it. >>> + * >>> + * @trip_priv is expected to be the value that has been stored by the driver >>> + * in the struct thermal_trip representing the trip point in question, so it >>> + * can be matched against the value of the priv field in that structure. >>> + * >>> + * If @trip_priv does not match any trip point in the trip table of @tz, >>> + * nothing happens. >>> + */ >>> +void thermal_zone_update_trip_temp(struct thermal_zone_device *tz, >>> + void *trip_priv, int temperature) >>> +{ >>> + int i; >>> + >>> + lockdep_assert_held(&tz->lock); >>> + >>> + if (!tz->trips || !trip_priv) >>> + return; >>> + >>> + for (i = 0; i < tz->num_trips; i++) { >>> + struct thermal_trip *trip = &tz->trips[i]; >>> + >>> + if (trip->priv == trip_priv) { >>> + trip->temperature = temperature; >>> + return; >>> + } >>> + } >>> +} >>> +EXPORT_SYMBOL_GPL(thermal_zone_update_trip_temp); >> >> This function would imply the comparator is always trip->priv but if we >> want another comparison eg. trip->priv->id, that won't be possible. >> >> Actually, I think you can reuse an existing function with a simple >> change, for_each_thermal_trip() located in thermal_core.h. > > for_each_thermal_trip() is only defined in tools/lib/thermal/thermal.c > AFAICS, but this one could actually work, so I can copy that > definition to somewhere else. > > But I suppose that you mean __for_each_thermal_trip() which won't > work, because it makes a copy of the trip and passes that to the > callback, but the callback would need to update the temperature of the > original trip. > > It would work if it passed the original trip to the caller, so I can > add something like that. As there is no user of this function yet, I think you can change that to use the trip array instead of the __thermal_zone_get_trip(). This one was used to have a compatibility with thermal zones using get_trip_* ops but that is not really needed and with your series only one driver will remain before dropping these ops. >> The changes would be renaming it without the '__' prefix and moving it >> in include/linux/thermal.h. >> >> Then the comparison function and the temperature change can be an ACPI >> driver specific callback passed as parameter to for_each_thermal_zone > > I guess you mean for_each_thermal_trip(). Yes, __for_each_thermal_trip() > As per the above, not really, but I can do something along these lines.
On Mon, Aug 7, 2023 at 6:17 PM Daniel Lezcano <daniel.lezcano@linaro.org> wrote: > > On 07/08/2023 17:40, Rafael J. Wysocki wrote: > > On Mon, Aug 7, 2023 at 1:34 PM Daniel Lezcano <daniel.lezcano@linaro.org> wrote: > >> > >> On 04/08/2023 23:05, Rafael J. Wysocki wrote: > >>> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > >>> > >>> Introduce a helper routine called thermal_zone_update_trip_temp() that > >>> can be used to update a trip point's temperature with the help of a > >>> pointer to local data associated with that trip point provided by > >>> the thermal driver that created it. > >>> > >>> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > >>> --- > >>> > >>> New patch in v4. > >>> > >>> --- > >>> drivers/thermal/thermal_trip.c | 37 +++++++++++++++++++++++++++++++++++++ > >>> include/linux/thermal.h | 4 ++++ > >>> 2 files changed, 41 insertions(+) > >>> > >>> Index: linux-pm/drivers/thermal/thermal_trip.c > >>> =================================================================== > >>> --- linux-pm.orig/drivers/thermal/thermal_trip.c > >>> +++ linux-pm/drivers/thermal/thermal_trip.c > >>> @@ -180,3 +180,40 @@ int thermal_zone_set_trip(struct thermal > >>> > >>> return 0; > >>> } > >>> + > >>> +/** > >>> + * thermal_zone_update_trip_temp - Update the trip point temperature. > >>> + * @tz: Thermal zone. > >>> + * @trip_priv: Trip tag. > >>> + * @temp: New trip temperature. > >>> + * > >>> + * This only works for thermal zones using trip tables and its caller must > >>> + * ensure that the zone lock is held before using it. > >>> + * > >>> + * @trip_priv is expected to be the value that has been stored by the driver > >>> + * in the struct thermal_trip representing the trip point in question, so it > >>> + * can be matched against the value of the priv field in that structure. > >>> + * > >>> + * If @trip_priv does not match any trip point in the trip table of @tz, > >>> + * nothing happens. > >>> + */ > >>> +void thermal_zone_update_trip_temp(struct thermal_zone_device *tz, > >>> + void *trip_priv, int temperature) > >>> +{ > >>> + int i; > >>> + > >>> + lockdep_assert_held(&tz->lock); > >>> + > >>> + if (!tz->trips || !trip_priv) > >>> + return; > >>> + > >>> + for (i = 0; i < tz->num_trips; i++) { > >>> + struct thermal_trip *trip = &tz->trips[i]; > >>> + > >>> + if (trip->priv == trip_priv) { > >>> + trip->temperature = temperature; > >>> + return; > >>> + } > >>> + } > >>> +} > >>> +EXPORT_SYMBOL_GPL(thermal_zone_update_trip_temp); > >> > >> This function would imply the comparator is always trip->priv but if we > >> want another comparison eg. trip->priv->id, that won't be possible. > >> > >> Actually, I think you can reuse an existing function with a simple > >> change, for_each_thermal_trip() located in thermal_core.h. > > > > for_each_thermal_trip() is only defined in tools/lib/thermal/thermal.c > > AFAICS, but this one could actually work, so I can copy that > > definition to somewhere else. > > > > But I suppose that you mean __for_each_thermal_trip() which won't > > work, because it makes a copy of the trip and passes that to the > > callback, but the callback would need to update the temperature of the > > original trip. > > > > It would work if it passed the original trip to the caller, so I can > > add something like that. > > As there is no user of this function yet, I think you can change that to > use the trip array instead of the __thermal_zone_get_trip(). This one > was used to have a compatibility with thermal zones using get_trip_* ops > but that is not really needed and with your series only one driver will > remain before dropping these ops. Sounds good. > >> The changes would be renaming it without the '__' prefix and moving it > >> in include/linux/thermal.h. > >> > >> Then the comparison function and the temperature change can be an ACPI > >> driver specific callback passed as parameter to for_each_thermal_zone > > > > I guess you mean for_each_thermal_trip(). > > Yes, __for_each_thermal_trip() OK
Index: linux-pm/drivers/thermal/thermal_trip.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_trip.c +++ linux-pm/drivers/thermal/thermal_trip.c @@ -180,3 +180,40 @@ int thermal_zone_set_trip(struct thermal return 0; } + +/** + * thermal_zone_update_trip_temp - Update the trip point temperature. + * @tz: Thermal zone. + * @trip_priv: Trip tag. + * @temp: New trip temperature. + * + * This only works for thermal zones using trip tables and its caller must + * ensure that the zone lock is held before using it. + * + * @trip_priv is expected to be the value that has been stored by the driver + * in the struct thermal_trip representing the trip point in question, so it + * can be matched against the value of the priv field in that structure. + * + * If @trip_priv does not match any trip point in the trip table of @tz, + * nothing happens. + */ +void thermal_zone_update_trip_temp(struct thermal_zone_device *tz, + void *trip_priv, int temperature) +{ + int i; + + lockdep_assert_held(&tz->lock); + + if (!tz->trips || !trip_priv) + return; + + for (i = 0; i < tz->num_trips; i++) { + struct thermal_trip *trip = &tz->trips[i]; + + if (trip->priv == trip_priv) { + trip->temperature = temperature; + return; + } + } +} +EXPORT_SYMBOL_GPL(thermal_zone_update_trip_temp); Index: linux-pm/include/linux/thermal.h =================================================================== --- linux-pm.orig/include/linux/thermal.h +++ linux-pm/include/linux/thermal.h @@ -286,9 +286,13 @@ int __thermal_zone_get_trip(struct therm struct thermal_trip *trip); int thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id, struct thermal_trip *trip); +void thermal_zone_update_trip_temp(struct thermal_zone_device *tz, + void *trip_priv, int temperature); int thermal_zone_set_trip(struct thermal_zone_device *tz, int trip_id, const struct thermal_trip *trip); +void thermal_zone_update_trip_temp(struct thermal_zone_device *tz, + void *trip_priv, int temperature); int thermal_zone_get_num_trips(struct thermal_zone_device *tz);