From patchwork Thu Dec 21 12:48:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 182183 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp383860dyi; Thu, 21 Dec 2023 04:49:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzKQkV4u3S4Gg7bYogvWBeV7dZIOYvDbpeLdDAipmGAJjQ8wUOO1l432u9aVPo96rsy41u X-Received: by 2002:a05:6a21:3286:b0:18f:c339:3fd9 with SMTP id yt6-20020a056a21328600b0018fc3393fd9mr658611pzb.73.1703162980418; Thu, 21 Dec 2023 04:49:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703162980; cv=none; d=google.com; s=arc-20160816; b=DKSxN26lcrCfUa3tJoIWHxQbhBgV2+lvixzJzT0LlhiPLXHCuMp5kZGLBUSV+6CUTX EbmAcbV0c+MZSzcAikCPPEF7b4X6Woxf4sWWtZlL0/kHj4ytnLOohcRtsMctDmkTbCAo 2DNjXyj32QoZ3UrdSAY6WctmnlHzy8fjfmcQKTvX4+Tul60Ncqt2A46TP2DJobDVNyIP r1iErKSlH6JU4QXaXgXvsfZ9v0NT7+EEJ7zmvEEscN9qabkY2MEIXTrPvUEl9wu0bNiP 31HlpJ43pWroUyGejrqxYKgXblYKaW6sWYkkRw0tvz58UlanfXSb8S0Kwy+mOiNxYI8P cEbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=YZyFFwdcu1o9xTxjmDE9a9tt5jMcjXFBIHVP1HTc3L8=; fh=tj3vwvS1joPqVAqhm025RI9FzN3aC+9rlGGIIVsXGr8=; b=GdKu5zPU5DBCXcU2bSMYgYCdN5V+RtBJPQlcCkiIhZ09uBqrrdPwzk4a/XgnSCjax1 SfLYgtvgF5r3paf2nq/fO6irYshcy8qpDl49DKVZei3iXPsMlhYD2kbHzI19X4p2924S /6WBAkI9tpO1hUR2GmxQ4IY2uNgaUBSBHpLBZCNVAsBjbK96vOb1SCbHJJhHCNg3rArD /ThEzVbZurnRyGu0JDUkM8OI8VInQNybYtx4q2ALGGMuDiG9IGbNwzheUNk+ilBGTmv7 AaZhDjbJm76bgxVE0Vf7xNcIb39TMOQdCGP5vbo1ZgYb7+m4RXS0qRYig9nXb1M+ZH48 Zn8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=e8l1ENh8; spf=pass (google.com: domain of linux-kernel+bounces-8368-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8368-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id a20-20020a1709027d9400b001d33c368c1bsi1415139plm.126.2023.12.21.04.49.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 04:49:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8368-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=e8l1ENh8; spf=pass (google.com: domain of linux-kernel+bounces-8368-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8368-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 47E1F283670 for ; Thu, 21 Dec 2023 12:49:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC73D7608B; Thu, 21 Dec 2023 12:48:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="e8l1ENh8" X-Original-To: linux-kernel@vger.kernel.org Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C09CF6EB7D; Thu, 21 Dec 2023 12:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1703162913; bh=hcDq139jNITXi7r1QTykVkAgtjt/plMZnUyanP1kC/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e8l1ENh83KKQ/+FT8K1P+/H6Xa+pRFRhXZr8kTT7IWCG83QKpHY8zyph3lc+rP0ZC 9QpdiUeZ21PyJLZIZ3eqbqM30af5qZUJLOeRaCPCaLHidHrRHYufkw4CeWtyTnneVm ELdd6MwZ132kX9JyLMM5/w8k1PVLJ8Vxrbo99Nzfq58J3rgeWUGrsce5QFi2cUCjUM MpHYEHRUC4vcyZt7qzP8AxHGgzEWm7pfPVyJhpDtb02hjLAhSWTkHVwFwOAL0uRQKp YGAQmg+AxwSdtnKlmpRkOkXF+QzEZW/FCbZ7mba7xBw2nX4JrH6Ydpk5TmXfy0ZUWT 4J0vesx0hvB9w== Received: from IcarusMOD.eternityproject.eu (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 86E773781F84; Thu, 21 Dec 2023 12:48:32 +0000 (UTC) From: AngeloGioacchino Del Regno To: daniel.lezcano@linaro.org Cc: rafael@kernel.org, rui.zhang@intel.com, lukasz.luba@arm.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, AngeloGioacchino Del Regno , kernel@collabora.com Subject: [RFC PATCH 01/26] thermal: Introduce thermal_zone_device_register() and params structure Date: Thu, 21 Dec 2023 13:48:00 +0100 Message-ID: <20231221124825.149141-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221124825.149141-1-angelogioacchino.delregno@collabora.com> References: <20231221124825.149141-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785895825780372523 X-GMAIL-MSGID: 1785895825780372523 In preparation for extending the thermal zone devices to actually have a name and disambiguation of thermal zone types/names, introduce a new thermal_zone_device_params structure which holds all of the parameters that are necessary to register a thermal zone device, then add a new function thermal_zone_device_register(). The latter takes as parameter the newly introduced structure and is made to eventually replace all usages of the now deprecated function thermal_zone_device_register_with_trips() and of thermal_tripless_zone_device_register(). Signed-off-by: AngeloGioacchino Del Regno --- drivers/thermal/thermal_core.c | 27 +++++++++++++++++++++++++++ include/linux/thermal.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index e5434cdbf23b..6be508eb2d72 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1235,6 +1235,8 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp); * whether trip points have been crossed (0 for interrupt * driven systems) * + * This function is deprecated. See thermal_zone_device_register(). + * * This interface function adds a new thermal zone device (sensor) to * /sys/class/thermal folder as thermal_zone[0-*]. It tries to bind all the * thermal cooling devices registered at the same time. @@ -1409,6 +1411,7 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t } EXPORT_SYMBOL_GPL(thermal_zone_device_register_with_trips); +/* This function is deprecated. See thermal_zone_device_register(). */ struct thermal_zone_device *thermal_tripless_zone_device_register( const char *type, void *devdata, @@ -1420,6 +1423,30 @@ struct thermal_zone_device *thermal_tripless_zone_device_register( } EXPORT_SYMBOL_GPL(thermal_tripless_zone_device_register); +/** + * thermal_zone_device_register() - register a new thermal zone device + * @tzdp: Parameters of the new thermal zone device + * See struct thermal_zone_device_register. + * + * This interface function adds a new thermal zone device (sensor) to + * /sys/class/thermal folder as thermal_zone[0-*]. It tries to bind all the + * thermal cooling devices registered at the same time. + * thermal_zone_device_unregister() must be called when the device is no + * longer needed. The passive cooling depends on the .get_trend() return value. + * + * Return: a pointer to the created struct thermal_zone_device or an + * in case of error, an ERR_PTR. Caller must check return value with + * IS_ERR*() helpers. + */ +struct thermal_zone_device *thermal_zone_device_register(struct thermal_zone_device_params *tzdp) +{ + return thermal_zone_device_register_with_trips(tzdp->type, tzdp->trips, tzdp->num_trips, + tzdp->mask, tzdp->devdata, tzdp->ops, + &tzdp->tzp, tzdp->passive_delay, + tzdp->polling_delay); +} +EXPORT_SYMBOL_GPL(thermal_zone_device_register); + void *thermal_zone_device_priv(struct thermal_zone_device *tzd) { return tzd->devdata; diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 98957bae08ff..c6ed33a7e468 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -258,6 +258,33 @@ struct thermal_zone_params { int offset; }; +/** + * struct thermal_zone_device_params - parameters for a thermal zone device + * @type: the thermal zone device type + * @tzp: thermal zone platform parameters + * @ops: standard thermal zone device callbacks + * @devdata: private device data + * @trips: a pointer to an array of thermal trips, if any + * @num_trips: the number of trip points the thermal zone support + * @mask: a bit string indicating the writeablility of trip points + * @passive_delay: number of milliseconds to wait between polls when + * performing passive cooling + * @polling_delay: number of milliseconds to wait between polls when checking + * whether trip points have been crossed (0 for interrupt + * driven systems) + */ +struct thermal_zone_device_params { + const char *type; + struct thermal_zone_params tzp; + struct thermal_zone_device_ops *ops; + void *devdata; + struct thermal_trip *trips; + int num_trips; + int mask; + int passive_delay; + int polling_delay; +}; + /* Function declarations */ #ifdef CONFIG_THERMAL_OF struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, int id, void *data, @@ -310,6 +337,8 @@ struct thermal_zone_device *thermal_tripless_zone_device_register( struct thermal_zone_device_ops *ops, const struct thermal_zone_params *tzp); +struct thermal_zone_device *thermal_zone_device_register(struct thermal_zone_device_params *tzdp); + void thermal_zone_device_unregister(struct thermal_zone_device *tz); void *thermal_zone_device_priv(struct thermal_zone_device *tzd); @@ -372,6 +401,10 @@ static inline struct thermal_zone_device *thermal_tripless_zone_device_register( const struct thermal_zone_params *tzp) { return ERR_PTR(-ENODEV); } +static inline struct thermal_zone_device *thermal_zone_device_register( + struct thermal_zone_device_params *tzdp) +{ return ERR_PTR(-ENODEV); } + static inline void thermal_zone_device_unregister(struct thermal_zone_device *tz) { }