Message ID | 20230324070807.6342-4-rui.zhang@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp432446vqo; Fri, 24 Mar 2023 00:19:40 -0700 (PDT) X-Google-Smtp-Source: AKy350Y05Bzym1lyYLXI0iGQhY5hJNdletwyVsdO54YApNjN14FkFAlee4pb+YkVwm5JoK/74ynB X-Received: by 2002:a17:906:9619:b0:922:446b:105a with SMTP id s25-20020a170906961900b00922446b105amr1751771ejx.19.1679642380345; Fri, 24 Mar 2023 00:19:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679642380; cv=none; d=google.com; s=arc-20160816; b=vVlWIxHnDRJOLwMBWbzeNFx9HqatiLvYrsyQlZWO66Eon7MffluX9YEL4UHXBw1+zp jyYZ76v5M8OeXaT/zeA68Bt/3YNFces4zfm3QTTAPhqloSM1DF0nRQ5Z89lznqfcq2rH URZdO2PSoDWDEGgHrBOxbNqa7MsjTJxwRcPm4pC3BHyPBkRiZdF/yY50Awk1kDZdLxDV QX6mrd9DP1et+M/L89zXjAp6t637/SxKCzp+cTNA7bqPlkVkAeKhMgXMdZS1N1+FNPG9 QgY3JymHTXu95dosg8oL8bV24ZMOlpv8cNXoXErAlWdRrPJx7whnSKi3G9D1K6+X0bhb JhjQ== 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 :dkim-signature; bh=IpxBKNfauOCmaQD3yyV8OgghieykzYY6kndQM1S08pI=; b=PwQgpRA/ajPbBXduTK7I2XREYgGGPrZ5LseiCtI9/IjLreJaIMseK+kU65o1ZKuMpb 9xGE1h374s2z2tUZ0hc5omy9CoiGxz+m876o2gqSlsGQlqrPm22k3WBQ4lcZ8psuHWk5 g6Ffjf8bnGT9ndE/e8b+IrlC6xnDWDnBep/9n701iecVJL3uUQQPESG52Kkg5f3ccIji 8F16CcD1mPXvPs0zPy2J9rAsJRQ/H4pxB6Ojq+tXUheR/2wUILTmdpWDxBqGZybYHOAI +/pgJPhDiSJGxhc6X9WzVjIPv79Rq0l8vC1utO91kOiyCyIUGviauD0UIszj7p5dTekL zV4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=abu2PdgA; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y21-20020a17090614d500b00922cbf5c852si4839050ejc.388.2023.03.24.00.19.08; Fri, 24 Mar 2023 00:19:40 -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=@intel.com header.s=Intel header.b=abu2PdgA; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231419AbjCXHIf (ORCPT <rfc822;ezelljr.billy@gmail.com> + 99 others); Fri, 24 Mar 2023 03:08:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231196AbjCXHIV (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 24 Mar 2023 03:08:21 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E33FD10ABA; Fri, 24 Mar 2023 00:08:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679641700; x=1711177700; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wFx21pLLRhlzjgfRpaT39oVLARW7iuGOv5zrbZTnlkk=; b=abu2PdgA1eA702P8ApPn2n/+vMIRXDH5u+K5esz1fQAaD/SyvTv8hW03 gj+1vkJnB/IsZnKc88jr6Kk4ZkdKsR7DbyHQdZElF+quhahn3NQ6VMwD6 CPhsx/EE+494mQUekW6gvKTM+yzmCugKCxoASD1tGBpw3un9/IZcnx+YG pWhXbGBx3dZFwCNJbqRkcC0s7s2Rm7oGWLc/+Gkp1DaacJCMWSKe0q6CH IASfyqFyXoVdbiZS14CFHN7N9tBE3n1QWTwA3bOZPAXBRfdFXPrt2Km03 ubDuAhtHHKcKEyfcpsukclgM+EjCfqkqs7st5OoKcR1UkFvK/dolAQcOX g==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402296729" X-IronPort-AV: E=Sophos;i="5.98,287,1673942400"; d="scan'208";a="402296729" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2023 00:08:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="747046060" X-IronPort-AV: E=Sophos;i="5.98,287,1673942400"; d="scan'208";a="747046060" Received: from fli4-mobl1.ccr.corp.intel.com (HELO rzhang1-DESK.intel.com) ([10.255.28.30]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2023 00:08:19 -0700 From: Zhang Rui <rui.zhang@intel.com> To: linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com, daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 4/5] thermal/core: Enforce paired .bind/.unbind callbacks Date: Fri, 24 Mar 2023 15:08:06 +0800 Message-Id: <20230324070807.6342-4-rui.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230324070807.6342-1-rui.zhang@intel.com> References: <20230324070807.6342-1-rui.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=unavailable 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761232688946415546?= X-GMAIL-MSGID: =?utf-8?q?1761232688946415546?= |
Series |
[v2,1/5] thermal/core: Update cooling device during thermal zone unregistration
|
|
Commit Message
Zhang, Rui
March 24, 2023, 7:08 a.m. UTC
The .bind/.unbind callbacks are designed to allow the thermal zone
device to bind to/unbind from a matched cooling device, with thermal
instances created/deleted.
In this sense, .bind/.unbind callbacks must exist in pairs.
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
drivers/thermal/thermal_core.c | 5 +++++
1 file changed, 5 insertions(+)
Comments
On Fri, Mar 24, 2023 at 8:08 AM Zhang Rui <rui.zhang@intel.com> wrote: > > The .bind/.unbind callbacks are designed to allow the thermal zone > device to bind to/unbind from a matched cooling device, with thermal > instances created/deleted. > > In this sense, .bind/.unbind callbacks must exist in pairs. > > Signed-off-by: Zhang Rui <rui.zhang@intel.com> > --- > drivers/thermal/thermal_core.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c > index 5225d65fb0e0..9c447f22cb39 100644 > --- a/drivers/thermal/thermal_core.c > +++ b/drivers/thermal/thermal_core.c > @@ -1258,6 +1258,11 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t > if (num_trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp) && !trips) > return ERR_PTR(-EINVAL); > > + if ((ops->bind && !ops->unbind) || (!ops->bind && ops->unbind)) { This can be written as if (!!ops->bind != !!ops->unbind) { > + pr_err("Thermal zone device .bind/.unbind not paired\n"); And surely none of the existing drivers do that? Because it would be a functional regression if they did. > + return ERR_PTR(-EINVAL); > + } > + > if (!thermal_class) > return ERR_PTR(-ENODEV); > > --
On Fri, Mar 24, 2023 at 2:24 PM Rafael J. Wysocki <rafael@kernel.org> wrote: > > On Fri, Mar 24, 2023 at 8:08 AM Zhang Rui <rui.zhang@intel.com> wrote: > > > > The .bind/.unbind callbacks are designed to allow the thermal zone > > device to bind to/unbind from a matched cooling device, with thermal > > instances created/deleted. > > > > In this sense, .bind/.unbind callbacks must exist in pairs. > > > > Signed-off-by: Zhang Rui <rui.zhang@intel.com> > > --- > > drivers/thermal/thermal_core.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c > > index 5225d65fb0e0..9c447f22cb39 100644 > > --- a/drivers/thermal/thermal_core.c > > +++ b/drivers/thermal/thermal_core.c > > @@ -1258,6 +1258,11 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t > > if (num_trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp) && !trips) > > return ERR_PTR(-EINVAL); > > > > + if ((ops->bind && !ops->unbind) || (!ops->bind && ops->unbind)) { > > This can be written as > > if (!!ops->bind != !!ops->unbind) { Or even if (!ops->bind != !ops->unbind) { for that matter. > > > + pr_err("Thermal zone device .bind/.unbind not paired\n"); > > And surely none of the existing drivers do that? Because it would be > a functional regression if they did. > > > + return ERR_PTR(-EINVAL); > > + } > > + > > if (!thermal_class) > > return ERR_PTR(-ENODEV); > > > > --
On Fri, 2023-03-24 at 14:24 +0100, Rafael J. Wysocki wrote: > On Fri, Mar 24, 2023 at 8:08 AM Zhang Rui <rui.zhang@intel.com> > wrote: > > The .bind/.unbind callbacks are designed to allow the thermal zone > > device to bind to/unbind from a matched cooling device, with > > thermal > > instances created/deleted. > > > > In this sense, .bind/.unbind callbacks must exist in pairs. > > > > Signed-off-by: Zhang Rui <rui.zhang@intel.com> > > --- > > drivers/thermal/thermal_core.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/drivers/thermal/thermal_core.c > > b/drivers/thermal/thermal_core.c > > index 5225d65fb0e0..9c447f22cb39 100644 > > --- a/drivers/thermal/thermal_core.c > > +++ b/drivers/thermal/thermal_core.c > > @@ -1258,6 +1258,11 @@ > > thermal_zone_device_register_with_trips(const char *type, struct > > thermal_trip *t > > if (num_trips > 0 && (!ops->get_trip_type || !ops- > > >get_trip_temp) && !trips) > > return ERR_PTR(-EINVAL); > > > > + if ((ops->bind && !ops->unbind) || (!ops->bind && ops- > > >unbind)) { > > This can be written as > > if (!!ops->bind != !!ops->unbind) { > > > + pr_err("Thermal zone device .bind/.unbind not > > paired\n"); > > And surely none of the existing drivers do that? Because it would be > a functional regression if they did. Yeah, I did a check and all drivers provide .bind/.unbind callbacks in pairs. Hi, Daniel, I know you're dealing with various of thermal drivers recently, are you aware of any exceptions? thanks, rui
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 5225d65fb0e0..9c447f22cb39 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1258,6 +1258,11 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t if (num_trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp) && !trips) return ERR_PTR(-EINVAL); + if ((ops->bind && !ops->unbind) || (!ops->bind && ops->unbind)) { + pr_err("Thermal zone device .bind/.unbind not paired\n"); + return ERR_PTR(-EINVAL); + } + if (!thermal_class) return ERR_PTR(-ENODEV);