From patchwork Fri Mar 24 07:08:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 74380 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp430812vqo; Fri, 24 Mar 2023 00:15:46 -0700 (PDT) X-Google-Smtp-Source: AK7set/0lY0eX7OltWuqNfemvVjt0MWeD+7stA3gioQ+teGQWwQOkzzdGFEYBMoWT8QyW+H/2FzR X-Received: by 2002:a05:6a20:3104:b0:d9:91d2:b81e with SMTP id 4-20020a056a20310400b000d991d2b81emr1764373pzf.62.1679642145734; Fri, 24 Mar 2023 00:15:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679642145; cv=none; d=google.com; s=arc-20160816; b=BhrIUz0uSYiWbnB2YXLNz3CpLZm14PhxJBkxt/7BQaXSggUVaHXuT43IFwgMUwpQHs O5gDl9bbxBX/VQDDm7Shsz//BGNdEX46eBY5tgEqO52vEokWRv9sQKBrpHqMLDryr1n0 Mq8N7JHurEOphiPNOFBQ6k/5JpzTeGuJSKnIoq9yTrq/vGo+oVSA18F9HCuYIp0B+nxW ecyxzOLgG7P2AVPoaA4NVUIt2ieViQof668xmpwHEOxdT+TooiI1RiU5NXYdpzuKbJRw YTa1EQRBbdwgU+7ZSLqh2YFdqs+rF5ZBlg+UXq7FNqSnLiY5WniD9vFUiFPx8TVhfVIt oLBg== 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=Ls2mZeeu7roxMjEXsoSO2ZAJNsGdzwJ8fJ9rss3YYX8=; b=qFWvUnO9Nc5MyQvyJfGp7/SdQwhWTUlJSclPMgK5XZSY3LudvsVo+MZEA7K5hkX2XN D7yGW0dAIDBo+TQw8+VlYYjMYpnDFYzF7RMxIsB1Cb/Fmzy5/poWM0+cygDrHuTCE4GO YxYzKhq0GEoczgPU+LrFLGAJ/KqTcC8uT9CrfJc5KzMjs/0QVtanFXFwvfbbBkVjbLdI WAcz1k6jWHj8TBuHOLWsDDg9RYAvY53HJRSzIlg6ES5D2Pr1tRTH9AY9XbgqNqsx/rGT QIoZLmEIMAyfi9mSqr/PndkudXEiX3SZ05PeNwcvHgvXhlCS3xR4ih76kVTqCr0CDd8g Ly3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aUvsfTZq; 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 s15-20020a65690f000000b005032da7f05dsi20596954pgq.508.2023.03.24.00.15.33; Fri, 24 Mar 2023 00:15:45 -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=aUvsfTZq; 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 S231489AbjCXHIi (ORCPT + 99 others); Fri, 24 Mar 2023 03:08:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231241AbjCXHIY (ORCPT ); Fri, 24 Mar 2023 03:08:24 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C9B95261; Fri, 24 Mar 2023 00:08:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679641702; x=1711177702; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Is2PNwJDYKRvv3xNHfYVY2PhgMrlEfNhGTel6iyfNy8=; b=aUvsfTZqzs4/PkVoh8LJ+/8S0So/E1+Cli7KlLLMJP3dsW6toxaS+VW6 RWalAUS/V4yHCoj+Bq1IlqZ+PXT2tSC+cQ5wCQbY/suSft6+mS9fMdPYD /a4s4k/HdgrJ7QSQqtjg1f6JhCGTpv/gzu3sLhh1n3PIWrLfnWyInZBtP 0nG5tWLX+Cue+Y3Sd9aaVN1G2Cs6+ECswDbBueFwFrpQ/ep+nQIacm8IN a183X1RDkm3Pel4aoTZLZN+GtNF1eiwhDGMLWFz7DOCzqjhkjv2Bq5Quk fs724P15gRpswH6w6CEtoVARjkR+WfGZtMeDfkbHknKysWgPS5I3VFBnF w==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402296736" X-IronPort-AV: E=Sophos;i="5.98,287,1673942400"; d="scan'208";a="402296736" 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:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="747046063" X-IronPort-AV: E=Sophos;i="5.98,287,1673942400"; d="scan'208";a="747046063" 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:20 -0700 From: Zhang Rui To: linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com, daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 5/5] thermal/core: Avoid unbind for thermal zones without .unbind() Date: Fri, 24 Mar 2023 15:08:07 +0800 Message-Id: <20230324070807.6342-5-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761232442393518581?= X-GMAIL-MSGID: =?utf-8?q?1761232442393518581?= The ops->bind()/unbind() callback is the only way to bind/unbind a cooling device to/from a thermal zone. Optimize the code to avoid trying unbind when .unbind() callback doesn't exist. Signed-off-by: Zhang Rui --- drivers/thermal/thermal_core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 9c447f22cb39..1af36450f13e 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1411,6 +1411,9 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) } list_del(&tz->node); + if (!tz->ops->unbind) + goto unbind_done; + /* Unbind all cdevs associated with 'this' thermal zone */ list_for_each_entry(cdev, &thermal_cdev_list, node) { struct thermal_instance *ti; @@ -1428,8 +1431,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) continue; unbind: - if (tz->ops->unbind) - tz->ops->unbind(tz, cdev); + tz->ops->unbind(tz, cdev); /* * The thermal instances for current thermal zone has been @@ -1441,6 +1443,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) mutex_unlock(&cdev->lock); } +unbind_done: mutex_unlock(&thermal_list_lock); cancel_delayed_work_sync(&tz->poll_queue);