Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp2861608rwb; Mon, 7 Aug 2023 04:57:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSpZecmXnOHY9gJsZwxXVhLNWKsV0xSkkCBVrmFoiKpBSmYekP3om4K4nZDuzMLcEs16hZ X-Received: by 2002:a17:906:7692:b0:994:17e3:2753 with SMTP id o18-20020a170906769200b0099417e32753mr8393152ejm.26.1691409429881; Mon, 07 Aug 2023 04:57:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691409429; cv=none; d=google.com; s=arc-20160816; b=aoV46hO2OfT/Z1CNz5TLunR2ow56jKYZ7Cs8U18DSuqlMp+tNoFP6fF/iTcvoJemoQ yGu3VIIWIeKkSEmNABohhUcY/Wbi+lCWLeNtPkYZj/1vnpgvxhqSTov/W1VLK4FgTKiS UESilc/sxJPxi8W3/iKyzJQRXkzo0yUjb7h29uxRVhTQ7ko/7PeWS+jxN5Dpz/b+RwbR Hh70r4V8rpUZ7A/AAQokYDgZX2StiszxdWBWXZahMMUnAuacuo79SIoRSFUxPkmg9ytq kBLVRtofmYTrPkcMJKttJzG/lH/HoqyVD/QE7OmK1C3rHXK7/q0sbjj7eDi4rU+Sr88z t9qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=2yG847+ykANyrrRuOFOgUHlifio1mpwNPWStZ5ZsUlY=; fh=pEzMByEnePV36x3XCCNauQuREaASp/TIcmpU1ppDINA=; b=XEMH7lBR5ODYbEDLZzwn6CGwbZc4B/WgWvbmNuYAwViYre60PpveWzHa44Hsa03Jyx vQnoU1PsnwUstY5J/Yhg4Z06zIiwIKeAn7vHszGQ6HlgxCqFDAEMMAC9NbNQ5zRE7eDY WYzJs+yd4NWIQTRLBMEvdZp8XEy1oHsHEhTeSvq7wZO2TGxU+cqdMlDUz/bnxOkAp6GK zl5b5DtGAysTlBdfVJNGU/HRXYOQv8k86iJhnPgPldOAa1Nald6soUbqWmvjfotVFdpa JWgk9l6GfZhBLQP2xkt9VeLQ9fEyBr+SwP0XTnCc0oHEKykoK/0o4hPkqmelL9rojWlD 0Tcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BaO7SpJK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v26-20020a170906381a00b00997d002ae21si5153906ejc.90.2023.08.07.04.56.44; Mon, 07 Aug 2023 04:57: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; dkim=pass header.i=@linaro.org header.s=google header.b=BaO7SpJK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232934AbjHGLeQ (ORCPT + 99 others); Mon, 7 Aug 2023 07:34:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233313AbjHGLde (ORCPT ); Mon, 7 Aug 2023 07:33:34 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0B485248 for ; Mon, 7 Aug 2023 04:31:10 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fe5eb84d43so3864595e9.3 for ; Mon, 07 Aug 2023 04:31:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691407787; x=1692012587; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=2yG847+ykANyrrRuOFOgUHlifio1mpwNPWStZ5ZsUlY=; b=BaO7SpJKv1jDCZvrxi47UrPgRjKOD1RmEA5ftd1m1zmHe0gV4C+bk7yIUsI98W6BzS 55WzdvGGCvOtueyb9YwFEOr5ZL8MdRkIDGMM2QZb8wIGpKKDXwRaUPSslFUkVAKoD9We +r5MmONLSVZOuvZu9hJy5BlT4zY4xTi5F1DYHrrkP/YeTofw4ZvHL47imnoH1u8v2dJa YNETI0ySclIuryJ9WmY3b+vQr1II88Wt5+4zejrcpJ3OMfft1nATxN0y6K8d2JkekXw2 hc6vPMiGzrilbNrVkx7hjvPHX63Ajomg62r+WpB6amQI9Z7lZOTdXdIQq1KbM0kBOMVL g82w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691407787; x=1692012587; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2yG847+ykANyrrRuOFOgUHlifio1mpwNPWStZ5ZsUlY=; b=UUjLNXQmtbLApxob9aCfwsj4phc5K6bpSf5WCsuFSDjgaykV6783i9rPeWTnOrKlNG Gwr1XnUgrVvdd7y0Z/H5i4784yhQg7mgNvgdkHP0pmE5a6DCd7Q3OLdu0Elb/Zx7W0Tn tdmejDXJRW0eEmNBSGjlH2pAs0S8Rj+krsb6Y50A/xklTr9sokvcArQkO1bEXRT18Zb3 iqAPAYbMiiH8TmpqREJlP4RznW+JNz4epKvOR7X23bCHiK1hgUs/WCHEdBP8dM4s6EDu ngLie9dLdl+Ub12F0bI3R5wL+MLK9yp5wgYSmzuJS9tSDgquakl/wQ6usNJINXbUARDi 4zfA== X-Gm-Message-State: AOJu0Yw1gW/pCDy5fcZ97yJT165blLrkpV5DPsmB4ywhf1XPHvRGpdv3 iQ2v/ufz5IIGnlGsft97BYAxMA== X-Received: by 2002:a05:600c:208:b0:3fe:ad3:b066 with SMTP id 8-20020a05600c020800b003fe0ad3b066mr7051996wmi.41.1691407787574; Mon, 07 Aug 2023 04:29:47 -0700 (PDT) Received: from [192.168.10.46] (146725694.box.freepro.com. [130.180.211.218]) by smtp.googlemail.com with ESMTPSA id p17-20020a7bcc91000000b003fe2696ccfcsm10402137wma.23.2023.08.07.04.29.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Aug 2023 04:29:47 -0700 (PDT) Message-ID: Date: Mon, 7 Aug 2023 13:29:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v4 04/10] thermal: core: Add thermal_zone_update_trip_temp() helper routine Content-Language: en-US To: "Rafael J. Wysocki" , Linux ACPI Cc: LKML , Linux PM , Michal Wilczynski , Zhang Rui , Srinivas Pandruvada References: <13318886.uLZWGnKmhe@kreacher> <4878513.31r3eYUQgx@kreacher> <1967710.PYKUYFuaPT@kreacher> From: Daniel Lezcano In-Reply-To: <1967710.PYKUYFuaPT@kreacher> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, 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: X-Mailing-List: linux-kernel@vger.kernel.org On 04/08/2023 23:05, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > 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 > --- > > 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); > > > > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog