Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp257382pxb; Wed, 22 Sep 2021 01:12:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrbPDa34/xW4Tqn0xXi+9aXs4iTyRmx4zFUqnaOsCgq8FN74mzG6Ux/b5dXjh3G8TE3yA1 X-Received: by 2002:a17:906:6c94:: with SMTP id s20mr41098365ejr.152.1632298361949; Wed, 22 Sep 2021 01:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632298361; cv=none; d=google.com; s=arc-20160816; b=vNhm5/kkJngxEpJTjYUyGpn3pEUJsgcD1c1a43y4M3e/6FqE6WqtiURcSJvl0qI5Bx 9vw20XSGFtaAFmKM8eZWZsRuHNG1/QJ7Np9TDgPnDucLQ4dhlHYqEAftl08CqsiNEDKw xo8kb3HKeoeQNnwOpcb7BLPIRe7XowON/5fiFnwBt/b2W4aQYWTfLVWguY+NKvkIU4M4 7jB/oeTWh/LZ5vFePCo3GrlHWTWA08Yzn8x7rvHiumr8Rdu5z9ZybXV6QMhHCeMNzVAP SyLU8V6pZ1+gPjnqYPlwVL/TG16fyaDC/qFC5oSzd7G7tLFyv8YsPqHVgrQL7RbLBhnP XIlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=sjfqFtjdJ7BBJE8A/g20sALymYT3IpdH2eEO6YWS1Ds=; b=Kds6Zy4eRBg6AOQv6JAG+2TpBiJdyEOZFjiNEYzvByG8gubirHosz7mSvXbk4PZptY zVdDCcbAoVF7PIBI1MH8pKuDnjsI+YHW2ZM9gWtB3dSZhu/L34UXETEQfygVuJziUlE/ 4OBDSeeYo+4dylP8R/H179E4f3A6tjAcIQfOACxZsrJDYu4yIKeq/E17/Tyxqw3dSoOE m+/CqfC67MjsBPCXhFNxa1fdIKamWvi8Cw5dP2R2N/IumGdYQf9qMvdZ/cvR3D3vIRlN Q6lRPUfZOyTYH9INmqcixrsNvLecUoceRAOwZ5lEt6OWdqGoyV7PyiLyg0QDkW+5SCoQ f7hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NNr9niA+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id my7si1844410ejc.262.2021.09.22.01.12.18; Wed, 22 Sep 2021 01:12:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NNr9niA+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S233435AbhIVIMD (ORCPT + 99 others); Wed, 22 Sep 2021 04:12:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233349AbhIVIMC (ORCPT ); Wed, 22 Sep 2021 04:12:02 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF439C061756 for ; Wed, 22 Sep 2021 01:10:32 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id t18so4419315wrb.0 for ; Wed, 22 Sep 2021 01:10:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=sjfqFtjdJ7BBJE8A/g20sALymYT3IpdH2eEO6YWS1Ds=; b=NNr9niA+rBKeMBi4aYpw3WOaB0s1c/Z+kBCqwKQ3VhAQqBU8VvqNqHRcw8dyFIhbll hAUlZD7/S9i0b6btgaCsEwp1bmXYA6x8BpEif/8Y9WhBiGRmbqtVtTo/n+V+mCrg41In HvvCul9Or1Kx07sjTLimYABtPLaV+xIYyyfNmAjYqH/P41OGQWbgnI7Qwctvl2uRH1Va 2Bzub4Uge2VG9mAwAklB4EVK8qnQTzPeYwyWVoZxQckjBv54trntvgB2QC8PLyOGv1Sx xSyoHhlHQZ21hBTt35bBYxvv+oJQfldUXKWwdf5IA+0lCIGu92Sbeb95aVRsMXKdxWke /w8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=sjfqFtjdJ7BBJE8A/g20sALymYT3IpdH2eEO6YWS1Ds=; b=aI6JDvhNoB1eqnCLDYLG29X07pxnrHjQ+u/EutUUYV+knr3w+Iwoz7Ru2NGeTvVTFl r4oDDUofSsMvMMMjui3fhxR8q58m3IDXeT4cUQriXC1esIKQFOG8psUUsWK83QBLpXbB TYt5dajxtJ/+rnbVgHU26lNReAWHlobBZU9zUxIf1LqXyPsnnLU0rT5mPVwEhPHdMIB+ aaC8pqWvb4QycQCB3Gt9gXaRHW9n/o5wY0mau0+sKdtZblIXD/qLJSAtG8MpRTzRH4ME S8lb3WiPL3nui4Px9oYCggon9GgUJfNvHwX0JIe298OVSJvYPc06Fe0D5Zjvchy/lUcS AyQg== X-Gm-Message-State: AOAM532rbH9M8kJma4D5amsp738XT/liKPf+tAbtnIw3Agq5x01TcAII EUw3pIyC68IoodsUxrco0i0E4vqUSXFxlg== X-Received: by 2002:a5d:5541:: with SMTP id g1mr41009909wrw.402.1632298231387; Wed, 22 Sep 2021 01:10:31 -0700 (PDT) Received: from ?IPv6:2a01:e34:ed2f:f020:8ccc:47ef:19b:1063? ([2a01:e34:ed2f:f020:8ccc:47ef:19b:1063]) by smtp.googlemail.com with ESMTPSA id k18sm1375822wrh.68.2021.09.22.01.10.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Sep 2021 01:10:30 -0700 (PDT) Subject: Re: [PATCH v2 0/2] Add a generic virtual thermal sensor To: Alexandre Bailon , rui.zhang@intel.com, amitk@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, ben.tseng@mediatek.com, khilman@baylibre.com, mka@chromium.org References: <20210917072732.611140-1-abailon@baylibre.com> <7cddcdb7-4efd-bfdb-3d86-f5862ea0b7fe@baylibre.com> <8a9e5f13-6253-2d0d-35a8-789090af4521@linaro.org> From: Daniel Lezcano Message-ID: <794e62ea-d867-3827-de5f-24ddc86c3524@linaro.org> Date: Wed, 22 Sep 2021 10:10:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20/09/2021 15:12, Alexandre Bailon wrote: > > On 9/17/21 4:03 PM, Daniel Lezcano wrote: >> On 17/09/2021 15:33, Alexandre Bailon wrote: >>> Hi Daniel, >>> >>> On 9/17/21 2:41 PM, Daniel Lezcano wrote: >>>> On 17/09/2021 09:27, Alexandre Bailon wrote: >>>>> This series add a virtual thermal sensor. >>>>> It could be used to get a temperature using some thermal sensors. >>>>> Currently, the supported operations are max, min and avg. >>>>> The virtual sensor could be easily extended to support others >>>>> operations. >>>>> >>>>> Note: >>>>> Currently, thermal drivers must explicitly register their sensors to >>>>> make them >>>>> available to the virtual sensor. >>>>> This doesn't seem a good solution to me and I think it would be >>>>> preferable to >>>>> update the framework to register the list of each available sensors. >>>> Why must the drivers do that ? >>> Because there are no central place where thermal sensor are registered. >>> The only other way I found was to update thermal_of.c, >>> to register the thermal sensors and make them available later to the >>> virtual thermal sensor. >>> >>> To work, the virtual thermal need to get the sensor_data the ops from >>> the thermal sensor. >>> And as far I know, this is only registered in thermal_of.c, in the >>> thermal zone data >>> but I can't access it directly from the virtual thermal sensor. >>> >>> How would you do it ? >> Via the phandles when registering the virtual sensor ? > As far I know, we can't get the ops or the sensor_data from the phandle > of a thermal sensor. > The closest solution I found so far would be to aggregate the thermal > zones instead of thermal sensors. > thermal_zone_device has the data needed and a thermal zone could be find > easily using its name. Yeah, the concept of the thermal zone and the sensor are very close. There is the function in thermal_core.h: -> for_each_thermal_zone() You should be able for each 'slave' sensor, do a lookup to find the corresponding thermal_zone_device_ops. > But, using a thermal_zone_device, I don't see how to handle module > unloading. I think try_module_get() / module_put() are adequate for this situation as it is done on an external module and we can not rely on the exported symbols. -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog