From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AF3AC001DF for ; Mon, 7 Aug 2023 11:34:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232925AbjHGLeP (ORCPT ); Mon, 7 Aug 2023 07:34:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233316AbjHGLde (ORCPT ); Mon, 7 Aug 2023 07:33:34 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5905B4C3B for ; Mon, 7 Aug 2023 04:31:12 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fe5c0e587eso8281445e9.0 for ; Mon, 07 Aug 2023 04:31:12 -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=dnsGQL2m/Ll3NDnIefeMnpjLLvFfufMh1A4lqEx1n0cMPrJOj7ggjnWnfs4QRxxTF/ JJBM4gFg/fO0qy6ocZ9mJhQ5zPPbCILlmOwcM+Ok6Qcbcz0wuMc076Uy7NxQe2eDzlWX P+A4N15D8a3MtHM988T2CMvUEHEy7D8qEwNlVtHQ/6jTUVmhxA+78wpbOlsszDetO9Ws eA8U8vbNVtm4Tk0/SntKwuM/NtSeOyC+TPIqq7TscVNNn7xgtu3wYUuf5mm+CnZ5XzgR veccmlLbwAop56oCST1s+bj4wWtEQztsIKk6QtSbxqZl4Lfo+K2TZO5k0GCYmUnXY9XW FZZg== X-Gm-Message-State: AOJu0YwnX2GvKd4tctE4w7pzRU9PiVj3Wz5D1HD3OIzXCY0eI1RzGuC5 sKhvb+Ipz4coLsRhHkCkUEFgjvujPTg9RNarGmY= X-Google-Smtp-Source: AGHT+IE931aONdpzSikETzjGEE2Uo9weVSJZlo9N1M9Pmrb143I2wh0bzp6eN+8C49HMcUZmE6ni2Q== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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